AttributeError:“模块"对象没有属性 [英] AttributeError: 'module' object has no attribute
本文介绍了AttributeError:“模块"对象没有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am trying to get the depth map of two stereo images. I have taken the code from this documentation.
我收到以下错误:
Traceback (most recent call last):
File "depth.py", line 9, in <module>
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
AttributeError: 'module' object has no attribute 'createStereoBM'
我的代码是:
import numpy as np
import cv2
from matplotlib import pyplot as plt
imgL = cv2.imread('tsukuba_l.png',0)
imgR = cv2.imread('tsukuba_r.png',0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL,imgR)
plt.imshow(disparity,'gray')
plt.show()
我进入了Python行解释器,并编写了以下代码:
I entered the Python line interpreter, and wrote the following code:
import cv2
help(cv2)
在cv2
中没有名为createStereoBM
的函数.
There is no function called createStereoBM
in cv2
.
顶部提供的链接中的代码是否错误?我在Ubuntu 12.04中使用Python 2.7.3. 该代码是否可能适用于Python 3及更高版本?
Is the code wrong in the link provided at the top? I am using Python 2.7.3 in Ubuntu 12.04. Is it possible that the code is meant for Python 3 and above?
请帮助.
推荐答案
请改用此功能
stereo = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16, SADWindowSize=15)
您可以在此处找到相关文档
这篇关于AttributeError:“模块"对象没有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文