1

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.

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

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

1 Comment

@D.Mitra You can mark this answer as a verified solution
-1

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

Comments

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.