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_->
points.size (),
false);
59 if(max_pts_per_cluster > host_cloud_->
points.size ())
60 max_answers = static_cast<int> (host_cloud_->
points.size ());
62 max_answers = max_pts_per_cluster;
68 for (std::size_t i = 0; i < host_cloud_->
points.size (); ++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_->
points[i].label == host_cloud_->
points[data[qp_r + qp * max_answers]].label)
125 processed[data[qp_r + qp * max_answers]] =
true;
126 PointT t_l = host_cloud_->
points[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_
void upload(const T *host_ptr, std::size_t size)
Uploads data to internal buffer in GPU memory.
void download(T *host_ptr) const
Downloads data from internal buffer to CPU memory.
Octree implementation on GPU.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
shared_ptr< Octree > Ptr
Types.
bool compareLabeledPointClusters(const pcl::PointIndices &a, const pcl::PointIndices &b)
Sort clusters method (for std::sort).
shared_ptr< PointCloud< PointT > > Ptr
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
A point structure representing Euclidean xyz coordinates.
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
void extractLabeledEuclideanClusters(const typename pcl::PointCloud< PointT >::Ptr &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, std::vector< PointIndices > &clusters, unsigned int min_pts_per_cluster, unsigned int max_pts_per_cluster)
A point structure representing Euclidean xyz coordinates, and the RGB color.
pcl::PCLHeader header
The point cloud header.