0

I have objects that appear as white halos in a binary threshold matrix. I made this code to fill the halos white so I can have solid white circles in the matrix:

void processBinary(Mat& binaryMat) {
  Mat clone;
  binaryMat.copyTo(clone);
  vector<vector<Point>> contours;
  findContours(clone, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

  if (!contours.empty()) {
      drawContours(binaryMat, contours, 0, Scalar(255), CV_FILLED);
  }
}

This works if I only have one object in the camera feed. However, with multiple of the same objects, it won't perform the filling on any object unless I remove all but one of the objects from the scene. How can I fix the code so that each object is filled to be a solid white circle?

Sumeet Batra
  • 357
  • 1
  • 4
  • 14

1 Answers1

-1

Does the drawContours method loop through all contours ? Controls are basically given as linked list tyhat has to be looped to get them all by calling while(contours!=null) .... contours = contours.VNext;//Or HNext for depending on your code.

MoustafaS
  • 1,991
  • 11
  • 20