最佳答案
- 阈值
- 找到轮廓
- approxPolyDP
#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)
关于opencv - 如何找到形状边界的直线近似值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47936718/