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