点云数据保存为pcd文件_pcd_write.cpp
Posted 人,唯一剥夺不了的,只有知识
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了点云数据保存为pcd文件_pcd_write.cpp相关的知识,希望对你有一定的参考价值。
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
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::savePCDFileASCII ("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
for (size_t i = 0; i < cloud.points.size (); ++i)
std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
return (0);
}
以上是关于点云数据保存为pcd文件_pcd_write.cpp的主要内容,如果未能解决你的问题,请参考以下文章
点云配准 8-pcd与ply文件转换以及数据保存格式:ascll 和二进制转换