Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Converting from an .stl file to .ply or .pcd file

Open coolinfan20 opened this issue 7 years ago • 3 comments

Hi,

How would I convert an STL file to a point cloud file (either .pcd or .ply file)? I have tried reading the STL file as a mesh file and then using the following code to try to convert it to a point cloud, but this does not work.

Using the python package numpy-stl, I did the following to read the mesh: your_mesh = mesh.Mesh.from_file("/../../Open3D/examples/Python/Basic/Dog.stl")

and then your source code: pcd = PointCloud() pcd.points = Vector3dVector(your_mesh) write_point_cloud("../../TestData/test_dog.ply", pcd) pcd_load = read_point_cloud("../../TestData/test_dog.ply") draw_geometries([pcd_load])

but it isn't able to execute the draw_geometries function. Is there another way to import and convert an stl file into a pcd or ply file?

Thanks!

coolinfan20 avatar Mar 09 '19 00:03 coolinfan20

Hi, you can install openmesh Framwork to solved your Problem.

import openmesh as om

mesh = om.TriMesh() om.read_mesh(mesh, source_file.stl) om.write_mesh(mesh, output_file.ply)

mzahirulj avatar Apr 08 '19 09:04 mzahirulj

Hey does anyone know how to convert a .ply to .pcd

oseh avatar Jan 02 '20 22:01 oseh

I tried this and it worked, if you want to convert triangular mesh to point cloud

import open3d as o3d

mesh = o3d.io.read_triangle_mesh("file.stl")
pointcloud = mesh.sample_points_poisson_disk(100000)

# you can plot and check
o3d.visualization.draw_geometries([mesh])
o3d.visualization.draw_geometries([pointcloud])

tanayag avatar May 14 '20 19:05 tanayag