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

后端 未结 5 2172
一个人的身影
一个人的身影 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:21

    For me this worked. But I'm not sure why.

    cv2.drawContours(mask, [cnt.astype(int)], 0, (0, 255, 0), -1)

    When you get an array of rounded floats from findContours, drawContours doesn't complain. But when I construct a similar (4,2) array of floats myself, it complains.

提交回复
热议问题