camera.h
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 #define F_PACKET_LENGTH 37474 // max length of F packet that camera returns
00046
00047
00048
00049
00050
00051 typedef struct
00052 {
00053 int middle_x, middle_y;
00054 int left_x;
00055 int left_y;
00056 int right_x;
00057 int right_y;
00058 int blob_area;
00059
00060 int confidence;
00061
00062 }packet_t;
00063
00064
00065
00066
00067 typedef struct
00068 {
00069 int r, g, b;
00070 } rgb_type;
00071
00072 typedef struct
00073 {
00074 int rowbyte;
00075 rgb_type rgb[IMAGE_WIDTH];
00076 } row_type;
00077
00078 typedef struct
00079 {
00080 int first;
00081 int xsize, ysize;
00082 row_type rows[IMAGE_HEIGHT];
00083 int last;
00084 } packet_f;
00085
00086
00087
00088
00089 typedef struct
00090 {
00091 uint8_t subtype;
00092 int16_t brightness;
00093 int16_t contrast;
00094 int8_t colormode;
00095
00096
00097
00098
00099 int8_t autogain;
00100
00101
00102 } imager_config;
00103
00104
00105
00106
00107 typedef struct
00108 {
00109 uint8_t subtype;
00110 int16_t rmin, rmax;
00111 int16_t gmin, gmax;
00112 int16_t bmin, bmax;
00113 } color_config;
00114
00115
00116
00117
00118 typedef struct
00119 {
00120 int red;
00121 int green;
00122 int blue;
00123 } rgb;
00124
00125
00126
00127
00128 typedef struct
00129 {
00130 int width;
00131 int height;
00132 rgb **pixel;
00133 } image;
00134
00135
00136
00137
00138
00139 int get_t_packet(int fd, packet_t *tpacket);
00140 int set_imager_config(int fd, imager_config ic);
00141 int get_bytes(int fd, char *buf, size_t len);
00142 int open_port(char *devicepath);
00143 void close_port(int fd);
00144 void read_t_packet(int fd, char *tpackChars);
00145 int read_f_packet (int fd, char *fpackChars);
00146 int set_t_packet( packet_t *tpacket, char tpack_chars[] );
00147 int set_f_packet (packet_f *fpacket, char fpack_chars[], int chan_num);
00148 int set_servo_position(int fd, int servo_num, int angle);
00149 int get_servo_position(int fd, int servo_num);
00150 void stop_tracking(int fd);
00151 int write_check(int fd, char *msg, int respond_size);
00152 int poll_mode(int fd, int on);
00153 void make_command(char *cmd, int *n, size_t size, char *fullCommand);
00154 int auto_servoing(int fd, int on);
00155 void track_blob(int fd, color_config cc);
00156 int read_image (int fd, int chan_num, packet_f *fpacket);
00157
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161
00162 #endif
Last updated 12 September 2005 21:38:45
|