2

How to find the contour that is nearest to the center of image?

For example in the image below, I have used cv::findContours() to find two contours of an image(please ignore the 5pixel part as I have used this image in another SO post), is it possible to locate the contour index of the red contour which is nearest to the center of image?

Imgur

I currently used cv::pointPolygonTest and loop the contours with the coordinate of the center of image to find the distance between every contours and center, it feel inefficient, is there any opencv function I can use?

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Komgcn
  • 323
  • 2
  • 12

0 Answers0