全码:OpenCV的Python的AttributeError的: '模块' 对象有没有属性 'imshow'
# import the necessary packages
from __future__ import print_function
import cv2
# load the image and convert it to grayscale
image = cv2.imread("jurassic_world.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow("preview", image)
# initialize the AKAZE descriptor, then detect keypoints and extract
# local invariant descriptors from the image
detector = cv2.AKAZE_create()
(kps, descs) = detector.detectAndCompute(gray, None)
print("keypoints: {}, descriptors: {}".format(len(kps), descs.shape))
# draw the keypoints and show the output image
cv2.drawKeypoints(image, kps, image, (0, 255, 0))
cv2.imshow("Output", image)
cv2.waitKey(0)
错误:
Traceback (most recent call last):
File "test_akaze.py", line 8, in <module>
cv2.imshow("preview", image)
AttributeError: 'module' object has no attribute 'imshow'
所以我试图研究一个答案。有在这个网站的类似问题,但我试着做他们说什么,它并没有帮助:这是我做的
- 跑了作为须藤
- (0)都imshow后添加cv2.waitKey
- 将其改为cv2.waitKey(0)& 0xFF的(我不知道这是怎么一回事,但我读的地方,你需要做的是为64位的机器,其矿)
- 我已经注释掉imshow ,其他一切正常。我得到了预期的结果。但imshow似乎没有安装或什么东西:/
我很抱歉我是这样一个白痴。而我正在刺向黑暗。我感谢任何帮助。
尝试将opencv库复制到/ usr/include,然后再试一次 –
看看您是否已经为某个重要模块命名了一个文件。 – user2357112
@JeruLuke:不要引用格式堆栈跟踪。 – user2357112