Opencv findCountours is not find all contours
I'm trying to find the contours of this image, but the method findContours only returns 1 contour, the contour is highlighted in image 2. I'm trying to find all external contours like these circles where the numbers are inside. What am i doing wrong? What can i do to accomplish it?
image 1
image 2
Below is the relevant portion of my code.
thresh = cv2.threshold(image, 0, 255,
cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
you will find the answer in the documentation
@sturkmen i tried the other options like "RETR_LIST" but it seems to find the same border twice. I'm trying to detect these circles but when i try "RETR_LIST" or others it returns the same contour of each circle twice.
After the thresholding apply a bitwise not then apply findContours but with RETR_TREE. findContours return three outputs, the image, the contours and a hierachy matrix. The hierarchy matrix contains a relashionship of the contours. You can refine it in order to only keep the hierarchy that fit your purpose