Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save pcl::PointCloud<pcl::PointXYZRGB> in format compatible with Meshlab

Is there any function in PCL library to save pcl::PointCloud<pcl::PointXYZRGB> point cloud in format XYZRGB that can be opened with Meshlab?

Seems pcl::io::savePCDFileASCII (filename, cloud); stores RGB values in some specific way.

like image 220
mrgloom Avatar asked Jun 09 '16 09:06

mrgloom


2 Answers

For me it works, if I store it as PLY file in binary format. It seems as if Meshlab is having some troubles with ASCII files occasionally. Here is what works for me.

pcl::PointCloud<pcl::PointXYZRGB>::Ptr sceneCloud(new pcl::PointCloud<pcl::PointXYZRGB>);
//Fill cloud somehow...

std::string writePath = "your/path";
pcl::io::savePLYFileBinary(writePath, *sceneCloudPtr);
like image 140
Tukk Avatar answered Sep 21 '22 00:09

Tukk


You can convert to .ply, .obj or any other supported format. Have a look to the demo pcd2ply in the PCL, or just use pcl::PLYWriter setting up the parameters depending on your needs:

 pcl::PLYWriter writer;
 writer.write (filename, cloud, Eigen::Vector4f::Zero (),
               Eigen::Quaternionf::Identity (), binary, use_camera);
like image 35
Finfa811 Avatar answered Sep 23 '22 00:09

Finfa811