我有一个 numpy 数组,它是形状(高度、宽度、3)的彩色图像“img”,还有一个形状(高度、宽度)的深度 numpy 数组。我想创建一个 RGBD 图像并显示它,为此我正在执行以下操作:o3d.geometry.RGBDImage.create_from_color_and_depth(img, depth)但我收到错误:TypeError: create_from_color_and_depth(): incompatible function arguments. The following argument types are supported: 1. (color: open3d.open3d_pybind.geometry.Image, depth: open3d.open3d_pybind.geometry.Image, depth_scale: float = 1000.0, depth_trunc: float = 3.0, convert_rgb_to_intensity: bool = True) -> open3d.open3d_pybind.geometry.RGBDImage如何解决这个问题?如果它需要一个 Image 类型,那么如何将 numpy 数组转换为 Image 类型?即使我像这样将 numpy 数组传递给 o3d.geometry.Image 构造函数:o3d.geometry.RGBDImage.create_from_color_and_depth(o3d.geometry.Image(img), o3d.geometry.Image(depth))我收到错误:TypeError: create_from_color_and_depth(): incompatible function arguments. The following argument types are supported: 1. (color: open3d.open3d_pybind.geometry.Image, depth: open3d.open3d_pybind.geometry.Image, depth_scale: float = 1000.0, depth_trunc: float = 3.0, convert_rgb_to_intensity: bool = True) -> open3d.open3d_pybind.geometry.RGBDImage如何解决这个问题并从 rgb numpy 数组和深度 numpy 数组创建 RGBD 图像?
3 回答

收到一只叮咚
TA贡献1821条经验 获得超4个赞
如果您共享可重现的示例会很棒,但我认为Image
从 np.array 创建并不像基于signature调用 ctor 那样简单。这不一定是一个 uint8 数组,对吧?
您必须按如下方式创建它:
depth_as_img = o3d.geometry.Image((depth).astype(np.uint8))
并进一步传递给create_from_color_and_depth
. 因此,您必须明确指定它是一个 uint8 数组。

扬帆大鱼
TA贡献1799条经验 获得超9个赞
您应该检查convert_rgb_to_intensity
此函数中的参数。默认情况下,它将使用灰度图像。这样,您的彩色图像应该只有一个通道。如果你想要 RGB,将该参数设置为 false 并查看它是否解决。

蓝山帝景
TA贡献1843条经验 获得超7个赞
您必须将图像转换为连续数组。您可以使用 numpy 数组执行此操作,如下所示!
depth_map = np.array(depth_map, dtype=np.float32)
添加回答
举报
0/150
提交
取消