Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV C++ contours - keeping results contiguous over frames

Hello,

I have a real time application in OpenCV where I need to take a current video frame, and analyse it for contours then work with the centroids of those contours. So far the basics are all good and working.

The issue I foresee is that my input frames are 'noisy' to the extent that I may see different amounts of centroids for each frame, it's how to deal with this that is my interest.

The objects that I'm interested in give positive hits in every frame so for instance if I'm expecting 14, then I'll get at least 14 for every frame. I'm also a-priori aware of the spatial relationships between the objects in frame (for instance, they'll never cross, there is symmetry and for instance among other rules the top-left one is exactly that: top-left - always) so I can trust that whatever order in which the openCV findContours function finds them will remain constant (for instance it might turn out the third contour found is always the top-left one).

It's the false positives that are the issue, in that they freak with the ordering such that the 'logic' I just outlined falls apart, unkindly. False-positives can appear anywhere, I could end up with 15 centroids and as such '3' might now be the false positive, and '4' is top left, and so on.

Question: It looks like just a one-hit function - clear your vector and start again kind of thing - but does OpenCV have a way around this built in?

If I have to roll my own - what are they usual tactics?

As the objects in frame are contiguous 'within a bound' between successive frames I can play with that I guess - and that, combined with the aforementioned known spatial relationships (again, 'within a bound') - I could be cooking with gas :)

Thing is, I'm up against a wall of a very short period to play with in terms of loop execution time - if I can rely on already solved problems with optimal algorithmic complexity vs. my own kludge I'm all for it.

Any ideas? (did I even make sense?)

OpenCV C++ contours - keeping results contiguous over frames

Hello,

I have a real time application in OpenCV where I need to take a current video frame, and analyse it for contours then work with the centroids of those contours. So far the basics are all good and working.

The issue I foresee is that my input frames are 'noisy' to the extent that I may see different amounts of centroids for each frame, it's how to deal with this that is my interest.

The objects that I'm interested in give positive hits in every frame so for instance if I'm expecting 14, then I'll get at least 14 for every frame. I'm also a-priori aware of the spatial relationships between the objects in frame (for instance, they'll never cross, there is symmetry and for instance among other rules the top-left one is exactly that: top-left - always) so I can trust that whatever order in which the openCV findContours function finds them will remain constant (for instance it might turn out the third contour found is always the top-left one).

It's the false positives that are the issue, in that they freak with the ordering such that the 'logic' I just outlined falls apart, unkindly. False-positives can appear anywhere, I could end up with 15 centroids and as such '3' might now be the false positive, and '4' is top left, and so on.

Question: It looks like just a one-hit function - clear your vector and start again kind of thing - but does OpenCV have a way around this built in?

If I have to roll my own - what are they usual tactics?

As the objects in frame are contiguous 'within a bound' between successive frames I can play with that I guess - and that, combined with the aforementioned known spatial relationships (again, 'within a bound') - I could be cooking with gas :)

Thing :) - thing is, I'd be doing this between every frame...

I'm up against a wall of a very short period to play with in terms of loop execution time - if I can rely on already solved problems with optimal algorithmic complexity vs. my own kludge I'm all for it.

Any ideas? Anyone got anything to teach me? (did I even make sense?)