Ask Your Question

Revision history [back]

Some steps to follow

  • Start by converting your image to a color space that can be better segmented for visible colors, like HSV color space.
  • Then define threshold values for your specific colors on the H S and V color channels seperately.
  • For each color create a binary thresholded mask based on the threshold values previously defined.
  • On each mask you can apply findContours (even remove some noise with a gaussian blur if you need that) and detect all the available blobs/objects.
  • Now count the number of objects and assign an index to each blob.
  • In order to be sure that an index sticks to blob, apply a Kalman filter tracking and use a distance measure to connect blobs between frames.