Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
coolinfan20 opened this issue Mar 9, 2019 · 3 comments
Closed

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

coolinfan20 opened this issue Mar 9, 2019 · 3 comments
Labels

Comments

@coolinfan20
Copy link

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!

@mzahirulj
Copy link

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)

@oseh
Copy link

oseh commented Jan 2, 2020

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

@tanayag
Copy link

tanayag commented May 14, 2020

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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants