在进行PCL学习的过程中,最常见的点云类型就是pcl::PointCloud < pcl::PointXYZ >,随着不断学习,又遇到了pcl::PCLPointCloud2::Ptr这种点云的类型,因此弄清两者的转换关系十分有必要。
PCL中有两个函数直接解决了两者的转换关系:
1.pcl::fromPCLPointCloud2()
2.pcl::toPCLPointCloud2()
下面直接看一段代码:
//====================================================================
pcl::PCLPointCloud2::Ptr cloud_blob(new pcl::PCLPointCloud2),
cloud_filtered_blob(new pcl::PCLPointCloud2);//申明滤波前后的点云
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>),
pcl::PLYReader reader;
reader.read("hand.ply", *cloud_