# color blob detection and distinguishing

I use opencv to track tennis ball with android phone. I used template that comes with opencv for android called color blob detection. By selecting color of the ball I track blob. My question is how can i distinguish two or more blobs and track just one (when there are more tennis ball in the line of sight)? How can i detect and track just tennis balls and not all other objects that are in the same color range?

Tnx, upfront!

edit retag close merge delete

Sort by ยป oldest newest most voted

In order to be color independant, do not use color information to detect your ball. This is exactly what u doing, by thresholding by certain values, which i can deduce from your answers.

Just create a grayscale image, apply edge detection, then use the circular hough transform to detect blob/circle structures. By then giving some thresholds on the size of the actually object, which you know since its a tennisball, the segmentation should be quite obvious.

more

Your problem is to assign one of several not distinguishable measurements (detected blobs) to your initial tracked tennis ball (a blob).

In computer vision and robotics this problem is called data association problem. You can find some literature about data association here and here. This papers describe methods how multiple measurements can be assigned to multiple objects. Your case is not as difficult as those from the papers, since you only want to track one object (your initial detected ball). Since the tracker provides a strong hypotheses of the position of your ball you can use the easiest method for data association. Its called Nearest Neighbour Association. Here the nearest measurement to the position of the ball is used to update the tracker. If you have an probabilistic tracker like Kalman Filter, you know the Gaussian distribution of the position of your object and you can use the mahalanobis distance instead the euclidean distance as distance measurement method. The mahalanobis distance give you a more reliable measure, that the measurement of the blob belongs to the object.

The processing pipeline could be:

2. capture the next frame and detect the blobs
3. compute for all detected blobs the distance to the tracked object (use euclidean or mahalanobis distance) and find the measurement with the shortest distance.
4. Update the tracker with this measurement. You can use a threshold to reject measurements with a too large distance. This will avoid unreliable measurement updates.
more

Maybe you don't need to 'compute for all detected blobs the distace to the tracked object', you can just limit a region in previous location and predict the location by its path( you know the shortest may not be the best)

( 2014-04-23 04:07:56 -0500 )edit

You can use Optical flow or kalman filter for predict of the current ball path.

more

My main problem is not to track ball, i already resolved that, main difficulty is to distinguish my object from other ones that are in same color range.

( 2012-12-10 06:25:32 -0500 )edit

Possibly, you can create a binary image with blobs identified and reason on them using cvBlobsLib add-on library. This can give you the parameters of blobs such as height, width, area, position, and a whole lot more. You can use those to select the blob you are looking for.

more

( 2012-12-11 04:08:04 -0500 )edit

You can use a background subtraction technique and Particle Filters.

more