Why removing waitKey() in openCV doesn't work?

泪湿孤枕 提交于 2021-02-19 05:25:11

问题


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?


回答1:


opencv performs window rendering during waitKey times, so you will need at least a waitKey(1) call to see some window content.



来源:https://stackoverflow.com/questions/59557039/why-removing-waitkey-in-opencv-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!