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

3

7

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.

Lanai answered 9/6, 2016 at 9:12 Comment(0)
C
9

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);
Contemn answered 22/5, 2017 at 12:47 Comment(2)
Worked for me. savePLYFileBinary is defined in pcl/io/ply_io.h that I had to include.Tittup
Would be nice, if you could mark it as the answer ;)Contemn
P
1

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);
Precautious answered 10/6, 2016 at 6:56 Comment(0)
I
0

For anyone who might have the same question, note that PLY files may or may not be fully formed e.g. it may or may not have normals or triangle indices.

Furthermore the data may not be in an expected order e.g. normals may come after RGB color or before.

I have found that PCL does not handle this well. I've used VCG Library instead. If you still need to use PCL then include both libraries but read in with VCG Lib and populate then PCL data structure.

Ionization answered 11/1 at 16:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.