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?
2 Answers
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

- 83
- 1
- 1
- 8
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...

- 3,408
- 5
- 29
- 51
-
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 05 '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 06 '12 at 02:41