博客新址: http://blog.xuezhisd.top
邮箱:xuezhisd@126.com
PCL系列
- PCL系列——读入PCD格式文件操作
- PCL系列——将点云数据写入PCD格式文件
- PCL系列——拼接两个点云
- PCL系列——从深度图像(RangeImage)中提取NARF关键点
- PCL系列——如何可视化深度图像
- PCL系列——如何使用迭代最近点法(ICP)配准
- PCL系列——如何逐渐地配准一对点云
- PCL系列——三维重构之泊松重构
- PCL系列——三维重构之贪婪三角投影算法
- PCL系列——三维重构之移动立方体算法
操作
- 在VS2010 中新建一个文件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;
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);
}
- 运行结束后,在项目目录下生成test_pcd.pcd文件,内容如下图所示。
参考
Writing Point Cloud data to PCD files
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)