OpenCv error can't open camera through video capture

后端 未结 6 1988
太阳男子
太阳男子 2021-01-17 20:01

I was using my cam through opencv and suddenly after restarting I ran my code it shows below error:

[ WARN:0] global /io/opencv/modules/videoio/src/cap_v4l.c         


        
6条回答
  •  广开言路
    2021-01-17 20:53

    I will not go to that part What you are trying to do, here is just a block of code that can open your camera every time you run it,

    python: 3.7.3

    OpenCV: 4.1.0

    import cv2
    cap = cv2.VideoCapture(0)
    while True:
    
        ret, frame = cap.read()
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    cap.release()
    cv2.destroyAllWindows()
    

提交回复
热议问题