39 #ifndef PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_
40 #define PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_
42 #include <pcl/gpu/segmentation/gpu_extract_labeled_clusters.h>
44 template <
typename Po
intT>
void
48 std::vector<PointIndices> &clusters,
49 unsigned int min_pts_per_cluster,
50 unsigned int max_pts_per_cluster)
55 std::vector<bool> processed (host_cloud_->
size (),
false);
59 if(max_pts_per_cluster > host_cloud_->
size ())
60 max_answers =
static_cast<int> (host_cloud_->
size ());
62 max_answers = max_pts_per_cluster;
68 for (std::size_t i = 0; i < host_cloud_->
size (); ++i)
82 PointT t = (*host_cloud_)[i];
84 p.x = t.x; p.y = t.y; p.z = t.z;
91 r.
indices.push_back (
static_cast<int> (i));
93 unsigned int found_points =
static_cast<unsigned int> (queries_host.
size ());
94 unsigned int previous_found_points = 0;
99 while (previous_found_points < found_points)
102 queries_device.
upload(queries_host);
104 tree->radiusSearch(queries_device, tolerance, max_answers, result_device);
107 previous_found_points = found_points;
110 std::vector<int> sizes, data;
116 for(std::size_t qp = 0; qp < sizes.size (); qp++)
118 for(
int qp_r = 0; qp_r < sizes[qp]; qp_r++)
120 if(processed[data[qp_r + qp * max_answers]])
123 if((*host_cloud_)[i].label == (*host_cloud_)[data[qp_r + qp * max_answers]].label)
125 processed[data[qp_r + qp * max_answers]] =
true;
126 PointT t_l = (*host_cloud_)[data[qp_r + qp * max_answers]];
128 p_l.x = t_l.x; p_l.y = t_l.y; p_l.z = t_l.z;
131 r.
indices.push_back(data[qp_r + qp * max_answers]);
137 if (found_points >= min_pts_per_cluster && found_points <= max_pts_per_cluster)
144 clusters.push_back (r);
149 template <
typename Po
intT>
void
157 tree_->setCloud(input_);
159 if (!tree_->isBuilt())
171 extractLabeledEuclideanClusters<PointT> (host_cloud_, tree_, cluster_tolerance_, clusters, min_pts_per_cluster_, max_pts_per_cluster_);
177 #define PCL_INSTANTIATE_extractLabeledEuclideanClusters(T) template void PCL_EXPORTS pcl::gpu::extractLabeledEuclideanClusters<T> (const typename pcl::PointCloud<T>::Ptr &, const pcl::gpu::Octree::Ptr &,float, std::vector<PointIndices> &, unsigned int, unsigned int);
178 #define PCL_INSTANTIATE_EuclideanLabeledClusterExtraction(T) template class PCL_EXPORTS pcl::gpu::EuclideanLabeledClusterExtraction<T>;
179 #endif //PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_