我正在尝试使用 python 接口绘制一个多边形到 opencv,cv2。我创建了一个空图像,只是一个 640x480 numpy 数组。我有一个要在图像上绘制的多边形(四点四边形)的列表,但是,我似乎无法获得甲酸盐来指示 cv2 四边形应该在哪里,并且我不断收到此错误:
OpenCV Error: Assertion failed (points.checkVector(2, CV_32S) >= 0) in fillConvexPoly, file .../OpenCV-2.4.0/modules/core/src/drawing.cpp, line 2017
我的代码基本上包括以下内容:
binary_image = np.zeros(image.shape,dtype='int8')
for rect in expected:
print(np.array(rect['boundary']))
cv2.fillConvexPoly(binary_image, np.array(rect['boundary']), 255)
fig = pyplot.figure(figsize=(16, 14))
ax = fig.add_subplot(111)
ax.imshow(binary_image)
pyplot.show()
我在预期中的矩形列表具有包含(x,y)点列表值的“边界”。代码打印:
[[ 91 233]
[419 227]
[410 324]
[ 94 349]]
我认为这是多边形的点列表,但显然该列表有一个 invalid points.checkvector
,不管是什么。谷歌搜索该错误没有任何用处。