python - OpenCV - python 中的 cv2.floodFill() 错误

标签 python opencv flood-fill

我在使用 cv2.floodfill() 时遇到了这个错误:

enter image description here

我的代码:

    ormap = np.bitwise_or(label,detmap)
    mask = np.zeros((image_size+2,imagesize+2),np.uint8)
    for y in range(image_size):
        for x in range(image_size):
            if label[y,x]>0:
                cv2.floodFill(ormap,mask,(y,x),0)

我试过了

  1. ormap.copy() 到一个新数组,但它不起作用
  2. 使用了 cv2.cv.fromarray() 但它显示“不支持数组类型”。

我正在使用 OpenCV 2.4.11 和 numpy 1.11.0
还有其他建议吗?

最佳答案

通过执行以下更改解决:

ormap = np.bitwise_or(label,detmap).astype(uint8)

关于python - OpenCV - python 中的 cv2.floodFill() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37016157/

相关文章:

python - 不太确定 %s 在 Python 中的意义,求助?

python - 碎片或 Selenium : Can we get current html page after clicking a button?

python - 无法分割手写字符

c++ - opencv2调整图像大小不适用于带有用户数据的垫子

python - 如何停止在 Python 中打印 OpenCV 错误消息

Java 洪水填充问题

ios - 使用泛光填充在 UIImage 中填充颜色时出错

python - 最大化正则表达式中的子串匹配

python - 让 Django REST Framework HyperlinkedModelSerializer 识别非默认路由

Javascript 洪水填充功能仅部分工作 [扫雷]