关于RealSenseD435

官方网址https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python

两个RealSenseD435连接到电脑,对图像进行同时读取和显示:

		# 相机1
		self.pipeline1 = rs.pipeline()  # ***刚开始出错,明明自我感觉良好却开始怀疑人生,是因为刚开始这里写的是self.pipeline1 = rs.pipeline,用类初始化时忘掉了括号()***
        self.config1 = rs.config()  # rs.config()函数用于创建摄像头配置对象,用于在pipeline对象启动配置对象之前对摄像头rgb流或depth流进行配置
        self.config1.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
        self.config1.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 60)   # Configure depth and color streams
        self.config1.enable_device(str(938422072062))
        self.profile1 = self.pipeline1.start(self.config1)    # Start streaming

        self.depth_sensor1 = self.profile1.get_device().first_depth_sensor()
        self.depth_scale1 = self.depth_sensor1.get_depth_scale()
 
        self.frames1 = self.pipeline1.wait_for_frames()
        self.color_frame1 = self.frames1.get_color_frame()
        self.color_and_depth_images["color_and_depth_images1"]["color"] = np.asanyarray(self.color_frame1.get_data())
	
		# 相机2
        self.pipeline2 = rs.pipeline()
        self.config2 = rs.config()  # rs.config()函数用于创建摄像头配置对象,用于在pipeline对象启动配置对象之前对摄像头rgb流或depth流进行配置
        self.config2.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
        self.config2.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 60)  # Configure depth and color streams
        self.config1.enable_device(str(935322072420))
        self.profile2 = self.pipeline2.start(self.config2)  # Start streaming

        self.depth_sensor2 = self.profile2.get_device().first_depth_sensor()
        self.depth_scale2 = self.depth_sensor2.get_depth_scale()
        
        self.frames2 = self.pipeline2.wait_for_frames()
        self.color_frame2 = self.frames2.get_color_frame()
        self.color_and_depth_images["color_and_depth_images2"]["color"] = np.asanyarray(self.color_frame2.get_data())  # [:, 80:]

验证程序

import pyrealsense2 as rs
import numpy as np
import cv2

pipeline1 = rs.pipeline()
config1 = rs.config()
config1.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config1.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 60)
config1.enable_device(str(938422072062))
profile1 = pipeline1.start(config1)
depth_sensor1 = profile1.get_device().first_depth_sensor()
frames1 = pipeline1.wait_for_frames()
color_frame1 = frames1.get_color_frame()
img1 = np.asanyarray(color_frame1.get_data())
# name1 = "img1"
# cv2.namedWindow(name1)
# cv2.imshow(name1, img1)
# cv2.waitKey(0)
# cv2.destroyWindow(name1)

pipeline2 = rs.pipeline()
config2 = rs.config()
config2.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 60)
config2.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config2.enable_device(str(935322072420))
profile2 = pipeline2.start(config2)
depth_sensor2 = profile2.get_device().first_depth_sensor()
frames2 = pipeline2.wait_for_frames()
color_frame2 = frames2.get_color_frame()
img2 = np.asanyarray(color_frame2.get_data())

img = np.concatenate([img1, img2], axis=1)
name2 = "img"
cv2.namedWindow(name2)
cv2.imshow(name2, img)
cv2.waitKey(0)
cv2.destroyWindow(name2)

# print(depth_sensor1)
# print(depth_sensor2)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值