matlab 获取d435深度图像,realsense D435I获取RGB图、深度图和左右图

2023-05-16

1 importpyrealsense2 as rs2 importnumpy as np3 importcv24

5 pipeline =rs.pipeline()6

7 config =rs.config()8

9 config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 15) #10、15或者30可选,20或者25会报错,其他帧率未尝试

10 config.enable_stream(rs.stream.infrared, 1, 640, 480, rs.format.y8, 15)11 config.enable_stream(rs.stream.infrared, 2, 640, 480, rs.format.y8, 15)12 config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 15)13

14 profile =pipeline.start(config)15

16 #Getting the depth sensor‘s depth scale (see rs-align example for explanation)

17 depth_sensor =profile.get_device().first_depth_sensor()18 depth_scale =depth_sensor.get_depth_scale()19 print("Depth Scale is:", depth_scale)20

21 clipping_distance_in_meters = 1 #1 meter

22 clipping_distance = clipping_distance_in_meters /depth_scale23

24 #Create an align object

25 #rs.align allows us to perform alignment of depth frames to others frames

26 #The "align_to" is the stream type to which we plan to align depth frames.

27 align_to =rs.stream.color28 align =rs.align(align_to)29

30

31 try:32 whileTrue:33 frames =pipeline.wait_for_frames()34

35 #Align the depth frame to color frame

36 aligned_frames =align.process(frames)37 #Get aligned frames

38 aligned_depth_frame = aligned_frames.get_depth_frame() #aligned_depth_frame is a 640x480 depth image

39 if notaligned_depth_frame:40 continue

41 depth_frame =np.asanyarray(aligned_depth_frame.get_data())42 #将深度图转化为伪彩色图方便观看

43 depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_frame, alpha=0.03), cv2.COLORMAP_JET)44 cv2.imshow(‘1 depth‘, depth_colormap)45

46 #color frames

47 color_frame =aligned_frames.get_color_frame()48 if notcolor_frame:49 continue

50 color_frame =np.asanyarray(color_frame.get_data())51 cv2.imshow(‘2 color‘, color_frame)52

53 #left frames

54 left_frame = frames.get_infrared_frame(1)55 if notleft_frame:56 continue

57 left_frame =np.asanyarray(left_frame.get_data())58 cv2.imshow(‘3 left_frame‘, left_frame)59

60 #right frames

61 right_frame = frames.get_infrared_frame(2)62 if notright_frame:63 continue

64 right_frame =np.asanyarray(right_frame.get_data())65 cv2.imshow(‘4 right_frame‘, right_frame)66

67 c = cv2.waitKey(1)68

69

70

71 #如果按下ESC则关闭窗口(ESC的ascii码为27),同时跳出循环

72 if c == 27:73 cv2.destroyAllWindows()74 break

75

76 finally:77 #Stop streaming

78 pipeline.stop()79

80 #深度图上色参考https://github.com/IntelRealSense/librealsense/blob/jupyter/notebooks/distance_to_object.ipynb

81 #对齐参考:https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/align-depth2color.py

82 #左右图获取参考https://blog.csdn.net/Hanghang_/article/details/102489762

83 #其他参考https://blog.csdn.net/Dontla/article/details/102701680

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

