我正在尝试在 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/