26 #ifndef __CMVISION_H__
27 #define __CMVISION_H__
67 #define CMV_COLOR_LEVELS 256
68 #define CMV_MAX_COLORS 32
71 #define CMV_DEFAULT_WIDTH 320
72 #define CMV_DEFAULT_HEIGHT 240
75 #define CMV_MAX_RUNS (CMV_DEFAULT_WIDTH * CMV_DEFAULT_HEIGHT) / 4
76 #define CMV_MAX_REGIONS CMV_MAX_RUNS / 4
77 #define CMV_MIN_AREA 20
79 #define CMV_NONE ((unsigned)(-1))
90 unsigned char y1,u,y2,v;
94 unsigned char u,y1,v,y2;
106 unsigned char red,green,blue;
112 #define CMV_THRESHOLD 0x01
113 #define CMV_COLOR_AVERAGES 0x02
114 #define CMV_DUAL_THRESHOLD 0x04
115 #define CMV_DENSITY_MERGE 0x08
117 #define CMV_VALID_OPTIONS 0x0F
129 int sum_x,sum_y,sum_z;
166 unsigned y_class[CMV_COLOR_LEVELS];
167 unsigned u_class[CMV_COLOR_LEVELS];
168 unsigned v_class[CMV_COLOR_LEVELS];
170 region region_table[CMV_MAX_REGIONS];
171 region *region_list[CMV_MAX_COLORS];
172 int region_count[CMV_MAX_COLORS];
174 rle rmap[CMV_MAX_RUNS];
187 void classifyFrame(
image_pixel * restrict img,
unsigned * restrict map);
188 int encodeRuns(
rle * restrict out,
unsigned * restrict map);
189 void connectComponents(
rle * restrict map,
int num);
190 int extractRegions(
region * restrict reg,
rle * restrict rmap,
int num);
191 void calcAverageColors(
region * restrict reg,
int num_reg,
193 rle * restrict rmap,
int num_runs);
194 int separateRegions(
region * restrict reg,
int num);
195 region *sortRegionListByArea(
region * restrict list,
int passes);
196 void sortRegions(
int max_area);
199 int mergeRegions(
region *p,
int num,
double density_thresh);
208 bool initialize(
int nwidth,
int nheight);
209 bool loadOptions(
char *filename);
210 bool saveOptions(
char *filename);
211 bool enable(
unsigned opt);
212 bool disable(
unsigned opt);
216 bool getThreshold(
int color,
217 int &y_low,
int &y_high,
218 int &u_low,
int &u_high,
219 int &v_low,
int &v_high);
220 bool setThreshold(
int color,
221 int y_low,
int y_high,
222 int u_low,
int u_high,
223 int v_low,
int v_high);
228 char *getColorName(
int color)
229 {
return(colors[color].name);}
230 rgb getColorVisual(
int color)
231 {
return(colors[color].color);}
233 color_info *getColorInfo(
int color)
234 {
return(&colors[color]);}
235 void getColorInfo(
int color,color_info &info)
236 {info = colors[color];}
237 void setColorInfo(
int color,color_info &info)
238 {colors[color] = info;}
241 bool processFrame(
unsigned *map);
242 int numRegions(
int color_id);
243 region *getRegions(
int color_id);
244 void set_cmv_min_area(
int area) { cmv_min_area = area; }
245 void set_cmv_max_area(
int area) { cmv_max_area = area; }
T min(T a, T b)
Return the minimum of a, b.
Definition: utility.h:113
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
Definition: cmvision.h:93
int AddInterface(player_devaddr_t addr)
Add an interface.
Generic message header.
Definition: player.h:162
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
Definition: cmvision.h:105
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
Definition: cmvision.h:161
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:75
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
Definition: cmvision.h:143
Definition: cmvision.h:122
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
virtual void Main(void)=0
Main method for driver thread.
Definition: cmvision.h:137
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
static bool MatchDeviceAddress(player_devaddr_t addr1, player_devaddr_t addr2)
Compare two addresses.
Definition: device.h:201
Definition: cmvision.h:157
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
Definition: cmvision.h:85
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:125
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
#define PLAYER_MSG6(level, msg, a, b, c, d, e, f)
Error message macros.
Definition: error.h:111
Class for loading configuration file information.
Definition: configfile.h:197
virtual int Setup()
Initialize the driver.
Definition: driver.h:386
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
void SetError(int code)
Set/reset error code.
Definition: driver.h:145
#define PLAYER_ERROR1(msg, a)
Error message macros.
Definition: error.h:82
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
Definition: cmvision.h:120
double timestamp
Time associated with message contents (seconds since epoch)
Definition: player.h:170
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:393
Base class for all drivers.
Definition: driver.h:109
Definition: cmvision.h:89
Definition: cmvision.h:153
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
T max(T a, T b)
Return the maximum of a, b.
Definition: utility.h:126