Clyde Tony
Clyde Tony

Reputation: 11

Why can't show the second point cloud?

Use the open3d can't show the second point cloud with o3d.visualization.VisualizerWithEditing().

python version = 3.8.19

open3d == 0.18.0

numpy == 1.24.4

WLS = 2.0

This is my test file:

import open3d as o3d
import numpy as np

# create point cloud
pcd1 = o3d.geometry.PointCloud()
pcd1.points = o3d.utility.Vector3dVector(np.random.random((100, 3)))
pcd1.paint_uniform_color([1, 0, 0])

pcd2 = o3d.geometry.PointCloud()
pcd2.points = o3d.utility.Vector3dVector(np.random.random((100, 3)))
pcd2.paint_uniform_color([0, 1, 0])

# create window
vis = o3d.visualization.VisualizerWithEditing()
vis.create_window()

# add point cloud data
vis.add_geometry(pcd1, reset_bounding_box=True)
vis.add_geometry(pcd2, reset_bounding_box=False)

ctr = vis.get_view_control()
ctr.set_zoom(0.8)
ctr.rotate(10.0, 0.0)

vis.run()
vis.destroy_window()

picked_points = vis.get_picked_points()

Current result: enter image description here

I wanted to be able to display two point clouds in a window at the same time, and to be able to select points with the mouse and print coordinates, but after adding the first geometry, the second one couldn't be displayed.

Desired result: enter image description here

If open3d actually can't do this, please tell me how to deal with this with some other graphic framework can solve it. Thanks a lot.

Upvotes: 1

Views: 37

Answers (1)

Rubens Benevides
Rubens Benevides

Reputation: 153

You can simply add the two point clouds together; the second will be drawn in the coordinate system of the first, but the coordinates will remain the same.

just replace:

vis.add_geometry(pcd1, reset_bounding_box=True)
vis.add_geometry(pcd2, reset_bounding_box=False)

by

vis.add_geometry(pcd1+pcd2, reset_bounding_box=True)

output (some points selected): enter image description here

Upvotes: 0

Related Questions