Open3D 点云三角面化
import open3d as o3d
import numpy as np
import trimesh
pcd = o3d.io.read_point_cloud("D:/program/PCL_1_9_1/share/doc/pcl-1.9/tutorials/sources/alignment_prerejective/chef.pcd")
pcd.estimate_normals()
# estimate radius for rolling ball
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist
mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(
pcd,
o3d.utility.DoubleVector([radius, radius * 2]))
print(mesh.get_surface_area())
o3d.visualization.draw_geometries([mesh], window_name='Open3D downSample', width=800, height=600, left=50,
top=50, point_show_normal=True, mesh_show_wireframe=True, mesh_show_back_face=True,)
# create the triangular mesh with the vertices and faces from open3d
tri_mesh = trimesh.Trimesh(np.asarray(mesh.vertices), np.asarray(mesh.triangles),
vertex_normals=np.asarray(mesh.vertex_normals))
trimesh.convex.is_convex(tri_mesh)
mesh计算:mesh =o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd, o3d.utility.DoubleVector([radius, radius * 2]))
计算表面积:mesh.get_surface_area()
转载:https://www.coder.work/article/4906341
最近对物体mesh计算表面积,遇到了点问题——发现计算不准
调查了一下:
参考CGAL官方(https://www.cgal.org/)mesh过程
- 点云预处理(滤波,平滑,法向量)
- 表面重建(mesh)
- 后处理(补洞,hold filling;重网格,remeshing)
所以,不能只用一次mesh化就开始计算
此外,不同的方法mesh均有一些问题,比如:空洞和重复的网格
open3d有网格聚类,网格简化,网格加密、网格化、网格变形等方法
pyvista也有和CGAL类似的方法,CGAL-binding(python)的暂时还未实现此功能
还有比较好用的就是pclpy,pcl python版,貌似实现了绝大多数功能