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 (
size_t i = 0; i < host_cloud_->points.size (); ++i)
82 PointT t = host_cloud_->points[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(
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)
143 r.
header = host_cloud_->header;
144 clusters.push_back (r);
149 template <
typename Po
intT>
void 157 tree_->setCloud(input_);
159 if (!tree_->isBuilt())
177 #define PCL_INSTANTIATE_extractLabeledEuclideanClusters(T) template void PCL_EXPORTS pcl::gpu::extractLabeledEuclideanClusters (const boost::shared_ptr<pcl::PointCloud<T> > &, 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>; 183 #endif //PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_ boost::shared_ptr< Octree > Ptr
Types.
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
std::vector< int > indices
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
Octree implementation on GPU.
void extractLabeledEuclideanClusters(const boost::shared_ptr< pcl::PointCloud< PointT > > &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)
bool compareLabeledPointClusters(const pcl::PointIndices &a, const pcl::PointIndices &b)
Sort clusters method (for std::sort).
A point structure representing Euclidean xyz coordinates.
void download(T *host_ptr) const
Downloads data from internal buffer to CPU memory.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
A point structure representing Euclidean xyz coordinates, and the RGB color.
void upload(const T *host_ptr, size_t size)
Uploads data to internal buffer in GPU memory.
void extractLabeledEuclideanClusters(const PointCloud< PointT > &cloud, const boost::shared_ptr< search::Search< PointT > > &tree, float tolerance, std::vector< std::vector< PointIndices > > &labeled_clusters, unsigned int min_pts_per_cluster=1, unsigned int max_pts_per_cluster=std::numeric_limits< unsigned int >::max(), unsigned int max_label=std::numeric_limits< unsigned int >::max())
Decompose a region of space into clusters based on the Euclidean distance between points...