Ask Your Question

Opencv for object tracking, form and color detection

asked 2013-03-21 08:33:22 -0500

SummerTime gravatar image

Hello Opencv fans ! I'm a newbie at this and I've just succeeded in installing and compiling my very first program (yeay ^_^ ). My project is to use opencv for computer vision in a robot with a simple webcam. The robot has to collect blue balls scattered throughout the field so I have to master form and color recognition as well as moving object tracking. I'm asking for tutorials, tips, advice, anything that would help me in my endeavor. Thank you guys, and I'm waiting for your replies :)

edit retag flag offensive close merge delete


It actually depends all on the type of input images, could you pass us an example before we suggest approaches in order to solve this question more specific?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-21 16:39:31 -0500 )edit

I would like to be able to capture frames from my webcam and then tresholding them into blach and white where the white spot would correspond to the blue ball and black to everything else. Then I would like to determine the blue ball's real time coordinates and track its movement. I would like also to be able to recognize a blue ball from a blue cube for example so I need to detect forms as well. To put it simply my main objective is to track several blue ball-like objects and follow them.

SummerTime gravatar imageSummerTime ( 2013-03-21 19:00:57 -0500 )edit

I did got that, but it depends on the environment of where you want to track blue balls. There is a huge difference in tracking a ball on a playfield with tons of children, compared to tracking a blue ball in a white room :) So just grab a single picture of your situation and post it here?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-22 04:04:58 -0500 )edit

Sorry I didn't understand before. I can't post picture right now because appearently I have to wait Two days so here's a link of the field where the contest is happening : I'd like to be able to track the balls and recognize the red zone from the green one. For obstacle avoidance I'm gonna go with Sensors (IR or US). Thank you again.

SummerTime gravatar imageSummerTime ( 2013-03-22 07:12:03 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-22 07:23:47 -0500

Ok looking at the input image you gave me, I would suggest the following approach for detecting the objects.

  1. Take the blue channel from your RGB image
  2. Normalize the blue colour channel for the other colours
  3. Look for local maxima (using some threshold region) in that image, it will be points with high blue components
  4. Create a binary mask for those maxima found
  5. Assign contours to those regions
  6. Calculate center points for those regions
  7. Use the blobs or the center points to actually track the ball

Some guides that could be usefull

edit flag offensive delete link more



Okay. Thank you very much !

SummerTime gravatar imageSummerTime ( 2013-03-22 10:51:41 -0500 )edit

Is it possible to use the HSV/HSL format instead of RGB ?

SummerTime gravatar imageSummerTime ( 2013-03-22 15:09:24 -0500 )edit

Probably not since most of the algorithms in OpenCV are based on graylevel 8 bit images for faster processing. You will have to work around it, or adapt the algorithm to let it use HSV images. What you can do is converting HSV channels towards grayscale variant by some conversion formulas.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-22 15:27:33 -0500 )edit

Hi again ! How can I compute the distance from the webcam to each of the blue balls or the coordinates of every blue ball seperately using CvBlob ? Thank you

SummerTime gravatar imageSummerTime ( 2013-03-25 13:54:37 -0500 )edit

Thats a totally different question. Create new one for more information, but basically, look deeper into stereo vision to define distance towards objects from 2D recordings.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-25 14:00:15 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-03-21 08:33:22 -0500

Seen: 2,685 times

Last updated: Mar 22 '13