OpenCV Error: (-215)size.width>0 && size.height>0 in function imshow

前端 未结 16 2476
既然无缘
既然无缘 2020-11-29 09:09

I am trying to make a face tracker that combines Haar Cascade Classification with Lucas Kanade good feature detection. However, I keep getting an error that I cannot figure

16条回答
  •  天涯浪人
    2020-11-29 09:32

    You have to delay

    Example Code:

    import cv2
    import numpy as np
    import time
    
    cam = cv2.VideoCapture(0)
    time.sleep(2)
    
    while True:
        ret,frame = cam.read()
        cv2.imshow('webcam', frame)
        if cv2.waitKey(1)&0xFF == ord('q'):
            break
    
    cam.release()
    cv2.destroyAllWindows()
    

提交回复
热议问题