tracking.cpp File Reference

contains functions for tracking an object. More...

#include "fcdynamic.h"

Defines

#define ROI_PAD   35
 padding applied after the blob's bounding box is found
#define PIXEL_BOUNDARY   0xfffffffc

Functions

void set_roi_box (TrackingWindow *win, int x, int y)
 sets the ROI to be centered around point [x, y] in the image's coordinate system.
void fix_blob_bounds (TrackingWindow *win)
 a helper function that converts the blob's initial position in the image coordinate system to the ROI coordinate system.
void set_region (int e, int x, int y, int flags, void *param)
 an OpenCV mouse callback routine for the gui that sets the initial ROI locations and the initial blob bounding box.
void pad_blob_region (TrackingWindow *win)
 a helper routine to pad the tighter bounding box found by blob
int blob (TrackingWindow *win)
 produces a tight rectangular bounding box around the object
int desperate (TrackingWindow *win)
int panic (TrackingWindow *win)
int reposition (TrackingWindow *ref, TrackingWindow *cur)
int position (TrackingWindow *cur)
 update the current TrackingWindow ROI for the next time it is active in the ROI sequence.


Detailed Description

contains functions for tracking an object.

in the documentation that follows keep in mind that in the TrackingWindow the ROI position parameters are with respect to the image reference frame (e.g. 0 <= x <= win->img_w) and the object parameters are relative to the ROI reference frame (e.g. 0 <= x <= win->roi_w). Also, object and blob are used interchangeably to mean the same thing, the entity being tracked by the vision system.

also, instead of returning error values many functions use assertions to ensure certain cases never happen. If an assertion does trigger true, then there is probably a bug somewhere in the code; the functions prior to the function where the assertion failed were suppose to make sure that the assertion never occurred. The idea behind the assertion was to remove them after sufficient debugging was done. The assertions are still in the code, because they did not impact the speed of the system when timing tests were analyzed. They provide a small reassurance that there are no severe bugs in the function.


Function Documentation

int blob ( TrackingWindow win  ) 

produces a tight rectangular bounding box around the object

blob finds an object in a given image as defined by the ROI and pixels in win->img. This current implementation is a simple bounding box algorithm that assumes the image has been binarized before it attempts to find a blob.

Parameters:
win the TrackingWindow to update the location of the object based on the image data and the ROI
Returns:
if an object is found then OBJECT_FOUND, else !OBJECT_FOUND

void fix_blob_bounds ( TrackingWindow win  ) 

a helper function that converts the blob's initial position in the image coordinate system to the ROI coordinate system.

Parameters:
win the TrackingWindow's ROI to fix.
fix_blob_bounds maps the blob's initial position to the ROI reference frame and it also fixes the bounds if the resulting points are outside the ROI window.

void pad_blob_region ( TrackingWindow win  ) 

a helper routine to pad the tighter bounding box found by blob

Parameters:
win the TrackingWindow's blob parameters to pad.
Note:
the padding can be changed by modifying ROI_PAD.

int position ( TrackingWindow cur  ) 

update the current TrackingWindow ROI for the next time it is active in the ROI sequence.

position searches for the blob in an image and updates the TrackingWindow with the new blob and ROI positions for the next time the TrackingWindow is active.

Parameters:
cur the current TrackingWindow to update with new position information
Returns:
if an object is found then OBJECT_FOUND, else !OBJECT_FOUND
Note:
the current underlying algorithm calls blob to find the object and then calls set_roi_box to center the ROI around the center of the blob's bounding box. Careful modification of these two functions may improve the tracking capabilities of the vision system with more complex algorithms that still meet the desired timing constraints.

void set_region ( int  e,
int  x,
int  y,
int  flags,
void *  param 
)

an OpenCV mouse callback routine for the gui that sets the initial ROI locations and the initial blob bounding box.

set_region is used in the initialization of the system. The blob is in an unknown location and with the assistance of this function, the GUI shown (like in display_run.cpp) assists the user in setting the initial position of the object. Currently, dragging the left mouse button set the blob's parameters and pressing the right mouse button causes the ROI to be centered around that click. The function's prototype is specified in the OpenCV documentation. Go there for more details about callbacks in OpenCV

Parameters:
e the mouse event
x the x coordinate of the click in the GUI reference frame (e.g. the image reference frame).
y the y coordinate of the click
flags special keyboard modifier keys
param an optional parameter to pass into the routine. It is used to pass the current TrackingWindow.
Note:
there is an error between where the mouse is clicked in the GUI and the values reporting the position of the mouse click when this function is called. The visual feedback will be off and will require manual correction from the user by compensating with their mouse clicks.

void set_roi_box ( TrackingWindow win,
int  x,
int  y 
)

sets the ROI to be centered around point [x, y] in the image's coordinate system.

set_roi_box centers a TrackingWindow ROI around [x, y] and updates the ROI in the system. It is still required to call write_roi in order for the frame grabber to receive the updated values.

Parameters:
win the TrackingWindow containing the ROI to update
x the x value to center the ROI around (0 <= x <= win->img_w)
y the y value to center the ROI around (0 <= y <= win->img_h)
Note:
set_roi_box will center around [x, y] such that the roi_x and roi_w are multiples of 4 and roi_w is greater than 8. The former is a documented limitation in the Silicon Software API and the latter has been determined through observation. If win->roi_w <= 8, then the camera hangs and does not send back any more images. It has not been tested to see if this bug is only isolated to the one desktop this code was developed on.

it is important to reiterate that the updated ROI returned by this functions is NOT written to the frame grabber. A call to write_roi is still required.


Generated on Thu Jan 29 21:50:49 2009 for High Speed Vision System by  doxygen 1.5.8