multiple random object tracking
Hi all! Long text and my bad english ahead, be ready :)
Right now i'm trying to implement optical color sorting for random moving particles. Not so random - it's just plastic granules and flakes, but they still could have pretty random shape. Overall goal is to decide is each particle color is within range of "good" colors.
Current implementation is following:
Get the image of patricles on neutral background
Perform Canny filter to get contours
Perform Scharr filter to get more accurate contours
Do findContours();
- Create boundingRect around each contour and check bbox area, so we do not analyze color of trash
Create mask of remaining contours filled with white
Use each boundingRect as ROI, apply mask to image inside ROI so we get particle only inside ROI
- Calculate average color inside each ROI and decide is it good or bad color
On a static synthetic image everything works very good, but on a real webcam image everything is bad:
- Not every contour is closed, and morphologyEx with MORPH_CLOSE not helping much and it also pretty slow
- Non closed contours arent filling with white to create mask, so the average color is not calculating right.
And the real question is: is there any way to track this particles of random shape? The particles are moving, and if we process them in described way, every new frame they treated as NEW set of particles, even when nothing moved, so at bad circumstances algorithm could decide that color is out of "good" color bounds, even if it is not so.
As far as i know recongnition of object working good only when training with good and bad samples of shape was performed, but there is no way to train it on a random shape
And Kalman filter for prediction of position needs a point. I can find a center of a particle by using contours' moments. But found center is OK only when found contour is a real contour of particle, which is not always true.
What do i do? Am i missing something?
Any help is appreciated.
see https://github.com/Smorodov/Multitarg...
sturkmen, thanks for hint! i didnt'managed to get SuBSENSE working because of some opencv3 related troubles ("error: 'AlgorithmInfo' in namespace 'cv' does not name a type|" but doing blur, then Canny, then morphologyEx on canny output with MORPH_CLOSE and findContours on this made good job on extraction and subtraction a real particle contours which include a whole particle.