python openCV显示摄像头


# -*- coding: utf-8 -*-

# @author leone
# @desc 使用 python 的 openCV 获取网络摄像头的数据
# @version 2018-12-23

import cv2
import sys

# 根据摄像头设置IP及rtsp端口
url = 'rtsp://account:password@192.168.0.35:554/11'

# 读取视频流
cap = cv2.VideoCapture(url)
# 设置视频参数
cap.set(3, 480)

print(cap.isOpened())

print(sys.version)

print(cv2.__version__)

while cap.isOpened():
    ret_flag, img_camera = cap.read()
    cv2.imshow("camera", img_camera)

    # 每帧数据延时 1ms, 延时为0, 读取的是静态帧
    k = cv2.waitKey(1)
    if k == ord('s'):
        cv2.imwrite("test.jpg", img_camera)
    if k == ord('q'):
        break

# 释放所有摄像头
cap.release()

# 删除窗口
cv2.destroyAllWindows()


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值