matlab 获取d435深度图像,realsense D435I获取RGB图、深度图和左右图 的相关文章

  • 朴素分类器 matlab

    在 matlab 中测试朴素分类器时 即使我在相同的样本数据上进行训练和测试 我也会得到不同的结果 我想知道我的代码是否正确 是否有人可以帮助解释这是为什么 dimensionality reduction columns 6 U S V
  • 如何打开 matlab p 代码文件

    有谁知道如何查看 matlab p 代码文件的代码 p 代码文件专门存在 以便您可以共享代码 以便其他人无法查看它 换句话说 您看不到 Matlab p 代码文件的代码
  • MATLAB:生成给定三种颜色的颜色图

    我正在尝试在 MATLAB 中生成给定三种颜色 最高值 零值和最低值 的颜色图 我的思维过程是从最高端到中间循环 并将每个步骤存储到一个 3xN 第一列是 R 第二列是 G 第三列是 B 矩阵 所以我正在使用 fade from high
  • MATLAB 中元胞数组的左连接

    I ve 2 cellMATLAB 中的数组 例如 A jim 4 paul 5 sean 5 rose 1 第二个 B jim paul george bill sean rose 我想做一个 SQL 左连接 这样我就可以得到 B 中的所
  • 如何在Matlab脚本中将泰勒级数系数存储到数组中

    这个问题是在 m 脚本的上下文中 我知道如何获取函数的泰勒级数 但我没有看到任何命令允许将级数的系数存储到数组中 sym2poly似乎不起作用 如何将系数存储到数组中 例如这个函数 syms x f 1 x 2 4 x 9 我们怎样才能得到
  • MATLAB 链表

    有哪些可能的方法来实现链表MATLAB http en wikipedia org wiki MATLAB 注意 我问这个问题是为了教学价值 而不是实用价值 我意识到 如果您实际上在 MATLAB 中滚动自己的链表 那么您可能做错了什么 然
  • 使用 libsvm 交叉验证后重新训练

    我知道交叉验证用于选择好的参数 找到它们后 我需要在不使用 v 选项的情况下重新训练整个数据 但我面临的问题是 在使用 v 选项训练后 我得到了交叉验证精度 例如 85 没有模型 我看不到 C 和 gamma 的值 在这种情况下我该如何重新
  • 增加 .fig 文件中的散点标记大小

    我有一个图形文件 scatter fig 该图有许多使用 scatter 的散点绘图仪 现在我只有这个无花果文件 我需要增加所有散点的标记大小 手动尝试过 但非常困难 有没有办法我可以做类似的事情 H 图形句柄 s 点 h 设置 s 标记大
  • 如何建立数据流挖掘的滑动窗口模型?

    我们遇到的情况是 流 来自传感器的数据或服务器上的点击流数据 采用滑动窗口算法 我们必须将最后 例如 500 个数据样本存储在内存中 然后 这些样本用于创建直方图 聚合并捕获有关输入数据流中异常的信息 请告诉我如何制作这样的滑动窗 如果您询
  • 如何读取 10 位原始图像?其中包含 RGB-IR 数据

    我想知道如何从我的 10 位原始 它有 rgb ir 图像数据 数据中提取 RGB 图像 如何使用 Python 或 MATLAB 进行阅读 拍摄时的相机分辨率为 1280x720 室内照片图片下载 https drive google c
  • 将 3d 矩阵重塑为 2d 矩阵

    我有一个 3d 矩阵 n by m by t 在 MATLAB 中表示n by m一段时间内网格中的测量值 我想要一个二维矩阵 其中空间信息消失了 只有n m随着时间的推移测量t剩下 即 n m by t 我怎样才能做到这一点 你需要命令r
  • 估算缺失数据,同时强制相关系数保持不变

    考虑以下 excel 数据集 m r 2 0 3 3 0 8 4 0 1 3 2 1 5 2 2 3 1 9 2 5 1 2 3 0 2 0 2 6 我的目标是使用以下条件填充缺失值 将上述两列之间的成对相关性表示为 R 大约 0 68 将
  • 整数的十进制表示形式中的分隔数字

    例如 我想将用户输入作为整数输入 45697 并将前两位数字存储在数组 向量或其他内容中 例如 4 5 6 9 7 这样我就可以使用一些函数调用来检查前两个值 4 5 并对它们进行计算 问题 我不知道如何存储恢复前两个值 有没有简单的函数调
  • MATLAB:比较两个不同长度的数组

    我有两个长度不同的数组 由于采样率不同 需要比较 我想对较大的数组进行下采样以匹配较小的数组的长度 但是该因子不是整数而是小数 举个例子 a 1 1 375 1 75 2 125 2 5 2 875 3 25 b 1 2 3 有什么方法可以
  • 如何从绘图处理程序中绘图?

    我有绘图的处理程序或图形的处理程序 例子 h plot 1 0 2 10 xx get h xx DisplayName Annotation 1x1 handle Color 0 0 1 LineStyle LineWidth 0 500
  • MATLAB 图中轴标签与轴之间的距离

    我正在使用 MATLAB 绘制一些数据 我想调整轴标签与轴本身之间的距离 但是 只需向标签的 位置 属性添加一点即可使标签移出图窗窗口 是否有 保证金 属性或类似的东西 在上图中 我想增加数字和标签 Time s 之间的距离 同时自动扩展数
  • 在 MATLAB 中定义其他中缀运算符

    有没有办法在 MATLAB 中定义额外的中缀运算符 具体来说 我想定义两个中缀运算符 gt and lt gt 这些符号是理想的 但如果需要 它可以是单个字符 它调用函数implies and iff以同样的方式 calls and and
  • 作为动画的八度情节点

    我有以下八度脚本 TOTAL POINTS 100 figure 1 for i 1 TOTAL POINTS randX rand 1 randY rand 1 scatter randX randY hold on endfor 当我运
  • 如何在Matlab中将世界坐标转换为像素索引

    我有 512x512x313 体积的 dicom 图像 并且我有一个以世界坐标表示的点 57 7475 63 4184 83 1515 我如何在 Matlab 中获得该世界坐标的相应像素坐标 我不想戳破你的幻想 但你所要求的是不可能的 我能
  • 非模态 questdlg.m 提示

    我的代码绘制了一个图 然后提示用户是否想使用不同的参数绘制另一个图 问题是 当 questdlg m 打开时 用户无法查看绘图的详细信息 这是代码 while strcmp Cont Yes 1 Some code modifying da

随机推荐