Read Frames from RTSP Stream in Python

前端 未结 6 469
旧巷少年郎
旧巷少年郎 2020-12-13 16:12

I have recently set up a Raspberry Pi camera and am streaming the frames over RTSP. While it may not be completely necessary, here is the command I am using the broadcast th

6条回答
  •  旧时难觅i
    2020-12-13 16:44

    Using the same method listed by "depu" worked perfectly for me. I just replaced "video file" with "RTSP URL" of actual camera. Example below worked on AXIS IP Camera. (This was not working for a while in previous versions of OpenCV) Works on OpenCV 3.4.1 Windows 10)

    import cv2
    cap = cv2.VideoCapture("rtsp://root:pass@192.168.0.91:554/axis-media/media.amp")
    
    while(cap.isOpened()):
        ret, frame = cap.read()
        cv2.imshow('frame', frame)
        if cv2.waitKey(20) & 0xFF == ord('q'):
            break
    cap.release()
    cv2.destroyAllWindows()
    

提交回复
热议问题