Python 属性错误 : 'module' object has no attribute 'DIST_L2'

标签 python opencv image-processing image-segmentation

我正在尝试在 Python 中使用 cv2.distanceTransform() 方法。运行以下代码行时出现错误:

dist_transform = cv2.distanceTransform(opening,cv2.DIST_L2,5)

运行此代码时出现以下错误:

AttributeError: 'module' object has no attribute 'DIST_L2'

之前已经问过类似的问题,我知道当你导入“something”而你的python文件名为“something.py”时会出现这个问题。 但是,我的 python 文件名为 segment3.py。

谁能帮我解决这个问题?我正在尝试使用分水岭算法进行分割。 我在 Fedora20 上工作。 提前致谢!

最佳答案

应该改写如下:

(dist_transform, labels) = cv2.distanceTransform(opening,cv2.cv.CV_DIST_L2,5) 

关于Python 属性错误 : 'module' object has no attribute 'DIST_L2' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24029401/

相关文章:

python - 带有 text.usetex 'true' 的轴字体不使用设置字体

python - 尝试理解跨 python 模块的多处理和队列

python - PubNub:TypeError:stat:路径应该是字符串、字节、os.PathLike 或整数,而不是 NoneType

python - 为什么我在导入 AudioSegment 时出错?

c++ - dyld:找不到符号:__ZN2cv6imreadERKNSt3 在 MAC OS 10.10 上运行简单代码时

opencv - JibJab 类面部置换

java - 将 JPG 文件加载到 Swing 应用程序中

python - Tensorflow 在批量处理时混合图像和标签

image - 如何比较两个边缘图像(在 OpenCV 中)?

python - python在重叠和旋转的瓷砖中分割图像