opencv连rtsp

import cv2

def watch_video():
    source="rtsp://admin:[email protected]:554/Streaming/Channels/802"
    cap = cv2.VideoCapture(source)
    cap.set(cv2.CAP_PROP_BUFFERSIZE, 0)
    _,img=cap.read()
    while cap.isOpened():
        back,frame=cap.read()
        cv2.namedWindow("cam",0)
        cv2.imshow("cam",frame)
        if not back:
            print('no')
            break
        if cv2.waitKey(1) & 0xFF ==1:
            break


if __name__ == "__main__":
    watch_video()

你可能感兴趣的:(opencv)