Point Cloud Library (PCL)  1.11.1-dev
gpu_seeded_hue_segmentation.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id:$
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/point_types.h>
43 #include <pcl/point_cloud.h>
44 #include <pcl/PointIndices.h>
45 #include <pcl/pcl_macros.h>
46 
47 namespace pcl
48 {
49  namespace gpu
50  {
51  void
53  const pcl::gpu::Octree::Ptr &tree,
54  float tolerance,
55  PointIndices &clusters_in,
56  PointIndices &clusters_out,
57  float delta_hue = 0.0);
58 
60  {
61  public:
66 
69 
72 
74 
75  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76  /** \brief Empty constructor. */
78  {};
79 
80  /** \brief Provide a pointer to the search object.
81  * \param tree a pointer to the spatial search object.
82  */
83  inline void setSearchMethod (const GPUTreePtr &tree) { tree_ = tree; }
84 
85  /** \brief Get a pointer to the search method used.
86  * @todo fix this for a generic search tree
87  */
88  inline GPUTreePtr getSearchMethod () { return (tree_); }
89 
90  /** \brief Set the spatial cluster tolerance as a measure in the L2 Euclidean space
91  * \param tolerance the spatial cluster tolerance as a measure in the L2 Euclidean space
92  */
93  inline void setClusterTolerance (double tolerance) { cluster_tolerance_ = tolerance; }
94 
95  /** \brief Get the spatial cluster tolerance as a measure in the L2 Euclidean space. */
96  inline double getClusterTolerance () { return (cluster_tolerance_); }
97 
98  inline void setInput (CloudDevice input) {input_ = input;}
99 
100  inline void setHostCloud (PointCloudHostPtr host_cloud) {host_cloud_ = host_cloud;}
101 
102  /** \brief Set the tollerance on the hue
103  * \param[in] delta_hue the new delta hue
104  */
105  inline void
106  setDeltaHue (float delta_hue) { delta_hue_ = delta_hue; }
107 
108  /** \brief Get the tolerance on the hue */
109  inline float
110  getDeltaHue () { return (delta_hue_); }
111 
112  /** \brief Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
113  * \param indices_in
114  * \param indices_out
115  */
116  void segment (PointIndices &indices_in, PointIndices &indices_out);
117 
118  protected:
119  /** \brief the input cloud on the GPU */
121 
122  /** \brief the original cloud the Host */
124 
125  /** \brief A pointer to the spatial search object. */
127 
128  /** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */
130 
131  /** \brief The allowed difference on the hue*/
132  float delta_hue_;
133 
134  /** \brief Class getName method. */
135  virtual std::string getClassName () const { return ("gpu::SeededHueSegmentation"); }
136  };
137  /** \brief Sort clusters method (for std::sort).
138  * \ingroup segmentation
139  */
140  inline bool
142  {
143  return (a.indices.size () < b.indices.size ());
144  }
145  }
146 }
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
Definition: convolution.h:46
point_types.h
pcl::gpu::Octree::PointCloud
DeviceArray< PointType > PointCloud
Point cloud supported.
Definition: octree.hpp:75
pcl::gpu::SeededHueSegmentation::host_cloud_
PointCloudHostPtr host_cloud_
the original cloud the Host
Definition: gpu_seeded_hue_segmentation.h:123
pcl::gpu::SeededHueSegmentation::PointIndicesPtr
PointIndices::Ptr PointIndicesPtr
Definition: gpu_seeded_hue_segmentation.h:67
pcl::gpu::SeededHueSegmentation::setClusterTolerance
void setClusterTolerance(double tolerance)
Set the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:93
pcl::gpu::SeededHueSegmentation::input_
CloudDevice input_
the input cloud on the GPU
Definition: gpu_seeded_hue_segmentation.h:120
pcl::gpu::SeededHueSegmentation::setHostCloud
void setHostCloud(PointCloudHostPtr host_cloud)
Definition: gpu_seeded_hue_segmentation.h:100
pcl::gpu::SeededHueSegmentation::tree_
GPUTreePtr tree_
A pointer to the spatial search object.
Definition: gpu_seeded_hue_segmentation.h:126
pcl::PointIndices::indices
Indices indices
Definition: PointIndices.h:21
pcl::gpu::Octree
Octree implementation on GPU.
Definition: octree.hpp:57
pcl::gpu::SeededHueSegmentation::getDeltaHue
float getDeltaHue()
Get the tolerance on the hue.
Definition: gpu_seeded_hue_segmentation.h:110
pcl::gpu::SeededHueSegmentation
Definition: gpu_seeded_hue_segmentation.h:59
pcl::gpu::SeededHueSegmentation::SeededHueSegmentation
SeededHueSegmentation()
Empty constructor.
Definition: gpu_seeded_hue_segmentation.h:77
pcl::gpu::SeededHueSegmentation::getClusterTolerance
double getClusterTolerance()
Get the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:96
pcl::gpu::SeededHueSegmentation::delta_hue_
float delta_hue_
The allowed difference on the hue.
Definition: gpu_seeded_hue_segmentation.h:132
pcl::PointCloud< pcl::PointXYZ >
pcl::gpu::seededHueSegmentation
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)
pcl::gpu::SeededHueSegmentation::cluster_tolerance_
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition: gpu_seeded_hue_segmentation.h:129
pcl::gpu::SeededHueSegmentation::segment
void segment(PointIndices &indices_in, PointIndices &indices_out)
Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
Definition: gpu_seeded_hue_segmentation.hpp:141
pcl::gpu::comparePointClusters
bool comparePointClusters(const pcl::PointIndices &a, const pcl::PointIndices &b)
Sort clusters method (for std::sort).
Definition: gpu_extract_clusters.h:161
pcl::gpu::SeededHueSegmentation::setSearchMethod
void setSearchMethod(const GPUTreePtr &tree)
Provide a pointer to the search object.
Definition: gpu_seeded_hue_segmentation.h:83
pcl::PointIndices::ConstPtr
shared_ptr< const ::pcl::PointIndices > ConstPtr
Definition: PointIndices.h:14
pcl::PointXYZ
A point structure representing Euclidean xyz coordinates.
Definition: point_types.hpp:300
pcl::gpu::DeviceArray< PointType >
pcl::PointIndices
Definition: PointIndices.h:11
pcl::gpu::SeededHueSegmentation::setInput
void setInput(CloudDevice input)
Definition: gpu_seeded_hue_segmentation.h:98
pcl::PointIndices::Ptr
shared_ptr< ::pcl::PointIndices > Ptr
Definition: PointIndices.h:13
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:406
pcl::gpu::SeededHueSegmentation::setDeltaHue
void setDeltaHue(float delta_hue)
Set the tollerance on the hue.
Definition: gpu_seeded_hue_segmentation.h:106
pcl::PointCloud< pcl::PointXYZ >::ConstPtr
shared_ptr< const PointCloud< pcl::PointXYZ > > ConstPtr
Definition: point_cloud.h:407
pcl::gpu::SeededHueSegmentation::GPUTreePtr
pcl::gpu::Octree::Ptr GPUTreePtr
Definition: gpu_seeded_hue_segmentation.h:71
pcl::gpu::SeededHueSegmentation::getSearchMethod
GPUTreePtr getSearchMethod()
Get a pointer to the search method used.
Definition: gpu_seeded_hue_segmentation.h:88
pcl::gpu::Octree::Ptr
shared_ptr< Octree > Ptr
Types.
Definition: octree.hpp:68
pcl::gpu::SeededHueSegmentation::PointCloudHostConstPtr
PointCloudHost::ConstPtr PointCloudHostConstPtr
Definition: gpu_seeded_hue_segmentation.h:65
pcl::gpu::SeededHueSegmentation::PointIndicesConstPtr
PointIndices::ConstPtr PointIndicesConstPtr
Definition: gpu_seeded_hue_segmentation.h:68
pcl::gpu::SeededHueSegmentation::getClassName
virtual std::string getClassName() const
Class getName method.
Definition: gpu_seeded_hue_segmentation.h:135
pcl::gpu::SeededHueSegmentation::PointCloudHostPtr
PointCloudHost::Ptr PointCloudHostPtr
Definition: gpu_seeded_hue_segmentation.h:64