gpt4 book ai didi

python-2.7 - OpenCV函数cv2.fillpoly()如何工作

转载 作者:行者123 更新时间:2023-12-02 17:08:06 27 4
gpt4 key购买 nike

有人可以解释一下填充多边形如何在opencv2 python中工作吗?我找不到很多正在运行的示例进行尝试。
我尝试的给我异常(exception)

OpenCV Error: Assertion failed (p.checkVector(2, CV_32S) >= 0) in fillPoly, file /builddir/
build/BUILD/opencv-2.4.5/modules/core/src/drawing.cpp, line 2037
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: /builddir/build/BUILD/opencv-2.4.5/modules/core/src/drawing.cpp:2037: error:
(-215) p.checkVector(2, CV_32S) >= 0 in function fillPoly.
这是我的简单代码:
mask=np.zeros((4, 3))
cv2.fillPoly(mask, [(1,1),(1,2), (2,1), (2,2)], 255)

最佳答案

该错误表示它需要一个32位整数。

将代码修改为以下内容:

mask = np.zeros((4, 3))
cv2.fillConvexPoly(mask, np.array([(1,1),(1,2), (2,1), (2,2)], 'int32'), 255)

关于python-2.7 - OpenCV函数cv2.fillpoly()如何工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50376393/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com