multiple random object tracking

asked 2018-09-13 07:01:37 -0500

ub0baa gravatar image

updated 2018-09-13 07:08:16 -0500

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:

  1. Get the image of patricles on neutral background image description

  2. Perform Canny filter to get contours

  3. Perform Scharr filter to get more accurate contours image description

  4. Do findContours();

  5. Create boundingRect around each contour and check bbox area, so we do not analyze color of trash
  6. Create mask of remaining contours filled with white image description

  7. Use each boundingRect as ROI, apply mask to image inside ROI so we get particle only inside ROI

  8. Calculate average color inside each ROI and decide is it good or bad color

image description

On a static synthetic image everything works very good, but on a real webcam image everything is bad:

  1. Not every contour is closed, and morphologyEx with MORPH_CLOSE not helping much and it also pretty slow
  2. 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.

edit retag flag offensive close merge delete


sturkmen gravatar imagesturkmen ( 2018-09-13 10:04:10 -0500 )edit

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.

ub0baa gravatar imageub0baa ( 2018-09-14 07:35:41 -0500 )edit