python使用opencv读取海康摄像头视频流rtsp

jupiter
2021-11-26 / 0 评论 / 631 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年12月07日,已超过871天没有更新,若内容或图片失效,请留言反馈。

pythons使用opencv读取海康摄像头视频流rtsp

海康IPcamera rtsp地址和格式:

rtsp://[username]:[password]@[ip]:[port]/[codec]/[channel]/[subtype]/av_stream
说明:
username: 用户名。例如admin。
password: 密码。例如12345。
ip: 为设备IP。例如 192.0.0.64。
port: 端口号默认为554,若为默认可不填写。
codec:有h264、MPEG-4、mpeg4这几种。
channel: 通道号,起始为1。例如通道1,则为ch1。
subtype: 码流类型,主码流为main,辅码流为sub。

python读取视频流

import cv2
url = 'rtsp://admin:!itrb123@10.1.9.143:554/h264/ch1/main/av_stream'
cap = cv2.VideoCapture(url)
while(cap.isOpened()):  
    # Capture frame-by-frame  
    ret, frame = cap.read()  
    # Display the resulting frame  
    cv2.imshow('frame',frame)  
    if cv2.waitKey(1) & 0xFF == ord('q'):  
        break  
# When everything done, release the capture   
cap.release()  
cv2.destroyAllWindows()
0

评论 (0)

打卡
取消