Point always on contour edge
Hi,
Thank you for implementing the algorithm in python.
I'm trying to use it on contours from a binary mask. The contours are returned from cv2.findContours, and I would like to compute the visual center for every contour. However, cx, cy = polylabel(cnt.tolist()) always returns a point that is on the edge of the contour, not in the middle (the .tolist() might not be required). Would you have any hint if I'm using polylabel correctly?
Many thanks.
Hello,
Sorry for the late response.
You might try to play with precision parameter in the polylabel cal.
I have the same problem. It works fine for sample polygons, but not for masks I generate with CVs findContours function.
I solved my issue - findCountours returns a set of coordinates in the form [[[1,2]],[[3,4]],...]. Polylabel needs the list to be formatted as [[[1,2],[3,4],...]]. Hope this helps others that may stumble on this. @Twista - thanks for a great package!