/* This is the vision module header file, including IPC message formats The default prefix for the Swarthmore vision module is SVM The enumerated IPC types are explicitly laid out so that debugging should be easier. Last modified: 4/19/02 */ #ifndef VisionModule_h #define VisionModule_h /******** Constant definitions ********/ // These definitions are relevant to data structure size // default maximum number of relevant regions in a single frame #define SVM_MAX_LOCATIONS 16 // max number of available vision operators #define SVM_NUM_OPERATORS 32 // max number of cameras #define SVM_NUM_CAMERAS 2 // These constants are used to communicate information from the operators #define SVM_GREEN_ON_TOP 0 #define SVM_RED_ON_TOP 1 // Shared memory id for the SVM #define SVM_SHARED_MEMORY_KEY 420 // These definitions are internal to the SVM #define SVM_DEFAULT_IMAGE_ROWS 240 // default image size #define SVM_DEFAULT_IMAGE_COLUMNS 320 #define SVM_DEFAULT_IMAGE_DEPTH 3 // default bytes per pixel #define SVM_DEFAULT_NUM_FRAMES 2 // default number of image buffers #define SVM_DEFAULT_FPS 30 // default frames per second #define SVM_DEFAULT_HFOV 871 // default FOV in milli-radians (0 zoom on PTZ) #define SVM_DEFAULT_VFOV 610 // default FOV in milli-radians (0 zoom on PTZ) #define SVM_MAX_PROCESSES 2 // maximum number of operators applied per frame #define SVM_MAX_PTZ_FRAMES 600 // maximum of about 10 seconds in control of the PTZ #define SVM_MIN_PTZ_FRAMES 15 // minimum of about 2/3 seconds in control #define SVM_MAX_PTZ_MISSES 10 // maximum number of misses before giving up control #define SVM_MIN_PTZ_MISSES 5 // minimum number of misses before giving up control #define SVM_BUFFER_SIZE (640*480) // vision buffer size for passing image data around #define SVM_PORTDUMP_DIVISOR 1 // scaline for image data dumped into the viewer buffer /******* type definitions and IPC type definitions **************/ // enumerated list of camera modes typedef enum {SVM_MODE_CAM1, // camera input 1 at 320 x 240 (max fps = 30) SVM_MODE_CAM0, // camera input 0 at 320 x 240 (max fps = 30) SVM_MODE_HRCAM1, // camera input 1 at 640 x 480 (max fps = 15) SVM_MODE_HRCAM0, // camera input 0 at 640 x 480 (max fps = 15) SVM_MODE_IDLE, // vision module is idle (no processing or capturing of images) SVM_MODE_START, // initial value SVM_MODE_QUIT} // vision module should quit SVM_Mode; #define SVM_Mode_FORMAT_NAME "SVM_Mode" #define SVM_Mode_FORMAT "{enum SVM_MODE_CAM1,SVM_MODE_CAM0,SVM_MODE_HRCAM1,SVM_MODE_HRCAM0,SVM_MODE_IDLE,SVM_MODE_QUIT}" // enumerated list of vision operators typedef enum { SVM_OP_Pink_Blob, /* Returns the location of bright pink blobs in the image. Can be used for robot competition participant badges */ SVM_OP_Color_Blobs, /* Returns the location of blobs of up to 8 different colors using rg histograms. The rg histograms have to be stored in the files svm_color{0-7}.pgm. Not all of them have to be there (but start at 0 and work up). */ SVM_OP_Read_Name_Tags, /* Tries to find AAAI style name tags and read them. */ SVM_OP_Reg_Booth, /* Tries to find the proper AAAI registration booth for the robot. */ SVM_OP_Face, /* Uses an rg histogram & gradient information to identify potential faces in the image. Can return multiple locations. The rg histogram must be stored as face.pgm in the working directory. */ SVM_OP_Shirt_Color, /* Based on face locations, it tries to identify the primary color of the person's shirt. */ SVM_OP_Identity, /* Based on face locations, it tries to identify whether it has seen the person in the recent past. Each unique entry in the short-term list has a number. The system only returns the number of the closest match if the person has been matched in at least 3 of the past ten matching attempts. */ SVM_OP_Hand, /* Uses an rg histogram to identify when there is a LOT of skin in the image. Can be used for palm reading tricks. Uses the same rg histogram as the face operator (face.pgm). */ SVM_OP_Italian_Flag, /* Returns the location of red-white-green flags in the image. Can indicate whether the red or green is on top. */ SVM_OP_Display, /* Pipes the current video input to the portImage buffer */ SVM_OP_Tray, /* Identifies how much food is left on a tray in front of the camera. Needs to be set up to look down at the tray. */ SVM_OP_Panorama /* Captures a panoramic image from a single camera while the robot is spinning in a circle */ } SVM_Operator; #define SVM_Operator_FORMAT_NAME "SVM_Operator" #define SVM_Operator_FORMAT "{enum SVM_OP_Pink_Blob,SVM_OP_Color_Blobs,SVM_OP_Read_Name_Tags,SVM_OP_Reg_Booth,SVM_OP_Face,SVM_OP_Shirt_Color,SVM_OP_Identity,SVM_OP_Hand,SVM_OP_Italian_Flag,SVM_OP_Display,SVM_OP_Tray}" typedef enum {SVM_TIMING_STOCHASTIC, // operator should run whenever possible SVM_TIMING_FIXED} // operator should run at fixed intervals (> 5 seconds apart) SVM_Operator_Timing; #define SVM_Operator_Timing_FORMAT_NAME "SVM_Operator_Timing" #define SVM_Operator_Timing_FORMAT "{enum SVM_TIMING_STOCHASTIC,SVM_TIMING_FIXED}" typedef enum {SVM_PTZ_DEFAULT, // operator doesn't care about camera position SVM_PTZ_FIXED, // operator needs to run with the camera in a set position SVM_PTZ_SEARCH, // operator needs to search (not implemented) SVM_PTZ_TRACKING, // operator needs to track its objects of interest SVM_PTZ_0PANTRACKING} // operator needs to track, but only using tilt capabilities SVM_PTZ_Attribute; #define SVM_PTZ_Attribute_FORMAT_NAME "SVM_PTZ_Attribute" #define SVM_PTZ_Attribute_FORMAT "{enum SVM_PTZ_DEFAULT,SVM_PTZ_FIXED,SVM_PTZ_SEARCH,SVM_PTZ_TRACKING,SVM_PTZ_0PANTRACKING}" // r, g, b color 0..255 typedef char SVM_Color[3]; #define SVM_Color_FORMAT_NAME "SVM_Color" #define SVM_Color_FORMAT "[char:3]" // x, y, z, a (a = how used?) typedef long SVM_Point[4]; #define SVM_Point_FORMAT_NAME "SVM_Point" #define SVM_Point_FORMAT "[long:4]" // top, left, bottom, right typedef long SVM_Box[4]; #define SVM_Box_FORMAT_NAME "SVM_Box" #define SVM_Box_FORMAT "[long:4]" typedef long SVM_Color_Bound[6]; // rmin, rmax, gmin, gmax, bmin, bmax 0..255 typedef enum {SVM_CAMERA_AUTO, SVM_CAMERA_FIXED, SVM_CAMERA_MANUAL, SVM_CAMERA_DEFAULT} SVM_Camera_Setting_Mode; #define SVM_Camera_Setting_Mode_FORMAT_NAME "SVM_Camera_Setting_Mode" #define SVM_Camera_Setting_Mode_FORMAT "{enum SVM_CAMERA_AUTO,SVM_CAMERA_FIXED,SVM_CAMERA_MANUAL,SVM_CAMERA_DEFAULT}" /* Camera configuration */ typedef struct { // overall parameters short active; // is the camera active? // PTZ parameters short usePTZ; // use the PTZ capabilities? short ptzID; // camera id (set internally, not in the config file) char controlPort[32]; // control port for the PTZ (ttyS0, ttyS1, ttyS2, ...) // current camera position: pan (mrad) tilt (mrad) zoom (0..127) height(mm) // pan and tilt are relative to the robot orientation (pan) and straight down (tilt) // height is relative to the ground plane long position[4]; // camera home position (pan (mrad), tilt (mrad), zoom (0..127)) long home[3]; // camera parameters SVM_Camera_Setting_Mode settingMode; short iris; short agc; short shutter; short wb; } SVM_Camera_Config; #define SVM_NUM_CAMERA_CONFIG_PARAMETERS 15 #define SVM_Camera_Config_FORMAT_NAME "SVM_Camera_Config" #define SVM_Camera_Config_FORMAT "{SVM_Camera_Config,short,short,short,[char:32],[short:4],[short:3],SVM_Camera_Setting_Mode,short,short,short,short}" /* Vision operator output data This data structure is used for publishing IPC messages */ typedef struct { SVM_Operator operatorID; /* indicates operator identity */ unsigned long timeStamp; /* time stamp indicating information age */ SVM_Point location[SVM_MAX_LOCATIONS]; /* centroids of relevant regions */ SVM_Box bbox[SVM_MAX_LOCATIONS]; /* bounding boxes of relevant regions */ long size[SVM_MAX_LOCATIONS]; /* size (in pixels) of relevant regions */ long numLocations; /* number of relevant regions */ long value[SVM_MAX_LOCATIONS]; /* general purpose integer values */ char text[128]; /* one text string */ SVM_Color color; /* relevant color */ } SVM_Operator_Data; // This if statement ensures that there is a match between // SVM_MAX_LOCATIONS and the values in the SVM_Operator_Data_FORMAT // string #if SVM_MAX_LOCATIONS == 16 #define SVM_Operator_Data_FORMAT_NAME "SVM_Operator_Data" #define SVM_Operator_Data_FORMAT "{SVM_Operator, long,[SVM_Point:16],[SVM_Box:16],[long:16],long,[long:16],[char:128],SVM_Color}" #endif /* This data structure holds the state of an operator. These are set to their initial default values on startup, but nothing is turned on (priority 0) */ typedef struct { int (*func)(void *robot, // standard operator interface void *data, unsigned char* image, const long imageHeight, const long imageWidth, const long imageDepth); SVM_Operator operatorID; // operator identity SVM_Operator_Data *data; // pointer to the SVM_OperatorData for this operator SVM_Operator_Timing timing; // tracking operators get executed on each frame short priority; /* stochastic priority OR seconds between execution time for fixed timing. If priority is 0, then the operator is not active. */ SVM_PTZ_Attribute ptzatt; // pan-tilt-zoom mode long ptzpos[3]; // desired pan (mrad), tilt (mrad), zoom position (0..127) for fixed position long arg; // free argument field, can be used to send additional data to the operator } SVM_Operator_State; /* IPC command data structure This data structure is how an external module modifies the state of an operator (issues a command). The fields have the same meaning as in the above data structure. */ typedef struct { SVM_Operator operatorID; // operator identity SVM_Operator_Timing timing; // stochastic or fixed short priority; // priority or # of seconds between application SVM_PTZ_Attribute ptzatt; // PTZ mode (don't care / fixed / tracking) long ptzpos[3]; // desired PTZ location for fixed, home position for tracking long arg; // free argument field } SVM_Operator_Command; #define SVM_Operator_Command_FORMAT_NAME "SVM_Operator_Command" #define SVM_Operator_Command_FORMAT "{SVM_Operator,SVM_Operator_Timing,short,SVM_PTZ_Attribute,[long:3],long}" // Data structure for the whole vision module typedef struct { // input variables to the vision module // camera mode (which camera, what resolution, idle, quit) SVM_Mode mode; // camera configurations SVM_Camera_Config camera[SVM_NUM_CAMERAS]; // state information for each vision operator SVM_Operator_State opState[SVM_NUM_OPERATORS]; // The moduleActive field is a flag set to 1 by the vision module // when it starts up. It is set to 0 when it shuts down. long moduleActive; // a big ol' image buffer for the visionPort monitor unsigned char portImage[SVM_DEFAULT_IMAGE_ROWS * SVM_DEFAULT_IMAGE_COLUMNS * 4]; // Operator data SVM_Operator_Data opData[SVM_NUM_OPERATORS]; // Buffers for passing information to the OCR module unsigned char bufferData[SVM_BUFFER_SIZE]; // some buffer space for trading around image data long bufferOffset[SVM_MAX_LOCATIONS]; // indicates where each buffer begins long bufferSize[SVM_MAX_LOCATIONS][2]; // indicates the size of the buffer (width (x), height (y)) unsigned long bufferTimeStamp[SVM_MAX_LOCATIONS]; // indicates when each buffer was filled unsigned char bufferFilling; // indicates the producer is filling the buffers (consumer don't switch buffers) unsigned char bufferUsing; // indicates the consumer is using this buffer (producer don't fill this one) } SVM_Vision_Module_Data; /******** IPC type definition calls (these go into a C file) ********/ /* // SVM mode type IPC_defineFormat(SVM_Mode_FORMAT_NAME, SVM_Mode_FORMAT); // Operator enumerated type IPC_defineFormat(SVM_Operator_FORMAT_NAME, SVM_Operator_FORMAT); // Operator timing enumerated type IPC_defineFormat(SVM_Operator_Timing_FORMAT_NAME, SVM_Operator_Timing_FORMAT); // PTZ Attribute enumerated type IPC_defineFormat(SVM_PTZ_Attribute_FORMAT_NAME, SVM_PTZ_Attribute_FORMAT); // Color data type IPC_defineFormat(SVM_Color_FORMAT_NAME, SVM_Color_FORMAT); // Point data type IPC_defineFormat(SVM_Point_FORMAT_NAME, SVM_Point_FORMAT); // Image rectangle IPC_defineFormat(SVM_Box_FORMAT_NAME, SVM_Box_FORMAT); // IPC format for information published by the SVM IPC_defineFormat(SVM_Operator_Data_FORMAT_NAME, SVM_Operator_Data_FORMAT); // IPC format for commands to individual SVM operators IPC_defineFormat(SVM_Operator_Command_FORMAT_NAME, SVM_Operator_Command_FORMAT); */ /******** IPC command definitions for the SVM ********/ // IPC message for setting the overall mode (camera & resolution, idle, quit) #define SVM_MODE "SVMMode" // IPC message for issuing a command to an SVM operator #define SVM_COMMAND "SVMCommand" // IPC message for requesting data from the SVM #define SVM_DATA_REQUEST "SVMDataRequest" // IPC message for receiving data from the SVM #define SVM_DATA_RESPONSE "SVMDataResponse" // IPC message formats for operator stream data /******** IPC message definition calls (these go into a C file) ********/ /* // set the mode by sending an SVM_Mode variable IPC_defineMsg(SVM_MODE, IPC_VARIABLE_LENGTH, SVM_Mode_FORMAT); // set an operator's state (on/off/PTZ attributes) by sending an operator command IPC_defineMsg(SVM_COMMAND, IPC_VARIABLE_LENGTH, SVM_Operator_Command_FORMAT); // request data from a specific operator by sending an SVM_Operator variable IPC_defineMsg(SVM_DATA_REQUEST, IPC_VARIABLE_LENGTH, SVM_Operator_FORMAT); // receive data from a specific operator IPC_defineMsg(SVM_DATA_RESPONSE, IPC_VARIABLE_LENGTH, SVM_Operator_Data_FORMAT); */ #endif

AltStyle によって変換されたページ (->オリジナル) /