Reputation: 510
I'm starting out with OpenCV with Python 3 and I have the following snippet:
import cv2
video = cv2.VideoCapture(0)
while True:
success, captured_frame = video.read()
cv2.imshow('Video', captured_frame)
pressed_key = cv2.waitKey(1) & 0xFF
if pressed_key == ord('q'):
break
video.release()
cv2.destroyAllWindows()
If I remove the pressed_key
variable along with its condition, the program runs but the Video window is blank and Windows attempts to force quit the program. Why is that?
Upvotes: 2
Views: 693
Reputation: 20140
opencv performs window rendering during waitKey times, so you will need at least a waitKey(1) call to see some window content.
Upvotes: 3