点云学习2:写入PCD文件
#include<iostream>#include<pcl/io/pcd_io.h>#include<pcl/point_types.h>int main(){pcl::PointCloud<pcl::PointXYZ> cloud;cloud.width = 5;cloud.height = 1;cloud.is_dense = false;cl
·
#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/point_types.h>
int main()
{
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 = 1000 * rand() / (RAND_MAX + 1.0);
cloud.points[i].y = 1000 * rand() / (RAND_MAX + 1.0);
cloud.points[i].z = 1000 * rand() / (RAND_MAX + 1.0);
}
pcl::io::savePCDFileASCII("my_test_pcd_input", cloud);
std::cerr << "Saved " << cloud.points.size() << std::endl;
for (size_t i = 0; i < cloud.points.size(); ++i)
{
std::cout << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
}
system("pause");
return 0;
}
这里值得一说的就是这个随机生成数据的地方
cloud.points[i].x = 1000 * rand() / (RAND_MAX + 1.0);
cloud.points[i].y = 1000 * rand() / (RAND_MAX + 1.0);
cloud.points[i].z = 1000 * rand() / (RAND_MAX + 1.0);
更多推荐
已为社区贡献1条内容
所有评论(0)