Search code examples
pythonmeshpoint-cloudsopen3d

STL to pointcloud


i am trying to convert stl file into points using open3d lib.

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

The problem is that in need to load mesh.surfaces instead vertices but i cant see open3d.open3d.geometry.TriangleMesh.Surface object. I need to align surfaces instead of vertices.

How do I obtain points from triangular mesh?

Input

Output


Solution

  • This might help:

    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