00001 #ifndef CAMERA_H_
00002 #define CAMERA_H_
00003
00004 #ifdef __cplusplus
00005 extern "C"
00006 {
00007 #endif
00008
00009 #include <fcntl.h>
00010 #include <termios.h>
00011 #include <stdio.h>
00012 #include <time.h>
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include <unistd.h>
00016
00017
00018
00019
00020
00021
00022
00023 #include "playerconfig.h"
00024
00025
00026
00027
00028
00029 #define IMAGE_WIDTH 174 // the width of the frame camera sends
00030 #define IMAGE_HEIGHT 143 // the height of the frame camera sends
00031 #define CONTRAST 5 // camera's contrast register #
00032 #define BRIGHTNESS 6 // camera's brightness register #
00033 #define COLORMODE 18 // camera's colormode register #
00034 #define RGB_AWT_ON 44 // camera's RGB auto white balance on
00035 #define RGB_AWT_OFF 40 // camera'sRGB auto white balance off
00036 #define YCRCB_AWT_ON 36 // camera'sYCrCb auto white balance on
00037 #define YCRCB_AWT_OFF 32 // camera'sYCrCb auto white balance off
00038 #define AUTOGAIN 19 // camera's autogain register #
00039 #define AUTOGAIN_ON 33 // camera's autogain on
00040 #define AUTOGAIN_OFF 32 // camera's autogain off
00041 #define ZERO_POSITION 128 // servos' middle position as defiend by camera
00042 #define MIN_RGB 16 // camera's min rgb value
00043 #define MAX_RGB 240 // camera's max rgb value
00044 #define T_PACKET_LENGTH 50 // max length of T packet that camera returns
00045
00046
00047
00048
00049
00050 typedef struct
00051 {
00052 int middle_x, middle_y;
00053 int left_x;
00054 int left_y;
00055 int right_x;
00056 int right_y;
00057 int blob_area;
00058
00059 int confidence;
00060
00061 }packet_t;
00062
00063
00064
00065
00066 typedef struct
00067 {
00068 uint8_t subtype;
00069 int16_t brightness;
00070 int16_t contrast;
00071 int8_t colormode;
00072
00073
00074
00075
00076 int8_t autogain;
00077
00078
00079 } imager_config;
00080
00081
00082
00083
00084 typedef struct
00085 {
00086 uint8_t subtype;
00087 int16_t rmin, rmax;
00088 int16_t gmin, gmax;
00089 int16_t bmin, bmax;
00090 } color_config;
00091
00092
00093
00094
00095 typedef struct
00096 {
00097 int red;
00098 int green;
00099 int blue;
00100 } rgb;
00101
00102
00103
00104
00105 typedef struct
00106 {
00107 int width;
00108 int height;
00109 rgb **pixel;
00110 } image;
00111
00112 color_config range;
00113
00114
00115
00116
00117 int get_t_packet(int fd, packet_t *tpacket);
00118 int set_imager_config(int fd, imager_config ic);
00119 int get_bytes(int fd, char *buf, size_t len);
00120 int open_port(char *devicepath);
00121 void close_port(int fd);
00122 void read_t_packet(int fd, char *tpackChars);
00123 int set_t_packet( packet_t *tpacket, char tpack_chars[] );
00124 int set_servo_position(int fd, int servo_num, int angle);
00125 int get_servo_position(int fd, int servo_num);
00126 void stop_tracking(int fd);
00127 int write_check(int fd, char *msg, int respond_size);
00128 int poll_mode(int fd, int on);
00129 void make_command(char *cmd, int *n, size_t size, char *fullCommand);
00130 int auto_servoing(int fd, int on);
00131 void track_blob(int fd, color_config cc);
00132
00133 #ifdef __cplusplus
00134 }
00135 #endif
00136
00137 #endif