zen*_*vil 10 python arrays numpy open3d
我有一个 numpy 数组,它是形状(高度,宽度,3)的彩色图像“img”,也是形状(高度,宽度)的深度 numpy 数组。我想创建一个 RGBD 图像并显示它,为此我正在执行以下操作:
o3d.geometry.RGBDImage.create_from_color_and_depth(img, depth)
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
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
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?如果需要Image类型,那么如何将numpy数组转换为Image类型?
即使我将 numpy 数组传递到 o3d.geometry.Image 构造函数中,如下所示:
o3d.geometry.RGBDImage.create_from_color_and_depth(o3d.geometry.Image(img), o3d.geometry.Image(depth))
Run Code Online (Sandbox Code Playgroud)
我收到错误:
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
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题并从 rgb numpy 数组和深度 numpy 数组创建 RGBD 图像?
如果您分享可重现的示例,那就太好了,但我认为Image
从 np.array 创建并不像基于签名调用 ctor 那么简单。这不一定是 uint8 数组,对吧?
基于这篇文章,您必须按如下方式创建它:
depth_as_img = o3d.geometry.Image((depth).astype(np.uint8))
Run Code Online (Sandbox Code Playgroud)
并进一步传递到create_from_color_and_depth
. 因此,您必须明确指定它是 uint8 数组。
归档时间: |
|
查看次数: |
8837 次 |
最近记录: |