Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create point cloud file(.ply) from vertices stored as numpy array?

I have some vertices whose coordinates were stored as NumPy array.

xyz_np:

array([[  7,  53,  31],
       [ 61, 130, 116],
       [ 89,  65, 120],
       ...,
       [ 28,  72,  88],
       [ 77,  65,  82],
       [117,  90,  72]], dtype=int32)

I want to save these vertices as a point cloud file(such as .ply) and visualize it in Blender.

I don't have face information.

like image 513
Ausrada404 Avatar asked Feb 07 '26 18:02

Ausrada404


1 Answers

You can use Open3D to do this.

# Pass numpy array to Open3D.o3d.geometry.PointCloud and visualize
xyz = np.random.rand(100, 3)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
o3d.io.write_point_cloud("./data.ply", pcd)

You can also visualize the point cloud using Open3D.

o3d.visualization.draw_geometries([pcd])
like image 182
Jing Zhao Avatar answered Feb 09 '26 09:02

Jing Zhao