Python查找轮廓和绘制轮廓函数错误

2024-04-20 12:05:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在从事一个项目,检测图像上的缺陷。 image after I apply threshold function

轮廓没有连接…我不知道为什么它们是离散点

contours

这是我的密码:

   ret, thresh1 = cv2.threshold(img, 95, 255, cv2.THRESH_BINARY)
   cnts= cv2.findContours(thresh1,cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)[-2]
   cv2.drawContours(img, cnts, -1, (255,255,0), 3)

另外len(cnts)函数没有返回正确的白点数


Tags: 项目图像密码imgthresholdcv2list轮廓