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> 42 template<
typename Po
intT>
void 47 if (extract_removed_clusters_)
49 small_clusters_->clear ();
50 large_clusters_->clear ();
54 if (!initCompute () || input_->points.empty () || indices_->empty () || !condition_function_)
60 if (input_->isOrganized ())
65 searcher_->setInputCloud (input_, indices_);
68 std::vector<int> nn_indices;
69 std::vector<float> nn_distances;
73 std::vector<bool> processed (input_->points.size (),
false);
76 for (
int iii = 0; iii < static_cast<int> (indices_->size ()); ++iii)
79 if ((*indices_)[iii] == -1 || processed[(*indices_)[iii]])
83 std::vector<int> current_cluster;
87 current_cluster.push_back ((*indices_)[iii]);
88 processed[(*indices_)[iii]] =
true;
91 while (cii < static_cast<int> (current_cluster.size ()))
94 if (searcher_->radiusSearch (input_->points[current_cluster[cii]], cluster_tolerance_, nn_indices, nn_distances) < 1)
101 for (
int nii = 1; nii < static_cast<int> (nn_indices.size ()); ++nii)
104 if (nn_indices[nii] == -1 || processed[nn_indices[nii]])
108 if (condition_function_ (input_->points[current_cluster[cii]], input_->points[nn_indices[nii]], nn_distances[nii]))
111 current_cluster.push_back (nn_indices[nii]);
112 processed[nn_indices[nii]] =
true;
119 if (extract_removed_clusters_ ||
120 (static_cast<int> (current_cluster.size ()) >= min_cluster_size_ &&
121 static_cast<int> (current_cluster.size ()) <= max_cluster_size_))
124 pi.
header = input_->header;
125 pi.
indices.resize (current_cluster.size ());
126 for (
int ii = 0; ii < static_cast<int> (current_cluster.size ()); ++ii)
127 pi.
indices[ii] = current_cluster[ii];
129 if (extract_removed_clusters_ && static_cast<int> (current_cluster.size ()) < min_cluster_size_)
130 small_clusters_->push_back (pi);
131 else if (extract_removed_clusters_ && static_cast<int> (current_cluster.size ()) > max_cluster_size_)
132 large_clusters_->push_back (pi);
134 clusters.push_back (pi);
141 #define PCL_INSTANTIATE_ConditionalEuclideanClustering(T) template class PCL_EXPORTS pcl::ConditionalEuclideanClustering<T>; 143 #endif // PCL_SEGMENTATION_IMPL_CONDITIONAL_EUCLIDEAN_CLUSTERING_HPP_
void segment(IndicesClusters &clusters)
Segment the input into separate clusters.
std::vector< int > indices
OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds...
std::vector< pcl::PointIndices > IndicesClusters