I got an image of the borders through the cvCanny detector. How now as quickly as possible to find the closed contours and coordinates in it incoming?

    1 answer 1

    The feature of the cvCanny interface in openCV is that this function simply converts the original image into an image with marked outlines of objects. But it is important here that after this conversion, the output is still an image.

    In order to get any representation of, strictly speaking, contours, you need to use a function of type findContours , which returns a sequence of elements of type cvSeq . Then everything is trivial - every object of type cvSeq has a flag indicating whether the contour is closed or not - CV_SEQ_FLAG_CLOSED . Obtaining coordinates, having a link to such an object, is also quite obvious.


    I note that in the openCV adaptation for python , some wrappers are probably made for the cvSeq class, so solving the problem should be even easier.

    If we reflect on the topic of performance, then it is ready to assume that the findContours function findContours reasonably well optimized and it is unlikely that there will be much speeding up.

    Of course, you know in advance that the resulting contours should be closed and based on this you can probably do some optimization of the findContours -> findClosedContours , but, frankly, I very much doubt that this will be really necessary.