Voll Code:OpenCV Python Attribute: 'Modul' Objekt hat kein Attribut '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)
Fehler:
Traceback (most recent call last):
File "test_akaze.py", line 8, in <module>
cv2.imshow("preview", image)
AttributeError: 'module' object has no attribute 'imshow'
Also habe ich versucht, eine Antwort zu erforschen. Es gibt eine ähnliche Frage auf dieser Seite, aber ich versuchte zu tun, was sie sagten, und es half nicht: Hier ist, was ich tat
- Ran als sudo
- cv2.waitKey hinzugefügt (0), nachdem beide imshow
- verändert es cv2.waitKey (0) & 0xFF (ich habe keine Ahnung, was das alles ist, aber ich habe irgendwo gelesen, dass Sie für 64-Bit-Maschinen zu tun haben, was mein ist)
- ich habe die imshow kommentiert out Alles andere funktioniert. Ich bekomme das gewünschte Ergebnis. Aber imshow scheint wie es ist nicht installiert oder etwas:/
Es tut mir leid, ich bin so ein Idiot. Und ich stach in die Dunkelheit. Ich schätze jede Hilfe.
Versuchen Sie, die opencv-Bibliotheken nach/usr/include zu kopieren, und versuchen Sie es erneut. –
Sehen Sie, ob Sie eine Datei gleich benannt haben wie ein wichtiges Modul. – user2357112
@JeruLuke: Stapelspuren nicht im Kursformat angeben. – user2357112