How to disable Buffer in OpenCV Camera?

前端 未结 3 1420
情话喂你
情话喂你 2021-01-04 19:07

I have this situation where I use OpenCV to detect faces in front of the camera and do some ML on those faces. The issue that I have is that once I do all the processing, an

3条回答
  •  一个人的身影
    2021-01-04 19:32

    I set cap value after reading each frame to None and my problem solved in this way:

    import cv2
    from PyQt5.QtCore import QThread
    
    if __name__ == '__main__':
    while True:
        cap = cv2.VideoCapture(0)
        ret, frame = cap.read()
        cv2.imshow('A', frame)
        cv2.waitKey(0)
    
        print('sleep!')
        QThread.sleep(5)
        print('wake up!')
        cap = None
    

提交回复
热议问题