Python Intel RealSense-在两个numpy阵列中对齐深度和颜色

Python Intel RealSense-在两个numpy阵列中对齐深度和颜色,python,numpy,realsense,Python,Numpy,Realsense,我使用的是Intel RealSense 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)

我使用的是Intel RealSense 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-数组640x480x1)和(RGB-数组640x480x3)

调用如何?我希望有一种方法可以使用librealsense模块。现在,我刚刚使用opencv来调整图像的大小。不确定这是否是最好的解决方案,但目前它必须这样做。