40 #include <pcl/common/copy_point.h>
41 #include <pcl/gpu/segmentation/gpu_extract_clusters.h>
50 std::size_t buffer_size,
55 template <
typename Po
intT>
61 std::vector<PointIndices>& clusters,
62 unsigned int min_pts_per_cluster,
63 unsigned int max_pts_per_cluster)
68 PCL_DEBUG(
"[pcl::gpu::extractEuclideanClusters]\n");
69 std::vector<bool> processed(host_cloud_->
size(),
false);
73 if (max_pts_per_cluster > host_cloud_->
size())
74 max_answers = host_cloud_->
size();
76 max_answers = max_pts_per_cluster;
77 PCL_DEBUG(
"Max_answers: %i\n", max_answers);
83 queries_device_buffer.
create(max_answers);
88 for (std::size_t i = 0; i < host_cloud_->
size(); ++i) {
111 unsigned int found_points = queries_host.
size();
112 unsigned int previous_found_points = 0;
120 if (queries_host.
size() <=
124 for (std::size_t p = 0; p < queries_host.
size(); p++) {
127 tree->radiusSearchHost(queries_host[p], tolerance, cpu_tmp, max_answers);
128 std::copy(cpu_tmp.begin(), cpu_tmp.end(), std::back_inserter(data));
139 queries_device.
upload(queries_host);
141 tree->radiusSearch(queries_device, tolerance, max_answers, result_device);
147 previous_found_points = found_points;
149 queries_host.
clear();
151 if (data.size() == 1)
155 for (
auto idx : data) {
158 processed[idx] =
true;
165 PCL_DEBUG(
" data.size: %i, foundpoints: %i, previous: %i",
168 previous_found_points);
169 PCL_DEBUG(
" new points: %i, next queries size: %i\n",
170 found_points - previous_found_points,
171 queries_host.
size());
172 }
while (previous_found_points < found_points);
174 if (found_points >= min_pts_per_cluster && found_points <= max_pts_per_cluster) {
181 clusters.push_back(r);
186 template <
typename Po
intT>
189 std::vector<pcl::PointIndices>& clusters)
197 tree_.setCloud(input_);
200 if (!tree_->isBuilt()) {
211 extractEuclideanClusters<PointT>(host_cloud_,
215 min_pts_per_cluster_,
216 max_pts_per_cluster_);
217 PCL_DEBUG(
"INFO: end of extractEuclideanClusters\n");
222 #define PCL_INSTANTIATE_extractEuclideanClusters(T) \
223 template void PCL_EXPORTS pcl::gpu::extractEuclideanClusters<T>( \
224 const typename pcl::PointCloud<T>::Ptr&, \
225 const pcl::gpu::Octree::Ptr&, \
227 std::vector<PointIndices>&, \
230 #define PCL_INSTANTIATE_EuclideanClusterExtraction(T) \
231 template class PCL_EXPORTS pcl::gpu::EuclideanClusterExtraction<T>;
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
pcl::PCLHeader header
The point cloud header.
void clear()
Removes all points in a cloud and sets the width and height to 0.
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
shared_ptr< PointCloud< PointT > > Ptr
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.
void create(std::size_t size)
Allocates internal buffer in GPU memory.
T * ptr()
Returns pointer for internal buffer in GPU memory.
shared_ptr< Octree > Ptr
Types.
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.
void economical_download(const pcl::gpu::NeighborIndices &source_indices, const pcl::Indices &buffer_indices, std::size_t buffer_size, pcl::Indices &downloaded_indices)
void extractEuclideanClusters(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)
IndicesAllocator<> Indices
Type used for indices in PCL.
A point structure representing Euclidean xyz coordinates.