点云-->mesh
print(1)
import trimesh
import open3d as o3d
import numpy as np
pcd = o3d.io.read_point_cloud("00010.ply")
radius = 0.001 # 搜索半径
max_nn = 30 # 邻域内用于估算法线的最大点数
pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius, max_nn)) # 执行法线估计
====open3d 点云转化为三角面.
poisson_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=12, width=0, scale=1.1, linear_fit=False)[0]
o3d.io.write_triangle_mesh("output_mesh.glb", poisson_mesh)
#radius determination
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 3 * avg_dist
#computing the mehs
bpa_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd,o3d.utility.DoubleVector([radius, radius * 2]))
#decimating the mesh
# dec_mesh = mesh.simplify_quadric_decimation(100000)
o3d.io.write_triangle_mesh("output_mesh2.glb", bpa_mesh)