问题描述
我有一个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
如何解决此问题?如果需要图像类型,那么如何将numpy数组转换为图像类型?
即使我将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,convert_rgb_to_intensity: bool = True) -> open3d.open3d_pybind.geometry.RGBDImage
如何解决此问题并从rgb numpy数组和depth numpy数组创建RGBD图像?
解决方法
如果您分享一个可复制的示例,那会很好,但是我认为从np.array创建Image
并不像基于signature调用ctor那样简单。这不一定是uint8的数组,对吧?
基于this article,您必须按照以下步骤创建它:
depth_as_img = o3d.geometry.Image((depth).astype(np.uint8))
,然后进一步传递到create_from_color_and_depth
。因此,您必须明确指定它是uint8s的数组。
您应该在此函数中检查convert_rgb_to_intensity
参数。默认情况下,它将使用灰度图像。这样,您的彩色图像应该只有一个通道。如果要使用RGB,请将该参数设置为false,然后查看是否可以解决。
此外,对于从numpy到open3d图像的其他注释:https://github.com/intel-isl/Open3D/issues/957