?write_ascii=true表示以ascii格式保存PLY文件否则是二进制保存
import time
import open3d as o3d;
import numpy as np;
x = np.linspace(-3, 3, 501)
mesh_x, mesh_y = np.meshgrid(x, x)
z = np.sinc((np.power(mesh_x, 2) + np.power(mesh_y, 2)))
z_norm = (z - z.min()) / (z.max() - z.min())
xyz = np.zeros((np.size(mesh_x), 3))
xyz[:, 0] = np.reshape(mesh_x, -1)
xyz[:, 1] = np.reshape(mesh_y, -1)
xyz[:, 2] = np.reshape(z_norm, -1)
print('xyz')
print(xyz)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
o3d.io.write_point_cloud("sync1.ply", pcd, write_ascii=True)
o3d.visualization.draw_geometries([pcd])
pcdsync = o3d.io.read_point_cloud("sync1.ply")
o3d.visualization.draw_geometries([pcdsync])