Ask Your Question

Revision history [back]

closing video with any key

Hi, I want to close the video frame with any key from the keyboard. I have tried with waitKey(0), but it just displays an image. I want to stream the video from webcam and want to close the streaming when I press any key. Is there any better way than passing all the keys at ord()?

 # Press 'q' to quit
key = cv2.waitKey(1) & 0xFF
    # if the `q` key was pressed, break from the loop
if key == ord('q'):
    break