I am getting 'Attribute Error' in the following code while tried loading an image, using Python & OpenCV?

99 views Asked by At

I want to load image using opencv-python. For that I install python 3.7 and pycharm IDE properly. All settings in pycharm regarding opencv-python, I properly installed.After that, I input this code and run

import cv2

img = cv2.imread('lena.jpg',1)
print(img)

cv2.imshow('image',img)
cv2.waitkey()
cv2.destroyAllWindows()

But this error has been shown:

[ 81  68 176]
  [ 81  72 183]
  [ 84  74 188]]]
Traceback (most recent call last):
  File "C:/Users/Asaduz Zaman/PycharmProjects/OpenCVExamples/getting_started_with_images.py", line 7, in <module>
    cv2.waitkey()
AttributeError: module 'cv2.cv2' has no attribute 'waitkey'

Process finished with exit code 1

I donot understand what is the probelm. pls need suggestions

Versions::

Python 3.7 opencv 4.1.26 Pycharm 2019.2.4

1

There are 1 answers

0
DeepSpace On

It should be waitKey (upper-case K)

From the docs:

Python: cv2.waitKey([delay]) → retval