pclpy
pclpy copied to clipboard
How to convert stl/ply files to pcd files? no 'vtkPolyDataToPointCloud' function in pclpy.pcl.io
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?