0

i am new to opencv and am trying to simply display an image, however with every cv2 function I get the same error, (AttributeError)

I have already installed pip install opencv-contrib-python witch was suggested to fix this problem but changed nothing,

import cv2
img = cv2.imread ("C:\\Users\\Astroid\\Desktop\\desktop backround pics\\560736.jpg", 1)
print(img)
cv2.imshow("560736",img)
cv2.WaitKey(2000)
cv2.DestroyAllWindows()

full error is.

Traceback (most recent call last): File "C:/Users/Astroid/.PyCharmCE2019.1/config/scratches/scratch.py", line 6, in cv2.WaitKey(20000) AttributeError: module 'cv2.cv2' has no attribute 'WaitKey'

1 Answer 1

0

Use lowercase for the method: [docs]

retval = cv.waitKey([, delay])
Sign up to request clarification or add additional context in comments.

2 Comments

thx, that worked for waitkey however i sayed that the same AttributeError was happening to all the cv2 functions, after i implemented your line of code it desplaye the image however the program ended in Traceback (most recent call last): File "C:/Users/Astroid/.PyCharmCE2019.1/config/scratches/scratch.py", line 7, in <module> cv2.DestroyAllWindows() AttributeError: module 'cv2.cv2' has no attribute 'DestroyAllWindows' and when i implemented this line in reasized = cv2.reasize(img, (800,600)) the same happend
The naming convention across cv2 is lowercase for first letter then camel case so it should be destroyAllWindows()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.