1.7-savingPNG
介绍
PCL提供了将点云的值保存到PNG图像文件的可能性。这只能用有有序的云来完成,因为结果图像的行和列将与云中的行和列完全对应。例如,如果您从类似Kinect或Xtion的传感器中获取了点云,则可以使用它来检索与该云匹配的640x480 RGB图像。
代码详情
#include <pcl / io / pcd_io.h>
#include <pcl / io / png_io.h>
int
main (int argc , char ** argv )
{
//用于存储点云的对象。
pcl :: PointCloud < pcl :: PointXYZRGB > :: Ptr 云(新 pcl :: PointCloud < pcl :: PointXYZRGB > );
//从磁盘读取PCD文件。
if(PCL :: IO :: loadPCDFile < PCL :: PointXYZRGB > (的argv [ 1 ], * 云) =! 0 )
{
return- 1 ;
}
//保存图像(必须为有序点云)。
pcl :: io :: savePNGFile (“output.png” , *cloud , “rgb” );
}
函数详解
savePNGFile()源码
pcl :: io :: savePNGFile (“output.png” , *cloud );
获取点云所有点的RGB信息,然后使用函数saveRgbPNGFile(file_name, &data[0], cloud.width, cloud.height)恢复到图片。
void
savePNGFile (const std::string& file_name, const pcl::PointCloud<T