STL 到点云

STL to pointcloud

我正在尝试使用 open3d 库将 stl 文件转换为点。

mesh = o3d.io.read_triangle_mesh("./stl.stl")
pcd = o3d.geometry.PointCloud()
pcd.points = mesh.vertices
pcd.colors = mesh.vertex_colors
pcd.normals = mesh.vertex_normals

问题是需要加载 mesh.surfaces 而不是顶点,但我看不到 open3d.open3d.geometry.TriangleMesh.Surface 对象。我需要对齐曲面而不是顶点。

如何从三角网格中获取点?

Input

Output

这可能有帮助:

open3d.geometry.sample_points_uniformly(input, number_of_points=100)

    Function to uniformly sample points from the mesh.

    Parameters
            input (open3d.geometry.TriangleMesh) – The input triangle mesh.
            number_of_points (int, optional, default=100) – Number of points that should be uniformly sampled.

    Returns
        open3d.geometry.PointCloud