Find a large circuit, even if it is not closed (OpenCV)

I have such an image with contours enter image description here

And when I iterate over the contours like

cnts = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[1]
for c in cnts:
    peri = cv2.arcLength(c, True)
    approx = cv2.approxPolyDP(c, 0.02 * peri, True)
    ### Here I'm showing each contour on the image

I cannot get the largest outline of the whole document, I think, because it is not closed. So, is there a way to get this outline?

+4
source share

Source: https://habr.com/ru/post/1680017/


All Articles