python opencv cv2.waitkey error
Asked Answered
J

4

15

i'm trying to test the following code of the getting started page:

import numpy as np
import cv2   
img = cv2.imread('test.jpg', 0)
cv2.imshow('image', img)
cv2.waitkey(0)&0xFF
cv2.destroyAllWindows()

But i got this error:

init done 
opengl support available 
Traceback (most recent call last):
  File "showimg.py", line 5, in <module>
    cv2.waitkey(0)&0xFF
AttributeError: 'module' object has no attribute 'waitkey'
Violación de segmento

I executed the examples that comes with the opencv installation, and they run correctly. Also, the last example that use the Matplotlib works fine.

¿Any idea of the error?, ¿any suggestion?

Justis answered 5/2, 2014 at 4:10 Comment(0)
H
41

AttributeError: 'module' object has no attribute 'waitkey'

Try cv2.waitKey in place of cv2.waitkey. Capitalization counts.

Harms answered 5/2, 2014 at 4:19 Comment(0)
S
1
cv2.waitKey()

This syntax works. In the open parentheses add time.

Subscript answered 27/9, 2019 at 3:35 Comment(1)
This is basically the same answer as the accepted one from five years ago.Banquette
W
1

Try waitKey() instead of waitkey(),It worls fine.

Welty answered 16/6, 2020 at 13:8 Comment(0)
M
0
'module' object has no attribute 'waitkey' 

For solving this problem you should use this code:

enter image description here

'waitKey' with capital K, it will solve your problem.

Mahayana answered 10/7, 2020 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.