Ask Your Question
0

OpenCV C++ contours - keeping results contiguous over frames

asked 2015-02-14 07:00:45 -0600

Lamar Latrell gravatar image

updated 2015-02-14 07:11:33 -0600

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'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.

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-02-14 08:44:36 -0600

updated 2015-02-14 08:45:26 -0600

What are you tracking? (Could you show an example image?) I assume that the ordering of the contours is rather stable, but as there is no tracking you shouldn't rely on that. Your problem is a rather standard one, so that you should find many approaches. One keyword is "multi object tracking" where you have tracks of individual objects to which you need to assign new observations. Your a-priori information can probably be used to predict the position of your observations. A standard technique for assigning tracks to observation is the hungarian method. The next point would be to track your features using a kalman filter so that you can explicitly compute the likelihood that an observation belongs to a track.

So the best thing would be to see some of your images, it's then much easier to select an approach.

edit flag offensive delete link more

Comments

Thanks for your interest :) It is helmet mounted facial motion capture with markers - e.g. http://geekcity.ru/wp-content/uploads...

The markers currently are black dots and the camera is monochrome - I could use IR LEDs, retro-reflective markers and IR filter the lens for very clean data. However retroreflective markers are either poisonous around the eye (paint), or too large (adhesive balls). That is why I'm keen to just try a dark marker, but something like a nostril or otherwise might give a false positive.

I was also thinking of using the moments capability available in contours - i.e. make the markers have very specific orientations and aspect ratios, also markers within markers (bullseyes) ...

Keen to learn though

Lamar Latrell gravatar imageLamar Latrell ( 2015-02-14 17:00:08 -0600 )edit

googling at the moment - "multi object tracking" is a great search term so thanks for the heads up, very relevant and I've discovered 'data association' also :)

Lamar Latrell gravatar imageLamar Latrell ( 2015-02-14 19:39:57 -0600 )edit

Just read the wikipedia page in the Hungarian method. I grasp the basics of it, so I develop a metric (or group of metrics) using my knowledge of the situation, then the algorithm optimises the assignment according to that metric? hrrrm, coming up with an 'optimal' metric isn't exactly a trivial task ! :) EDIT: oh so the Kalman filter prediction is the metric ?

Lamar Latrell gravatar imageLamar Latrell ( 2015-02-14 20:28:30 -0600 )edit

Done this now and it's successful... Position and velocity State Kalman filter predicts position from last iteration, current measurements (with false positives included!) are then Hungarian associated, associations are then fed to the Kalman update - rinse and repeat :)

Lamar Latrell gravatar imageLamar Latrell ( 2015-03-13 05:11:33 -0600 )edit

Can you show a video of your results?

FooBar gravatar imageFooBar ( 2015-03-13 07:25:09 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-02-14 07:00:45 -0600

Seen: 1,236 times

Last updated: Feb 14 '15