Take the 2-minute tour ×

Im using opencv 2.0 with cvblob.h in VS2010 and I made a program that detects yellow blobs. Now what I want to do is to number those blobs, no matter if they move. I know that the label property is useful for number them, but I've tried it and when one blob is moved, the labels change. How can I hold the "initial" label numbers?

share|improve this question
I solved it. As you said I implemented a simple multiple object tracking system base on the area of the blobs, which only move on two dimensions so their areas don't change. –  Tapia Apr 16 '12 at 21:14

2 Answers 2

up vote 1 down vote accepted

What you want is to track blobs. Tracking blobs means that you keep track of blobs from frame to frame. This way, you will have a number that identified moving objects (blobs over time).

To do that you must code your own tracking algorithm (based on your specific problem) or use the tracking functions that comes with cvBlob, which are far from perfect but useful for testing purpose.

You have code samples in cvBlob package. In particular:

http://cvblob.googlecode.com/svn/trunk/samples/red_object_tracking.cpp http://cvblob.googlecode.com/svn/trunk/test/test_tracking.cpp

share|improve this answer

By saying that you want the blobs to hold on to their initial labels, you are essentially trying to track them. That would amount to implement a multiple object tracking system. Believe me it's not as simple as you think.

You need to establish some sort of correspondance between the frames.

In case the blobs does not vary too much between the frames you can try finding geometrical centers of each blob in one frame and in the susequent frame you can try finding a blob nearest to a center found in previous frame. Then assign the previous label to the new blobs. And so on so forth...

share|improve this answer
Yes, I have a code where I track 2 blobs (knowing their position), but when I swap their position on camera, their labels change. Is there any way to "keep" the label of each blob? –  Tapia Mar 5 '12 at 21:33
the labeling done by the library function is on the basis of which blob it detects first. If you are expecting the label not to change it means you are expecting the blob detection algorithm to track your blobs as well. Which will not happen –  bubble Mar 6 '12 at 2:41

Your Answer


