Python × OpenCV × 海康威视大华其他网络摄像机(IPC)环境参数配置及实时预览二次开发

# -*- coding: UTF-8 -*-
# ! /usr/bin/python

import cv2

# 参数

# -------------------------------------- 这是一条分割线 --------------------------------------
# -------------------------------------- 摄像机的:用户名 密码 IP --------------------------------------

# path = 0 # 0表示计算机自带的摄像头,这样可以实验余下程序是否正确
path = "rtsp://摄像机用户名:摄像机密码@摄像机IP地址:554/h264/ch1/main/av_stream" # 把摄像机相应信息修改好
# 例如:path = "rtsp://admin:[email protected]:554/h264/ch1/main/av_stream"

# -------------------------------------- 这是一条分割线 --------------------------------------

def main():
    camera = cv2.VideoCapture(path)

    while True:
        grabbed, frame = camera.read()
        cv2.putText(frame,
                    'Tips: Please click "Esc" to close the window.',
                    (0, 25),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.7,
                    (0, 255, 255), 2)
        cv2.imshow("surveillance", frame)

        if cv2.waitKey(1) & 0xff == 27:
            break
    camera.release()

if __name__ == "__main__":
    main()

猜你喜欢

转载自blog.csdn.net/zuliang001/article/details/80882524