PDA

View Full Version : [Just For Fun] Vision Color Tracking Robot



djsures
11-27-2010, 08:41 PM
This is a test robot I created to trial a new module that I have been working on. It tracks and follows objects by their color.

The module has the ability to look up and down also, but this hardware platform that I created doesn't have a vertical head servo.

My next robot will look up, down, left and right. But I'm waiting on some parts that I ordered before I can build it.


http://www.youtube.com/watch?v=FUE3xKwmzyU

http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261614.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261615.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261617.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261618.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261621.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261623.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261630.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261631.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB261632.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271613.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271614.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271615.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271633.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271636.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271638.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271641.JPG
http://www.dj-sures.com/GraphicFiles/2010-11-27 Calgary Ez-b Vision Tracking Robot/Resized_PB271645.JPG

djsures
11-28-2010, 09:41 PM
Awesome, what tracking software are you using?

thanx dude! it's my own software. i wrote it yesterday before i made the video. it's a function that is very modular. tell it a color and it returns the location of the object.

Stobs
12-01-2010, 08:42 PM
Very nicely done DJ - way cool! Question though? Does the software require two cameras? If not I don't understand why there's two cameras installed, since they're both fixed, and as far as I can tell the data printed to the screen isn't paired (i.e., one line of data for one camera followed by a second line of data for the other camera. Some capability you're ramping up to, or have I missed something?

Paul

BTW, +rep

djsures
12-01-2010, 10:31 PM
only one camera. one image is the raw camera data, the second is my processed data.

this is the c# code that calls my color vision detection code..

first you have to create a instant of the ezconnector..

EZCommunicator _ezb = new EZCommunicator();

then you get a list of video capture devices on the machine. put them in a combo box so the user can choose...

foreach (DirectX.Capture.VideoCaptureDevice videoCaptureDevice in _ezb.Camera.GetVideoCaptureDeviceList())
comboBox1.Items.Add(videoCaptureDevice.Name);


within a connect button, have it connect to the EZB board and initiate a camera with selected video capture device. also, the two optional parameters are controls that you want to display the camera image. technically, it can be any type of windows control. i use panel control. I also start a timer that will look for the object and move the head...

_ezb.AutoConnect();
string videoCaptureDeviceName = comboBox1.SelectedItem.ToString();

_ezb.Camera.InitCamera(panel1, _ezb.Camera.GetVideoCaptureDevicebyName(videoCaptu reDeviceName), panel2);

timer1.Interval = 100;
timer1.Enabled = true;


then in the timer elapsed tick, i do this...

ObjectLocation objectLocation = _ezb.Camera.GetObjectLocation(Camera.ColorEnum.Blu e, Camera.SearchObjectSize.Med, 100);

objectLocation now has a few parameters, the most important in the video example is the horizontal position. i get the head's horizontal servo last position, then based on the object location i either move the servo left or right... that puts the object in the center..

if (!objectLocation.isFound)
return;

if (_ezb.IsConnected) {

int position = _ezb.Servo.GetServoPosition(Servo.ServoPortEnum.RB 3);

if (objectLocation.horizontalLocation == ObjectLocation.HorizontalLocationEnum.Left)
position++;
else if (objectLocation.horizontalLocation == ObjectLocation.HorizontalLocationEnum.Right)
position--;

_ezb.Servo.SetServoPosition(Servo.ServoPortEnum.RB 3, position);
}


VOILA!

Stobs
12-01-2010, 11:10 PM
Sorry about that! :P I've got to get more sleep. Thanks for correction and additional info DJ, much appreciated.

Paul

djsures
12-03-2010, 09:08 AM
Sorry about that! :P I've got to get more sleep. Thanks for correction and additional info DJ, much appreciated.

Paul

anytime paul! :)