【问题标题】:How does OpenCV function cv2.fillpoly() workOpenCV 函数 cv2.fillpoly() 是如何工作的
【发布时间】:2018-05-16 17:00:06
【问题描述】:

谁能解释一下fill poly在opencv2 python中是如何工作的?我找不到太多正在运行的示例来尝试。

我的尝试给了我例外

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)

【问题讨论】:

    标签: python-2.7 opencv


    【解决方案1】:

    错误意味着它需要一个 32 位整数。

    修改代码如下:

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

    【讨论】:

    • 是的,我也想通了。谢谢@JeruLuke
    猜你喜欢
    • 2017-07-16
    • 2018-01-08
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-28
    • 2020-12-31
    相关资源
    最近更新 更多