Search code examples
pythonopencvdeep-learningface-recognition

ret, frame = video_capture.read() ValueError: too many values to unpack (expected 2)


I want to use IP cam instead of webcam on my project which is based on tiny face detection.

video_capture = cv2.VideoCapture(0)
video_capture=VideoStream("rtsp://admin:bilge06@10.374.140.132:554").start()

Solution

  • For Python

    capture= cv2.VideoCapture("rtsp://admin:bilge06@10.374.140.132:554")
    
    if not capture:
        print("Failed")
    else:
       ret, frame= capture.read()
    
    

    It is in C++ You need change the code as

    VideoCapture capture;
    Mat ImageMat;
    bool op = capture.open("rtsp://admin:bilge06@10.374.140.132:554");
    if(op)
    {
        capture >> ImageMat;
    }
    

    It will read from the stream. To check whether stream is working or not you can use VLC player and set the IP in network stream and it will verify it