【问题标题】:Intel RealSense - Align depth and color in two numpy arrays英特尔实感 - 在两个 numpy 数组中对齐深度和颜色
【发布时间】:2021-05-12 14:51:47
【问题描述】:

我正在使用英特尔实感 L515。我想在两个不同的 numpy 数组中对齐深度和彩色图像,使它们的分辨率相同。

这是我的代码

import pyrealsense2 as rs
import numpy as np


pc = rs.pointcloud()


pipe = rs.pipeline()
config = rs.config()

config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 960, 540, rs.format.bgr8, 30)

pipe.start(config)

try:

    frames = pipe.wait_for_frames()

    depth = frames.get_depth_frame()
    color = frames.get_color_frame()

    # These are the two different frames to align
    depth_image = np.asanyarray(depth.get_data())
    color_image = np.asanyarray(color.get_data())

    # The new color image
    # color_image_with_same_resolution = ?

finally:
    pipe.stop()

彩色图像比深度图像具有更高的分辨率。什么是调整彩色图像大小的最有效方法,使其具有与深度图像相同的尺寸,并且每个颜色像素都映射到正确的对应深度像素。在这种情况下,速度和效率至关重要。

本质上,我希望能够保存两个单独的数组,以便在另一个程序中使用。数组必须具有相同的维度,如下所示:(Z - Array 640x480x1) 和 (RGB -Array 640x480x3)

【问题讨论】:

  • 打电话给resize怎么样?
  • 我希望有一种方法可以使用 librealsense 模块。现在我刚刚使用 opencv 来调整图像大小。不确定这是否是最好的解决方案,但现在必须这样做。

标签: python numpy realsense


【解决方案1】:

检查这个 librealsense 示例:

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/align-depth2color.py

它使用 pyrealsense2.align() 允许将深度帧与其他帧对齐。

【讨论】:

    【解决方案2】:

    解决方案非常简单。使用 pyrealsense2 库时速度也很快!

    import pyrealsense2 as rs
    
    pipeline = None
    colorizer = rs.colorizer()
    align = rs.align(rs.stream.depth)
    
    pipeline = rs.pipeline()
    config = rs.config()
    config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16,30) config.enable_stream(rs.stream.color, 960, 540, rs.format.rgb8, 30)
    profile = pipeline.start(config)
    
    frameset = pipeline.wait_for_frames()
    frameset = align.process(frameset)
    aligned_color_frame = frameset.get_color_frame()
    color_frame = np.asanyarray(aligned_color_frame.get_data())
    depth = np.asanyarray(frameset.get_depth_frame().get_data())
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 2015-02-13
      • 1970-01-01
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多