OpenCV 3.1 drawContours '(-215) npoints > 0'

后端 未结 5 2171
一个人的身影
一个人的身影 2021-02-08 12:51

I\'m trying to create a mask from a contour, but am getting a C++ error.

Using OS X Yosemite, Python 2.7.10, OpenCV 3.1.0.

def create_mask(img, cnt):
            


        
5条回答
  •  遇见更好的自我
    2021-02-08 13:24

    You might have commited mistake while finding the contours. Contour is the second value returned by findContours() function as the docs say

    im2, contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
    

    So the following code will not work

    cnt = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    

    This might solve your problem.

提交回复
热议问题