PCL 不同类型的点云之间进行类型转换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38446366/article/details/82655712

 

可以使用PCL里面现成的函数pcl::copyPointCloud()

#include <pcl/common/impl/io.h>

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz (new pcl::PointCloud<pcl::PointXYZ> ());  
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_xyzrgba (new pcl::PointCloud<pcl::PointXYZRGBA> ());
    pcl::copyPointCloud(*cloud_xyz, *cloud_xyzrgba);

函数原型:

PCL_EXPORTS void   copyPointCloud (const pcl::PCLPointCloud2 &cloud_in,   pcl::PCLPointCloud2 &cloud_out);

或者手动转换:

cloud_xyzrgba->points.resize(cloud_xyz->size());
for (size_t i = 0; i < cloud_xyz->points.size(); i++) {
    cloud_xyzrgb->points[i].x = cloud_xyz->points[i].x;
    cloud_xyzrgb->points[i].y = cloud_xyz->points[i].y;
    cloud_xyzrgb->points[i].z = cloud_xyz->points[i].z;
}

猜你喜欢

转载自blog.csdn.net/qq_38446366/article/details/82655712