Vision Assignment – Locating an Object

Plug the camera into your CBC, and point it straight forward

(you may have to add structure to hold camera in position)

  • First, setup the camera parameter for the experiment lighting conditions: find and select “auto exposure” under Vision/Camera Parameters, and then set the exposure back to manual by clicking on the select icon again. (see Vision functions: Use Example)
  • Then train the camera so that it recognizes a red or pink colored object for color channel ‘0’ (for a camera with the Link controller follow the calibrate directions under Link Camera )
  • Use the following program to display the location in the camera view for a red object: (note changes for the Link code in comments)
int main() {
   int x, y, color=0; // set up for color channel 0 (red, or orange)
  // add 'camera_open(LOW_RES);' for Link code with the same resolution
   cbc_display_clear(); //display_clear() w. Link code
   while (black_button() == 0) //run till button is pressed (ref. to side button on Link)
   track_update(); // process the most recent image; use 'camera_update()' w. Link code
   if (track_count(color) > 0) // use 'get_object_count(color)' w. Link code
      { // get x, y for the biggest blob in the channel field-of-view
      x = track_x(color,0); y = track_y(color,0); /* for Link code:
           x=get_object_centroid(color,0).x; y=get_object_centroid(color,0).y; */
      printf("Biggest blob at (%d ,%d )\n",x,y);
   else { printf("No color match in Frame\n"); }
   msleep(200); // give print time to display
 printf("Program is done\n");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s