God_Help
God_Help

Reputation: 35

Error while using waitkey() in openCV

I have been working on a very simple python code for taking video input.

import cv2
import numpy as np

#Capturing video
cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read() #Ret returns whether it's true or false
cv2.imshow('Image',frame)

if cv2.waitkey(1) & 0xff == ord('q'):
    break
cap.release()
cv2.destroyAllWindows()

but, while executing, it's showing an error like this...

line 11, in <module>
if cv2.waitkey(0) & 0xff == ord('q'):
AttributeError: 'module' object has no attribute 'waitkey'

What is the way out? I am using Python 2.7.13 and openCV 2.4.10.

Upvotes: 1

Views: 5784

Answers (3)

Neeraj Sharma
Neeraj Sharma

Reputation: 1

Simply replace cv2.waitkey(1) with cv2.waitKey(1)

Upvotes: -1

Shahrukh khan
Shahrukh khan

Reputation: 382

The K is capital in cv2.waitKey() , write

if (cv2.waitKey(1) & 0xff) == ord('q'):
    break

Upvotes: 1

Quang Hoang
Quang Hoang

Reputation: 150735

It's cv2.waitKey() not cv2.waitkey().

Upvotes: 3

Related Questions