Ask Your Question

color blob detection and distinguishing

asked 2012-12-07 04:29:39 -0600

van wilder gravatar image

updated 2020-11-30 03:33:47 -0600

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 flag offensive close merge delete

5 answers

Sort by ยป oldest newest most voted

answered 2012-12-11 05:08:16 -0600

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.

edit flag offensive delete link more

answered 2012-12-11 02:59:10 -0600

Siegfried gravatar image

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:

  1. after the first occurrence of your ball, initialize your tracker
  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.
edit flag offensive delete link 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)

claycau gravatar imageclaycau ( 2014-04-23 04:07:56 -0600 )edit

answered 2012-12-07 12:27:21 -0600

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

edit flag offensive delete link 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.

van wilder gravatar imagevan wilder ( 2012-12-10 06:25:32 -0600 )edit

answered 2012-12-10 15:23:27 -0600

unxnut gravatar image

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.

edit flag offensive delete link more


what about haar cascade, can i use that?

van wilder gravatar imagevan wilder ( 2012-12-11 04:08:04 -0600 )edit

answered 2012-12-10 09:26:33 -0600

imran gravatar image

You can use a background subtraction technique and Particle Filters.

edit flag offensive delete link more

Question Tools



Asked: 2012-12-07 04:29:39 -0600

Seen: 5,408 times

Last updated: Dec 11 '12