Open3d: convert depth image to pcd

Created on 27 Jul 2018  路  11Comments  路  Source: intel-isl/Open3D

i wonder if there is an existing function that can convert a depth image into point cloud format (.pcd), given the camera intrinsic matrix?

question

Most helpful comment

Oh, I see the point. Then try using create_point_cloud_from_depth_image. The modified example code will be

    depth_raw = read_image("../../TestData/RGBD/depth/00000.png")
    pcd = create_point_cloud_from_rgbd_image(depth_raw, PinholeCameraIntrinsic(
            PinholeCameraIntrinsicParameters.PrimeSenseDefault))
    draw_geometries([pcd])

Definition is here.
https://github.com/IntelVCL/Open3D/blob/35be432d45bf47bbcdf920c62d7d9d446ac6d36d/src/Core/Geometry/PointCloudFactory.cpp#L100-L104.

All 11 comments

Yes. Please check this tutorial: http://open3d.org/docs/tutorial/Basic/rgbd_images/redwood.html
In short, what you looking for is something like:

    color_raw = read_image("../../TestData/RGBD/color/00000.jpg")
    depth_raw = read_image("../../TestData/RGBD/depth/00000.png")
    rgbd_image = create_rgbd_image_from_color_and_depth(
        color_raw, depth_raw); 
    pcd = create_point_cloud_from_rgbd_image(rgbd_image, PinholeCameraIntrinsic(
            PinholeCameraIntrinsicParameters.PrimeSenseDefault))
    draw_geometries([pcd])

great! but could i create a pcd without the rgb image?

Oh, I see the point. Then try using create_point_cloud_from_depth_image. The modified example code will be

    depth_raw = read_image("../../TestData/RGBD/depth/00000.png")
    pcd = create_point_cloud_from_rgbd_image(depth_raw, PinholeCameraIntrinsic(
            PinholeCameraIntrinsicParameters.PrimeSenseDefault))
    draw_geometries([pcd])

Definition is here.
https://github.com/IntelVCL/Open3D/blob/35be432d45bf47bbcdf920c62d7d9d446ac6d36d/src/Core/Geometry/PointCloudFactory.cpp#L100-L104.

This is exactly the function i am looking for! Thank you!

Yes. Please check this tutorial: http://open3d.org/docs/tutorial/Basic/rgbd_images/redwood.html
In short, what you looking for is something like:

    color_raw = read_image("../../TestData/RGBD/color/00000.jpg")
    depth_raw = read_image("../../TestData/RGBD/depth/00000.png")
    rgbd_image = create_rgbd_image_from_color_and_depth(
        color_raw, depth_raw); 
    pcd = create_point_cloud_from_rgbd_image(rgbd_image, PinholeCameraIntrinsic(
            PinholeCameraIntrinsicParameters.PrimeSenseDefault))
    draw_geometries([pcd])

i tried the same code but its giving me black and white pcd? ... can you explain why ? ... i want to create colored pcd using rgb and depth image taken with RealSense D415

@Resays

i tried the same code but its giving me black and white pcd? ... can you explain why ?

create_from_color_and_depth() converts an RGB image to an intensity image.

i want to create colored pcd ...

After creating a black and white pcd, change pcd's colors:

rgb_vector = np.reshape( rgb_image, [-1, 3])
pcd.colors = o3d.utility.Vector3dVector(rgb_vector)

Note that you can pass convert_rgb_to_intensity=False to create_from_color_and_depth() to avoid converting to intensity values.

You're right, but then how should PointCloud.create_from_rgbd_image() be configured to create a point cloud from the RGB-D?
It creates 0 points when I pass convert_rgb_to_intensity=False to create_from_color_and_depth().

Hi i am getting error
pcd = create_point_cloud_from_rgbd_image(depth_raw, PinholeCameraIntrinsic(
^
IndentationError: unexpected indent

Thanks for the pointer @griegler. I hit the same problem recently, and I found that it's a bit counter intuitive to get an intensity pointcloud by default given a pair of RGB and depth images. As you mentioned, I added convert_rgb_to_intensity=False as an arg and finally I got a colorized pointcloud I wanted.

Is it possible to make the colored pointcloud by default with a flag to convert that to intensity? If not, I think more specific documentation on the API (the page I checked is an older version of Open3d) or the tutorial will be extremely helpful.

@theNded what are your thoughts on that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samarth-robo picture samarth-robo  路  3Comments

mike239x picture mike239x  路  4Comments

taochenshh picture taochenshh  路  3Comments

masonsun picture masonsun  路  3Comments

nrj127 picture nrj127  路  4Comments