37 #ifndef PCL_SEGMENTATION_IMPL_CONDITIONAL_EUCLIDEAN_CLUSTERING_HPP_
38 #define PCL_SEGMENTATION_IMPL_CONDITIONAL_EUCLIDEAN_CLUSTERING_HPP_
40 #include <pcl/segmentation/conditional_euclidean_clustering.h>
41 #include <pcl/search/auto.h>
43 template<
typename Po
intT>
void
48 if (extract_removed_clusters_)
50 small_clusters_->clear ();
51 large_clusters_->clear ();
55 if (!initCompute () || input_->points.empty () || indices_->empty () || !condition_function_)
65 searcher_->setInputCloud (input_, indices_);
68 const int nn_start_idx = searcher_->getSortedResults () ? 1 : 0;
72 std::vector<float> nn_distances;
76 std::vector<bool> processed (input_->size (),
false);
79 for (
const auto& iindex : (*indices_))
82 if (iindex == UNAVAILABLE || processed[iindex])
90 current_cluster.push_back (iindex);
91 processed[iindex] =
true;
94 while (cii <
static_cast<int> (current_cluster.size ()))
97 if (searcher_->radiusSearch ((*input_)[current_cluster[cii]], cluster_tolerance_, nn_indices, nn_distances) < 1)
104 for (
int nii = nn_start_idx; nii < static_cast<int> (nn_indices.size ()); ++nii)
107 if (nn_indices[nii] == UNAVAILABLE || processed[nn_indices[nii]])
111 if (condition_function_ ((*input_)[current_cluster[cii]], (*input_)[nn_indices[nii]], nn_distances[nii]))
114 current_cluster.push_back (nn_indices[nii]);
115 processed[nn_indices[nii]] =
true;
122 if (extract_removed_clusters_ ||
123 (
static_cast<int> (current_cluster.size ()) >= min_cluster_size_ &&
124 static_cast<int> (current_cluster.size ()) <= max_cluster_size_))
127 pi.
header = input_->header;
128 pi.
indices.resize (current_cluster.size ());
129 for (
int ii = 0; ii < static_cast<int> (current_cluster.size ()); ++ii)
130 pi.
indices[ii] = current_cluster[ii];
132 if (extract_removed_clusters_ &&
static_cast<int> (current_cluster.size ()) < min_cluster_size_)
133 small_clusters_->push_back (pi);
134 else if (extract_removed_clusters_ &&
static_cast<int> (current_cluster.size ()) > max_cluster_size_)
135 large_clusters_->push_back (pi);
137 clusters.push_back (pi);
144 #define PCL_INSTANTIATE_ConditionalEuclideanClustering(T) template class PCL_EXPORTS pcl::ConditionalEuclideanClustering<T>;
void segment(IndicesClusters &clusters)
Segment the input into separate clusters.
@ radius_search
The search method will mainly be used for radiusSearch.
IndicesAllocator<> Indices
Type used for indices in PCL.
std::vector< pcl::PointIndices > IndicesClusters