1

I found several tutorials about visualization of point cloud from RGB-D image in Open3D. But I only got the result in gray-scale mode. Here is my example code:

import open3d as o3d # installed by running: <pip install open3d-python> 
def img_to_pointcloud(img, depth, K, Rt):
    rgb = o3d.geometry.Image(img)
    depth = o3d.geometry.Image(depth)
    rgbd = o3d.geometry.create_rgbd_image_from_color_and_depth(rgb, depth, depth_scale=1.0, depth_trunc=50.0)
    fx, fy, cx, cy = K[0, 0], K[1, 1], K[0, 2], K[1, 2]
    intrinsic = o3d.camera.PinholeCameraIntrinsic(int(cx*2), int(cy*2), fx, fy, cx, cy)
    pc = o3d.create_point_cloud_from_rgbd_image(rgbd, intrinsic, Rt)
    o3d.visualization.draw_geometries([pc])

The example of result can be found at http://www.open3d.org/docs/release/getting_started.html#running-open3d-tutorials. Does Open3D support visualize point cloud in RGB mode. If it doesn't, what the library would you recommend in Python?

Khang Truong
  • 357
  • 1
  • 6
  • 16
  • Can you check colors with [`has_colors(pc)`](http://www.open3d.org/docs/release/python_api/open3d.geometry.PointCloud.html?highlight=has_colors#open3d.geometry.PointCloud.has_colors)? According to [this tutorial](http://www.open3d.org/docs/release/tutorial/Basic/pointcloud.html?highlight=create%20point%20cloud#visualize-point-cloud) it can visualize colored PCs. Maybe [`create_point_cloud_from_rgbd_image`](http://www.open3d.org/docs/release/python_api/open3d.geometry.PointCloud.html?highlight=create_from_rgbd_image#open3d.geometry.PointCloud.create_from_rgbd_image) does not assign colors. – ilke444 Mar 12 '20 at 07:14
  • Else I would recommend [PCL](http://www.pointclouds.org/documentation/). Although I only use it in c++, python bindings [exist](https://strawlab.github.io/python-pcl/). – ilke444 Mar 12 '20 at 07:25
  • yes, I've already checked colors with has_colors function. The output is True. So, I don't understand why. Thank you, I'll try to use PCL – Khang Truong Mar 12 '20 at 09:01
  • Now that I looked at the tutorial again, the point cloud does have colors! Since the image is in grayscale, the resulting point cloud also have 1 channel colors. So it does render it correctly, with color. – ilke444 Mar 12 '20 at 09:19
  • yeah, I checked my image `img`, it is a color image. But when creating the point cloud by using `create_point_cloud_from_rgbd_image`, only grayscale is shown – Khang Truong Mar 12 '20 at 12:03

1 Answers1

3

Does Open3D support visualize point cloud in RGB mode?

Yes, it does.

Open3D.geometry.create_rgbd_image_from_color_and_depth has an optional parameter convert_rgb_to_intensity which is set to be true by default.

To visualize in RGB mode, just change your fifth line to
rgbd = o3d.geometry.create_rgbd_image_from_color_and_depth(rgb, depth, depth_scale=1.0, depth_trunc=50.0, convert_rgb_to_intensity=False).

Jing Zhao
  • 2,420
  • 18
  • 21