Point Cloud Library (PCL)  1.9.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
52  seededHueSegmentation (const boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> > &host_cloud_,
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 */
120  CloudDevice input_;
121 
122  /** \brief the original cloud the Host */
123  PointCloudHostPtr host_cloud_;
124 
125  /** \brief A pointer to the spatial search object. */
126  GPUTreePtr tree_;
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 }
void setClusterTolerance(double tolerance)
Set the spatial cluster tolerance as a measure in the L2 Euclidean space.
void setDeltaHue(float delta_hue)
Set the tollerance on the hue.
PointCloudHostPtr host_cloud_
the original cloud the Host
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:44
boost::shared_ptr< Octree > Ptr
Types.
Definition: octree.hpp:67
std::vector< int > indices
Definition: PointIndices.h:19
GPUTreePtr getSearchMethod()
Get a pointer to the search method used.
Octree implementation on GPU.
Definition: octree.hpp:56
bool comparePointClusters(const pcl::PointIndices &a, const pcl::PointIndices &b)
Sort clusters method (for std::sort).
GPUTreePtr tree_
A pointer to the spatial search object.
boost::shared_ptr< PointCloud< pcl::PointXYZ > > Ptr
Definition: point_cloud.h:427
A point structure representing Euclidean xyz coordinates.
pcl::gpu::Octree::PointCloud CloudDevice
void setSearchMethod(const GPUTreePtr &tree)
Provide a pointer to the search object.
boost::shared_ptr< const PointCloud< pcl::PointXYZ > > ConstPtr
Definition: point_cloud.h:428
float delta_hue_
The allowed difference on the hue.
PointCloudHost::ConstPtr PointCloudHostConstPtr
void segment(PointIndices &indices_in, PointIndices &indices_out)
Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
boost::shared_ptr< ::pcl::PointIndices > Ptr
Definition: PointIndices.h:22
CloudDevice input_
the input cloud on the GPU
float getDeltaHue()
Get the tolerance on the hue.
void seededHueSegmentation(const boost::shared_ptr< pcl::PointCloud< pcl::PointXYZRGB > > &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, PointIndices &clusters_in, PointIndices &clusters_out, float delta_hue=0.0)
pcl::PointCloud< pcl::PointXYZ > PointCloudHost
virtual std::string getClassName() const
Class getName method.
void setHostCloud(PointCloudHostPtr host_cloud)
double getClusterTolerance()
Get the spatial cluster tolerance as a measure in the L2 Euclidean space.
boost::shared_ptr< ::pcl::PointIndices const > ConstPtr
Definition: PointIndices.h:23
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.