40 #include <pcl/common/copy_point.h>
41 #include <pcl/gpu/segmentation/gpu_extract_clusters.h>
42 #include <pcl/pcl_exports.h>
51 std::size_t buffer_size,
56 template <
typename Po
intT>
62 std::vector<PointIndices>& clusters,
63 unsigned int min_pts_per_cluster,
64 unsigned int max_pts_per_cluster)
69 PCL_DEBUG(
"[pcl::gpu::extractEuclideanClusters]\n");
70 std::vector<bool> processed(host_cloud_->
size(),
false);
74 if (max_pts_per_cluster > host_cloud_->
size())
75 max_answers = host_cloud_->
size();
77 max_answers = max_pts_per_cluster;
78 PCL_DEBUG(
"Max_answers: %i\n", max_answers);
84 queries_device_buffer.
create(max_answers);
89 for (std::size_t i = 0; i < host_cloud_->
size(); ++i) {
112 unsigned int found_points = queries_host.
size();
113 unsigned int previous_found_points = 0;
121 if (queries_host.
size() <=
125 for (std::size_t p = 0; p < queries_host.
size(); p++) {
128 tree->radiusSearchHost(queries_host[p], tolerance, cpu_tmp, max_answers);
129 std::copy(cpu_tmp.begin(), cpu_tmp.end(), std::back_inserter(data));
140 queries_device.
upload(queries_host);
142 tree->radiusSearch(queries_device, tolerance, max_answers, result_device);
148 previous_found_points = found_points;
150 queries_host.
clear();
152 if (data.size() == 1)
156 for (
const auto& idx : data) {
159 processed[idx] =
true;
166 PCL_DEBUG(
" data.size: %i, foundpoints: %i, previous: %i",
169 previous_found_points);
170 PCL_DEBUG(
" new points: %i, next queries size: %i\n",
171 found_points - previous_found_points,
172 queries_host.
size());
173 }
while (previous_found_points < found_points);
175 if (found_points >= min_pts_per_cluster && found_points <= max_pts_per_cluster) {
182 clusters.push_back(r);
187 template <
typename Po
intT>
190 std::vector<pcl::PointIndices>& clusters)
198 tree_.setCloud(input_);
201 if (!tree_->isBuilt()) {
212 extractEuclideanClusters<PointT>(host_cloud_,
216 min_pts_per_cluster_,
217 max_pts_per_cluster_);
218 PCL_DEBUG(
"INFO: end of extractEuclideanClusters\n");
223 #define PCL_INSTANTIATE_extractEuclideanClusters(T) \
224 template void PCL_EXPORTS pcl::gpu::extractEuclideanClusters<T>( \
225 const typename pcl::PointCloud<T>::Ptr&, \
226 const pcl::gpu::Octree::Ptr&, \
228 std::vector<PointIndices>&, \
231 #define PCL_INSTANTIATE_EuclideanClusterExtraction(T) \
232 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.
PCL_EXPORTS 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.