1

I'm trying to create a point cloud from a mesh. I haven't had any success. The compiler complains at the line actor = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd, cam) with the following error: [CreatePointCloudFromRGBDImage] Unsupported image format.

When checking rgbd by using print(rgbd) I get the following info:

RGBDImage of size 
Color image : 1920x1061, with 3 channels.
Depth image : 1920x1061, with 1 channels.
Use numpy.asarray to access buffer data.

So it makes me think that the image is valid. Any thoughts on what the issue might be?

import open3D as o3d

def render_depth(cam_intrinsic, model):
    # load model
    actor = o3d.io.read_triangle_mesh(str(model))
    actor.compute_vertex_normals()

    # create visualizer object
    vis = o3d.visualization.Visualizer()
    vis.create_window()
    vis.add_geometry(actor)
    ctr = vis.get_view_control()

    # retrieve intrinsic camera settings
    parameters = o3d.io.read_pinhole_camera_parameters(cam_intrinsic)
    ctr.convert_from_pinhole_camera_parameters(parameters)
    depth = vis.capture_depth_float_buffer(False)
    image = vis.capture_screen_float_buffer(False)
    vis.run()
    vis.destroy_window()

    return depth, image

def main():

    # produce depth and color image, for creating RGBD image
    depth, color = render_depth('directory_to_camera_properties.json', 'model_directory.obj')

    # create RGBD image
    rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(color=color, depth=depth, 
convert_rgb_to_intensity=False)

    cam = o3d.camera.PinholeCameraIntrinsic()
    cam.intrinsic_matrix = [[500, 0.0, 0.0], [0.0, 918.8529534152894, 0.0], [959.5, 530.0, 1.0]]

    actor = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd, cam)

    o3d.visualization.draw_geometries([actor])

if __name__ == '__main__':
    main()

1 Answer 1

0

Although I don't know what's in your directory_to_camera_properties.json file, but the vis.run() should come before you capture the depth and image in the render_depth function. Thus it should look like:

def render_depth(cam_intrinsic, model):
    # load model
    # ...

    vis.run()
    depth = vis.capture_depth_float_buffer()
    image = vis.capture_screen_float_buffer()
    vis.destroy_window()

    return depth, image

This resolved the issue for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.