Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you should try to find the largest contour:

(simply going for len() here, but cv2.contourArea() would also be a good option)

largest=-1
nc = 0
for i, c in enumerate(contours):
   print i, len(c)
   if len(c)>nc:
      nc = len(c)
      largest = i

print ("number of countours detected before filtering %d -> "%len(contours))
new = np.zeros(imgray.shape)
new = cv2.drawContours(img,contours,largest,(0,0,255),3)