python opencv cv2.waitkey error

juanca picture juanca · Feb 5, 2014 · Viewed 28.5k times · Source

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?

Answer

John1024 picture John1024 · Feb 5, 2014

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

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