调用红外双目摄像头

最近要做死鸡检测,公司光学同事给到了我这个红外双目摄像头,我一开始读的时候跟poe接口的网络摄像头的连接读取方式是一样的,但是读取出来的画面只有一个,并没有红外画面

查了半天资料,发现调用的时候要调用两个!

import cv2

ip_address = '192.168.254.5'
port = 554
username = 'admin'
password = '123456789'
stream_path_left = f'rtsp://{username}:{password}@{ip_address}:{port}/cam/realmonitor?channel=1&subtype=0'

stream_path_right = f'rtsp://{username}:{password}@{ip_address}:{port}/cam/realmonitor?channel=2&subtype=0'

cap_left = cv2.VideoCapture(stream_path_left, cv2.CAP_FFMPEG)
cap_right = cv2.VideoCapture(stream_path_right, cv2.CAP_FFMPEG)
if not cap_left.isOpened() or not cap_right.isOpened():
    print('无法连接相机!')
    exit()
while True:
    ret_left, frame_left = cap_left.read()
    ret_right, frame_right = cap_right.read()

    if not ret_left or not ret_right:
        print('无法读取帧!')
        break

    cv2.imshow('RGB camera', frame_left)
    cv2.imshow('Infrared camera', frame_right)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap_left.release()
cap_right.release()
cv2.destroyAllWindows()

这样就可以同时打开RGB摄像头和红外摄像头了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值