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

21k views Asked by At

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.

1

There are 1 answers

2
Jing Zhao On BEST ANSWER

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])