today I have started with Open3D and I don't really know how to display more than one Geometry object in one scene/window.
When I run my code I have two different and separate windows(first with point cloud, second with lines). How should I use visualization.draw_geometries to display them two in one scene?
xyz = np.genfromtxt('file.csv', delimiter=',')
print (xyz)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
print(np.asarray(pcd.points))
o3d.visualization.draw_geometries_with_editing([pcd])
choosen_points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 1], [1, 0, 1],
[0, 1, 1], [1, 1, 1]]
lines = [[0, 1], [0, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 7], [6, 7],
[0, 4], [1, 5], [2, 6], [3, 7]]
colors = [[1, 0, 0] for i in range(len(lines))]
line_set = o3d.geometry.LineSet()
line_set.points = o3d.utility.Vector3dVector(choosen_points)
line_set.lines = o3d.utility.Vector2iVector(lines)
line_set.colors = o3d.utility.Vector3dVector(colors)
o3d.visualization.draw_geometries([line_set])
o3d.visualization.draw_geometries expects a list of geometries as an argument. You are currently calling the function twice, which results in two windows opening. To simultaneously draw both geometries, you just need to combine them in a single list, like so:
o3d.visualization.draw_geometries([pcd, line_set])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With