tangjikededela
tangjikededela

Reputation: 41

Can I select multiple random points from .obj file by Python and Open3D

What should I do if I want to pick up some random point from .obj file by Open3D.

I test that I can read file by

import open3d as o3d

print("Testing IO for textured meshes ...")
textured_mesh = o3d.io.read_triangle_mesh("../pikaqiu.obj")
print(textured_mesh)
mesh = o3d.geometry.TriangleMesh()

but how can I choose a point from the file?

Upvotes: 0

Views: 768

Answers (1)

Kaustubh Shrotri
Kaustubh Shrotri

Reputation: 13

First, you can visualize the mech byopen3d.visualization.draw_geometries_with_editing(). Then, after the window appears, you can select points by Shift+Left Mouse Click. If you want to deselect, then Shift+Right Mouse Click. After you are done selecting the points, press Q or Esc to close the window. get_picked_points() will return you indices of multiple points you selected.

import open3d as o3d
textured_mesh = o3d.io.read_triangle_mesh("../pikaqiu.obj")
vis = o3d.visualization.draw_geometries_with_editing()
vis.create_window()
vis.add_geometry(textured_mesh)
vis.run()  # user picks points
vis.destroy_window()
vis.get_picked_points()

You can get the points from the array of the mesh

mesh_array = np.asarray(pcd.points)
points = mesh_array[vis.get_picked_points()]

Upvotes: 0

Related Questions