I'm using the camshiftdemo.c
program that comes bundled with OpenCV 2.3.1:
https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/camshiftdemo.c?rev=1429
I was wondering how I can use this program to instruct a robot to follow an object of choice? I'm trying to run an experiment to see if it will work, but I obviously need to tweak it a little bit.
The way camshiftdemo works is it draws a red ellipse around the object you chose (by clicking on it with your mouse). As the object moves so does the red ellipse. If the object moves further away the ellipse decreases in size and increases if it comes closer to the camera.
To instruct a robot I was thinking I tell it to move forward if the size of the red eclipse decreases, and move backward if it increases. The robot will move left if the eclipse moves to the left and moves right if the eclipse moves right.
Sounds simple enough, but where in this code is the eclipse being drawn? And what if the object moves back and forth in 10 seconds? Does this mean the robot stays in the same place (i.e. should I introduce a delay in the robots movements?)?
My goal is to get the camshiftdemo.c
code to instruct the robot to move {forward,backward, turn left, turn right}.
So how can I get the robot to follow an object, either by using the size of the eclipse or otherwise?