open3d-表面重建

为实现三角网格表面重建,open3d.geometry.TriangleMesh提供了多种方式。

class TriangleMesh(MeshBase):        
    # Alpha shapes                       
    def create_from_point_cloud_alpha_shape(self, *args, **kwargs):
    # Ball pivoting
    def create_from_point_cloud_ball_pivoting(self, pcd, radii):
    # Poisson
    def create_from_point_cloud_poisson(self, pcd, depth=8, width=0, scale=1.1, linear_fit=False, n_threads=-1):

    ...
import open3d as o3d
import numpy as np
from open3d.web_visualizer import draw
from open3d.visualization import draw_geometries
pcd = o3d.io.read_point_cloud('./datas/sphere.ply')
pcd.paint_uniform_color([1, 0, 0])
print(pcd)
-> PointCloud with 642 points.
draw(pcd)
mesh1 = o3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape(pcd, 25)
mesh1.compute_vertex_normals()
mesh1.paint_uniform_color([0.5, 0.5, 0.5])
print(mesh1)
-> TriangleMesh with 642 points and 1424 triangles.
draw([mesh1, pcd])
radii = [20, 15, 10]
pcd.estimate_normals()
pcd.orient_normals_consistent_tangent_plane(1)
# draw_geometries([pcd])
mesh2 = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd, o3d.utility.DoubleVector(radii))
mesh2.compute_vertex_normals()
mesh2.paint_uniform_color([0.5, 0.5, 0.5])
print(mesh2)
-> TriangleMesh with 642 points and 1280 triangles.
draw([mesh2, pcd])
mesh3, densities3 = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd)
mesh3.compute_vertex_normals()
mesh3.paint_uniform_color([0.5, 0.5, 0.5])
print(mesh3)
-> TriangleMesh with 3990 points and 7976 triangles.
print(np.asarray(densities3).shape)
-> (3990,)

draw([mesh3, pcd])