【问题标题】:obtain point cloud from depth numpy array using open3d - python使用open3d从深度numpy数组中获取点云-python
【发布时间】:2022-04-09 06:07:17
【问题描述】:

我有一个 2D numpy 数组(640X480),其中包含我通过渲染系统获得的每个像素的深度值。现在我想获取它的点云。我尝试了很多方法,但我遇到了旋转问题:

我尝试过的方法:

  1. 使用 open3d-python 库:我找到了一个示例并按照以下步骤操作:
color_raw = o3d.io.read_image("../../test_data/RGBD/color/00000.jpg")
depth_raw = o3d.io.read_image("../../test_data/RGBD/depth/00000.png")
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
    color_raw, depth_raw)

    a = o3d.camera.PinholeCameraIntrinsicParameters
    pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
        rgbd_image,
        o3d.camera.PinholeCameraIntrinsic(
            o3d.camera.PinholeCameraIntrinsicParameters.Kinect2DepthCameraDefault))
    o3d.visualization.draw_geometries([pcd])
```

**Problem**: 
a) I do not have an rgbd image. all I have is a 2d numpy array containing depth values for each pixel which can be saved as png image and used for the parameter depth_raw. 

b) I tried to create a point cloud only from depth image using the function `open3d.geometry.PointCloud.create_from_depth_image(depth, intrinsic, extrinsic=(with default value), depth_scale=1000.0, depth_trunc=1000.0, stride=1, project_valid_depth_only=True)` but I get error when I try to pass the png image. how can I pass my numpy array into the required image format. 

Please help me the above doubts to proceed further. 

thanks in advance 

【问题讨论】:

  • 我知道这不是解决方案,但您应该尝试Vedo library。如果您想要拥有交互式 3d 点云,并且想要拥有实时变化的点云,它会更容易使用。

标签: python numpy point-clouds depth open3d


【解决方案1】:

试试这个: depths 必须是一个 [n, n] numpy 数组,然后

import open3d as o3d

vertices = []
depths = (your_depth_values)

for x in range(depths.shape[0]):
    for y in range(depths.shape[1]):
        vertices.append((float(x), float(y), depths[x][y]))

pcd = o3d.geometry.PointCloud()
point_cloud = np.asarray(np.array(vertices))
pcd.points = o3d.utility.Vector3dVector(point_cloud)
pcd.estimate_normals()
pcd = pcd.normalize_normals()
o3d.visualization.draw_geometries([pcd])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2021-09-20
    • 2017-07-14
    • 1970-01-01
    相关资源
    最近更新 更多