conversion from pcl::PointCloud<pcl::PointXYZ> to pcl::PCLPointCloud2

asked 2021-10-25 20:24:19 -0500

santK gravatar image

updated 2021-10-26 02:05:20 -0500

gvdhoorn gravatar image

Hello I try to convert from pcl::PointCloud<pcl::PointXYZ> to pcl::PCLPointCloud2 But the conversion returns an empty point cloud.

This is my code:

pcl::PCLPointCloud2 cloud_inliers_pcl2;
pcl::toPCLPointCloud2(cloud_inliers, cloud_inliers_pcl2);

I can print out the cloud "cloud_inliers" which is in the pcl::PointCloud<pcl::PointXYZ>

But the pcl::PCLPointCloud2 returns empty fields

edit retag flag offensive close merge delete


Pls take a look at this answer:

osilva gravatar image osilva  ( 2021-10-26 20:52:23 -0500 )edit

Hello, Thank you. I referred that in the beginning of my code to convert from pcl::PCLPointCloud2 to pcl::PointCloud<pcl::pointxyz> And it worked. But now I need to convert back to pcl::PCLPointCloud2 I use the method pcl::toPCLPointCloud2 with 1st argument as cloud_inliers which is pcl::PointCloud<pcl::pointxyz> and second argument as cloud_inliers_pcl2 which is pcl::PointCloud<pcl::pointxyz>

santK gravatar image santK  ( 2021-10-27 07:59:48 -0500 )edit

Thank you for the clarification

osilva gravatar image osilva  ( 2021-10-27 11:03:59 -0500 )edit