def find_contours(img):
img1 = cv2.bitwise_not(img)
imgray = cv2.cvtColor(img1 ,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
img_cont = img1.copy()
cv2.drawContours(img_cont, contours, -1, (255,255,255), -1)
return img_cont
评论列表
文章目录