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

How to convert stl/ply files to pcd files? no 'vtkPolyDataToPointCloud' function in pclpy.pcl.io #94

Open
CarrotC opened this issue Aug 3, 2021 · 0 comments

Comments

@CarrotC
Copy link

CarrotC commented Aug 3, 2021

I want to sample CAD models in stl format, and find that stl can be convert to pcd files with pcl.
There is code in c++:

	//read CAD model in stl format
	vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
	reader->SetFileName("T0-2.stl");
	reader->Update();
	//convert to ply format
	vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
	polyData = reader->GetOutput();
	polyData->GetNumberOfPoints();
	pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>());
	//ply to pcd
	pcl::io::vtkPolyDataToPointCloud(polyData, *cloud);
	//show point cloud
	pcl::visualization::PCLVisualizer visual("stl2pcd");
	visual.setBackgroundColor(255, 255, 255);
	visual.addPointCloud(cloud, "input_cloud");
	visual.spin();
	//save pcd file
	pcl::io::savePCDFileASCII("stl2pcd.pcd", *cloud);

When I rewrite these code in python with pclpy, I meet a problem that there is pcl::io::vtkPolyDataToPointCloud(polyData, *cloud); in c++ code, but there is no vtkPolyDataToPointCloud function or sth like this in pclpy.pcl.io.
Is it a bug or is there other parts in pclpy that can get the same result?

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

No branches or pull requests

1 participant