基于pcl库写一段有多少次循环就创建多少个pclPointIndices容器的c++代码
#include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl/segmentation/extract_clusters.h>
int main() { // 创建点云数据 pcl::PointCloudpcl::PointXYZ::Ptr cloud(new pcl::PointCloudpcl::PointXYZ); // 设置点云数据
// 创建聚类对象
pcl::EuclideanClusterExtraction<pcl::PointXYZ> ec;
ec.setInputCloud(cloud);
// 设置聚类参数
// 定义容器,用于存储聚类结果
std::vector<pcl::PointIndices> cluster_indices;
// 循环创建pcl::PointIndices容器
for (int i = 0; i < num_iterations; ++i)
{
// 聚类
ec.extract(cluster_indices);
// 输出聚类结果
for (const auto& indices : cluster_indices)
{
std::cout << "Cluster with " << indices.indices.size() << " points" << std::endl;
}
}
return 0;
原文地址: http://www.cveoy.top/t/topic/h9D3 著作权归作者所有。请勿转载和采集!