Opencv 3 with Python3 getting this error: (-215) npoints > 0 in function drawContours

微笑、不失礼 提交于 2019-12-12 06:24:42

问题


Trying to draw in contours from a list. Here's my code. It fails on the cv2.drawContours function. Is there a way to use the connectedComponentsWithStats function to somehow find all the contours and then draw black pixels over them the way I am trying to because when I use the connectedComponentsWithStats function, it selects the contours I want it to.

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
labelNum, labelImg, contours, GoCs = cv2.connectedComponentsWithStats(gray)  
for c in contours:
    x,y,w,h,size = c
    if size <= 100:
        cv2.drawContours(mask, [c], -1, 0, -1)

来源:https://stackoverflow.com/questions/44087581/opencv-3-with-python3-getting-this-error-215-npoints-0-in-function-drawcon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!