39 #ifndef PCL_GPU_SEGMENTATION_IMPL_SEEDED_HUE_SEGMENTATION_H_
40 #define PCL_GPU_SEGMENTATION_IMPL_SEEDED_HUE_SEGMENTATION_H_
42 #include <pcl/gpu/segmentation/gpu_seeded_hue_segmentation.h>
49 PointIndices& indices_in,
50 PointIndices& indices_out,
56 std::vector<bool> processed(host_cloud_->
size(),
false);
58 const auto max_answers = host_cloud_->
size();
61 for (std::size_t k = 0; k < indices_in.indices.size(); ++k) {
62 int i = indices_in.indices[k];
70 p = (*host_cloud_)[i];
79 queries_host.
push_back((*host_cloud_)[i]);
81 unsigned int found_points = queries_host.
size();
82 unsigned int previous_found_points = 0;
87 std::vector<int> sizes, data;
90 while (previous_found_points < found_points) {
92 queries_device.
upload(queries_host);
94 tree->radiusSearch(queries_device, tolerance, max_answers, result_device);
97 previous_found_points = found_points;
107 for (std::size_t qp = 0; qp < sizes.size(); qp++) {
108 for (
int qp_r = 0; qp_r < sizes[qp]; qp_r++) {
109 if (processed[data[qp_r + qp * max_answers]])
113 p_l = (*host_cloud_)[data[qp_r + qp * max_answers]];
117 if (std::abs(h_l.h - h.h) < delta_hue) {
118 processed[data[qp_r + qp * max_answers]] =
true;
119 queries_host.
push_back((*host_cloud_)[data[qp_r + qp * max_answers]]);
125 for (std::size_t qp = 0; qp < sizes.size(); qp++) {
126 for (
int qp_r = 0; qp_r < sizes[qp]; qp_r++) {
127 indices_out.indices.push_back(data[qp_r + qp * max_answers]);
144 if (!
tree_->isBuild()) {
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
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.
Octree implementation on GPU.
shared_ptr< Octree > Ptr
Types.
PointCloudHostPtr host_cloud_
the original cloud the Host
CloudDevice input_
the input cloud on the GPU
float delta_hue_
The allowed difference on the hue.
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.
void segment(PointIndices &indices_in, PointIndices &indices_out)
extract clusters of a PointCloud given by <setInputCloud(), setIndices()>
GPUTreePtr tree_
A pointer to the spatial search object.
void seededHueSegmentation(const PointCloud< PointXYZRGB > &cloud, const search::Search< PointXYZRGB >::Ptr &tree, float tolerance, PointIndices &indices_in, PointIndices &indices_out, float delta_hue=0.0)
Decompose a region of space into clusters based on the Euclidean distance between points.
void seededHueSegmentation(const pcl::PointCloud< pcl::PointXYZRGB >::Ptr &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, PointIndices &clusters_in, PointIndices &clusters_out, float delta_hue=0.0)
void PointXYZRGBtoXYZHSV(const PointXYZRGB &in, PointXYZHSV &out)
Convert a XYZRGB point type to a XYZHSV.