#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 = 2;
cloud.is_dense = true;
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);
}
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;
}
std::cout << " " << std::endl;
cloud.width = 5;
cloud.height = 2;
for (size_t h = 0; h < cloud.height; ++h)
{
for (size_t w = 0; w < cloud.width; ++w)
{
std::cout << cloud.at(w, h).x <<" : "<< cloud.at(w, h).y << " : " << cloud.at(w, h).z << std::endl;; // 正确
}
}
system("pause");
return(0);
}
09-26
318