0

I want to group a different number of contours found with opencv to a set:

Contours

Sets of contours

I also want to keep track of the indexes for every contour in every set, e.g. in Set 1 you can find contour 10,11,12,13,14. My contours are stored in a vector<vector<Point>>.
I already tried the function cv::approxPolyDP but the polygon will be drawn around all contours.
I know I can calculate the distance between every single contour pair but how can I use the distance to group them to a new contour?

Grillteller
  • 891
  • 10
  • 26
  • 1
    Check [this](https://stackoverflow.com/a/33834092/5008845), it's basically the same thing – Miki Aug 09 '17 at 09:59
  • Wow, that worked instantly like a charm even with the unchanged radius tolerance of 18. Thank you! But it takes some time for computing (I guess because the distance is calculated between every point of the contours). Do you think this will work if I calculate the centroids of the contours first and use these centroid points in partition? – Grillteller Aug 09 '17 at 11:10
  • Yes, you _should_ work on contours (not single points as I did), and compute their distance using centroids – Miki Aug 09 '17 at 11:57
  • Is it possible to fetch the radius tolerance somehow automatically? – Grillteller Aug 09 '17 at 12:26

0 Answers0