Python 3.x 如何在Opencv3 python中删除轮廓内的轮廓

Python 3.x 如何在Opencv3 python中删除轮廓内的轮廓,python-3.x,opencv3.0,icr,Python 3.x,Opencv3.0,Icr,我正在为ICR使用以下代码行 im2,contours,hier =cv2.findContours(thresh.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) for cnt in contours: if (cv2.contourArea(cnt)>50 and cv2.contourArea(cnt)<1000): [x,y,w,h] = cv2.boundingRect(cnt) im2,等高线,hier=c

我正在为ICR使用以下代码行

im2,contours,hier =cv2.findContours(thresh.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
     if (cv2.contourArea(cnt)>50 and cv2.contourArea(cnt)<1000):
     [x,y,w,h] = cv2.boundingRect(cnt)
im2,等高线,hier=cv2.findContours(thresh.copy(),cv2.RETR\u树,cv2.CHAIN\u近似值\u简单)
对于轮廓中的cnt:

如果(cv2.contourArea(cnt)>50且cv2.contourArea(cnt)使用
cv2.RETR\u外部
使用cv2.RETR\u外部抛出索引错误