Write PCD Files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Write PCD Files

nomoore
I'm having trouble saving a point cloud as a pcd file. My code it as follows:

pcl::PointCloud<pcl::PointXYZI>::ConstPtr cloud;

//Generate cloud

pcl::PCDWriter writer;
writer->write<pcl::PointXYZI> (pcd_filename, *cloud);
writer->write(pcd_filename, cloud);

The problem I am having is that writer->write() triggers an assert every
time I call it. I believe that is because my declaration of cloud is
incongruous with the write() function's expected inputs. I'm simply unsure
of how to align them properly. I have tried declaring the writer a few
different ways as well as type casting, or creating new clouds to use an
intermediaries. Most recently I've tried:

boost::shared_ptr<pcl::PCDWriter> writer;

pcl::PCLPointCloud2::ConstPtr cloud2;
cloud2 = cloud;

writer->write(pcd_filename, cloud2);

The program exits with code 3. I'd appreciate it if someone could tell me
how to properly typecast or declare my point cloud or how call the write
function. Thank you much!



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Write PCD Files

nomoore
I got it solved. My initial setup worked fine.

pcl::PointCloud<PointType>::ConstPtr cloud;

//Capture cloud

pcl::PCDWriter writer;
writer.write<PointXYZI> (pcd_filename, *cloud, true);

Apparently I was failing to capture data for the first few frames so my
point clouds were initialized to null and it seems the writer didn't like
that. So, I have to wait a few frames before writing a file.

I hope someone finds this helpful.



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users