答案 0 :(得分:1)
#findContours
contours = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)[-2]
canvas = img.copy()
## draw approx contours
for cnt in contours:
arclen = cv2.arcLength(cnt, True)
approx = cv2.approxPolyDP(cnt, arclen*0.005, True)
#drawContours
cv2.drawContours(canvas, [approx], -1, (0,0,255), 1, cv2.LINE_AA)
cv2.imwrite("result.png", canvas)