PCL:将点云写入PCD文件中

#include 
#include 
#include 

int main(int argc, char **argv) {

    pcl::PointCloud::PointXYZ>::Ptr cloud (new  pcl::PointCloud::PointXYZ>);
    cloud->width = 100;
    cloud->height = 1;
    cloud->points.resize(cloud->width * cloud->height);
    for (size_t i = 0; i < cloud->points.size(); ++i)
    {
      cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
      cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
      cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
    }

    pcl::io::savePCDFile::PointXYZ>("../write.pcd", *cloud);
    return 0;
}

这个还是挺简单的,可以在终端中用cat命令输出文件内容,可以看到具体的格式如下图所示,包括版本号,区域,尺寸,具体就不一一解释啦!

PCL:将点云写入PCD文件中_第1张图片

你可能感兴趣的:(SLAM)