opencv轮廓检测——绘制物体的凸包
1、绘制轮廓:import cv2img = cv2.坡纠课柩imread('0.png')img0=cv2.c即枢潋雳vtColor(255-img,cv2.COLOR_BGR2GRAY)_, t = cv2.threshold(img0, 0, 255, cv2.THRESH_BINARY)_, c, _ = cv2.findContours(t, 3, 2)for cnt in c: cv2.drawContours(img,c,-1,(255,0,0),2)cv2.imwrite('00.png',img)255-img是为了取反色图片。

3、第二个物体的凸包是:hull = cv2.convexHull(c[1])

5、用for循环,来画出所有物体的凸包:for cnt in c: hull = cv2.convexHull(cnt) cv2.polylines(img,[hull],True,(500,255,0),2)

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:26
阅读量:48
阅读量:34
阅读量:85
阅读量:43