Reputation: 85
Several threads report this problem, but all of them show fixing the type of the point list (to int32, i.e. CV_32S) as the solution. The point list below has the appropriate type.
>>> ti = np.zeros((400,400,3), np.uint8) # Test image
>>> mask = np.array([[213,60],[333,240],[93,240],[150,120]], np.int32) # Test point list
>>> cv2.polylines(ti, mask, True, (255,0,0), 1)
*** cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2437: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'cv::polylines'
>>> print(mask.dtype, mask.shape)
int32 (4, 2)
I've tried changing the type (I get a different error, complains it's the wrong type) and re-casting it to int32. Can't make it play nice...
fillConvexPoly works fine (which got me what I needed for now), fillPoly exhibits the same problem as above.
Upvotes: 0
Views: 2571
Reputation: 1783
Correction to the above is -
cv2.polylines(ti, [mask], True, (255,0,0), 1)
Upvotes: 4