1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > PCL——向PCD文件写入点云数据

PCL——向PCD文件写入点云数据

时间:2021-08-12 06:26:19

相关推荐

PCL——向PCD文件写入点云数据

向PCD文件写入点云数据

1. 例程代码

1. 例程代码

以下代码均来源于PCL的官方教程,pcd_write.cpp:我使用的是VS编译

https://pcl.readthedocs.io/projects/tutorials/en/master/writing_pcd.html#writing-pcdpcd_write.cpp

#include <iostream>#include <pcl/io/pcd_io.h>//PCD I/O operations#include <pcl/point_types.h>//several point type structuresint main(){pcl::PointCloud<pcl::PointXYZ> cloud;// Fill in the cloud datacloud.width = 5;cloud.height = 1;cloud.is_dense = false;cloud.resize(cloud.width * cloud.height);//fill in the PointCloud structure with random point valuesfor (auto& point : cloud){point.x = 1024 * rand() / (RAND_MAX + 1.0f);point.y = 1024 * rand() / (RAND_MAX + 1.0f);point.z = 1024 * rand() / (RAND_MAX + 1.0f);}//保存PCD文件操作pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);std::cerr << "Saved " << cloud.size() << " data points to test_pcd.pcd." << std::endl;for (const auto& point : cloud)std::cerr << " " << point.x << " " << point.y << " " << point.z << std::endl;system("Pause");return (0);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。