【发布时间】:2016-02-29 19:46:18
【问题描述】:
我正在使用点云库,在过滤点云并使用欧几里得聚类提取进行分割后,我正在提取第一个聚类的点。以下代码是我认为可能用于提取集群点的代码:
std::vector<pcl::PointIndices> cluster_indices;
typename pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT>);
tree->setInputCloud(out_cloud);
pcl::EuclideanClusterExtraction<PointT> ec;
ec.setClusterTolerance(2 * 0.06);
ec.setMinClusterSize(50);
ec.setMaxClusterSize(1200);
ec.setSearchMethod(tree);
ec.setInputCloud(filtered_cloud);
ec.extract(cluster_indices);
int j = cluster_indices.size();
tam_cluster = cluster_indices[0].indices.size();
int ind_tmp;
for (int n=0; n<tam_cluster; n++){
ind_tmp=cluster_indices[0].indices[n];
first_clust->points.push_back (filtered_cloud->points[ind_tmp]);
}
std::cout << " ** Number of points of first cluster : " << first_clust->size() <<std::endl;
所以,我不知道为什么,但有时我会得到一个超过 1200 点的集群。我认为这可能是由于 pcl 在提取集群中的实现。
这段代码正确吗?
【问题讨论】:
-
typename是干什么用的? -
抱歉,我忘了更改那行代码,所以它只是:pcl::search::KdTree
::Ptr tree (new pcl::search::KdTree );树->setInputCloud(filtered_cloud);
标签: c++ point-cloud-library point-clouds