Point Cloud Library (PCL) 1.12.1
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 the copyright holder(s) 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#pragma once
40
41#include <pcl/pcl_base.h>
42#include <pcl/point_types_conversion.h>
43#include <pcl/search/search.h> // for Search
44
45namespace pcl
46{
47 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48 /** \brief Decompose a region of space into clusters based on the Euclidean distance between points
49 * \param[in] cloud the point cloud message
50 * \param[in] tree the spatial locator (e.g., kd-tree) used for nearest neighbors searching
51 * \note the tree has to be created as a spatial locator on \a cloud
52 * \param[in] tolerance the spatial cluster tolerance as a measure in L2 Euclidean space
53 * \param[in] indices_in the cluster containing the seed point indices (as a vector of PointIndices)
54 * \param[out] indices_out
55 * \param[in] delta_hue
56 * \todo look how to make this templated!
57 * \ingroup segmentation
58 */
59 void
62 float tolerance,
63 PointIndices &indices_in,
64 PointIndices &indices_out,
65 float delta_hue = 0.0);
66
67 /** \brief Decompose a region of space into clusters based on the Euclidean distance between points
68 * \param[in] cloud the point cloud message
69 * \param[in] tree the spatial locator (e.g., kd-tree) used for nearest neighbors searching
70 * \note the tree has to be created as a spatial locator on \a cloud
71 * \param[in] tolerance the spatial cluster tolerance as a measure in L2 Euclidean space
72 * \param[in] indices_in the cluster containing the seed point indices (as a vector of PointIndices)
73 * \param[out] indices_out
74 * \param[in] delta_hue
75 * \todo look how to make this templated!
76 * \ingroup segmentation
77 */
78 void
81 float tolerance,
82 PointIndices &indices_in,
83 PointIndices &indices_out,
84 float delta_hue = 0.0);
85
86 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
88 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
89 /** \brief SeededHueSegmentation
90 * \author Koen Buys
91 * \ingroup segmentation
92 */
93 class SeededHueSegmentation: public PCLBase<PointXYZRGB>
94 {
96
97 public:
101
104
107
108 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
109 /** \brief Empty constructor. */
111 {};
112
113 /** \brief Provide a pointer to the search object.
114 * \param[in] tree a pointer to the spatial search object.
115 */
116 inline void
117 setSearchMethod (const KdTreePtr &tree) { tree_ = tree; }
118
119 /** \brief Get a pointer to the search method used. */
120 inline KdTreePtr
121 getSearchMethod () const { return (tree_); }
122
123 /** \brief Set the spatial cluster tolerance as a measure in the L2 Euclidean space
124 * \param[in] tolerance the spatial cluster tolerance as a measure in the L2 Euclidean space
125 */
126 inline void
127 setClusterTolerance (double tolerance) { cluster_tolerance_ = tolerance; }
128
129 /** \brief Get the spatial cluster tolerance as a measure in the L2 Euclidean space. */
130 inline double
132
133 /** \brief Set the tollerance on the hue
134 * \param[in] delta_hue the new delta hue
135 */
136 inline void
137 setDeltaHue (float delta_hue) { delta_hue_ = delta_hue; }
138
139 /** \brief Get the tolerance on the hue */
140 inline float
141 getDeltaHue () const { return (delta_hue_); }
142
143 /** \brief Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
144 * \param[in] indices_in
145 * \param[out] indices_out
146 */
147 void
148 segment (PointIndices &indices_in, PointIndices &indices_out);
149
150 protected:
151 // Members derived from the base class
156
157 /** \brief A pointer to the spatial search object. */
159
160 /** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */
162
163 /** \brief The allowed difference on the hue*/
165
166 /** \brief Class getName method. */
167 virtual std::string getClassName () const { return ("seededHueSegmentation"); }
168 };
169}
170
171#ifdef PCL_NO_PRECOMPILE
172#include <pcl/segmentation/impl/seeded_hue_segmentation.hpp>
173#endif
PCL base class.
Definition: pcl_base.h:70
PointCloudConstPtr input_
The input point cloud dataset.
Definition: pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition: pcl_base.h:150
bool initCompute()
This method should get called before starting the actual computation.
Definition: pcl_base.hpp:138
bool deinitCompute()
This method should get called after finishing the actual computation.
Definition: pcl_base.hpp:174
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
KdTreePtr tree_
A pointer to the spatial search object.
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
KdTreePtr getSearchMethod() const
Get a pointer to the search method used.
virtual std::string getClassName() const
Class getName method.
pcl::search::Search< PointXYZRGB >::Ptr KdTreePtr
PointCloud::ConstPtr PointCloudConstPtr
float delta_hue_
The allowed difference on the hue.
void setClusterTolerance(double tolerance)
Set the spatial cluster tolerance as a measure in the L2 Euclidean space.
float getDeltaHue() const
Get the tolerance on the hue.
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.
void setDeltaHue(float delta_hue)
Set the tollerance on the hue.
double getClusterTolerance() const
Get the spatial cluster tolerance as a measure in the L2 Euclidean space.
void segment(PointIndices &indices_in, PointIndices &indices_out)
Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
SeededHueSegmentation()
Empty constructor.
PointIndices::ConstPtr PointIndicesConstPtr
shared_ptr< pcl::search::Search< PointXYZRGB > > Ptr
Definition: search.h:81
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.
shared_ptr< ::pcl::PointIndices > Ptr
Definition: PointIndices.h:13
shared_ptr< const ::pcl::PointIndices > ConstPtr
Definition: PointIndices.h:14