Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
segmentation
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
45
namespace
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
60
seededHueSegmentation
(
const
PointCloud<PointXYZRGB>
&cloud,
61
const
search::Search<PointXYZRGB>::Ptr
&tree,
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
79
seededHueSegmentation
(
const
PointCloud<PointXYZRGB>
&cloud,
80
const
search::Search<PointXYZRGBL>::Ptr
&tree,
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
{
95
using
BasePCLBase =
PCLBase<PointXYZRGB>
;
96
97
public
:
98
using
PointCloud
=
pcl::PointCloud<PointXYZRGB>
;
99
using
PointCloudPtr
=
PointCloud::Ptr
;
100
using
PointCloudConstPtr
=
PointCloud::ConstPtr
;
101
102
using
KdTree
=
pcl::search::Search<PointXYZRGB>
;
103
using
KdTreePtr
=
pcl::search::Search<PointXYZRGB>::Ptr
;
104
105
using
PointIndicesPtr
=
PointIndices::Ptr
;
106
using
PointIndicesConstPtr
=
PointIndices::ConstPtr
;
107
108
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
109
/** \brief Empty constructor. */
110
SeededHueSegmentation
() =
default
;
111
112
/** \brief Provide a pointer to the search object.
113
* \param[in] tree a pointer to the spatial search object.
114
*/
115
inline
void
116
setSearchMethod
(
const
KdTreePtr
&tree) {
tree_
= tree; }
117
118
/** \brief Get a pointer to the search method used. */
119
inline
KdTreePtr
120
getSearchMethod
()
const
{
return
(
tree_
); }
121
122
/** \brief Set the spatial cluster tolerance as a measure in the L2 Euclidean space
123
* \param[in] tolerance the spatial cluster tolerance as a measure in the L2 Euclidean space
124
*/
125
inline
void
126
setClusterTolerance
(
double
tolerance) {
cluster_tolerance_
= tolerance; }
127
128
/** \brief Get the spatial cluster tolerance as a measure in the L2 Euclidean space. */
129
inline
double
130
getClusterTolerance
()
const
{
return
(
cluster_tolerance_
); }
131
132
/** \brief Set the tolerance on the hue
133
* \param[in] delta_hue the new delta hue
134
*/
135
inline
void
136
setDeltaHue
(
float
delta_hue) {
delta_hue_
= delta_hue; }
137
138
/** \brief Get the tolerance on the hue */
139
inline
float
140
getDeltaHue
()
const
{
return
(
delta_hue_
); }
141
142
/** \brief Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>
143
* \param[in] indices_in
144
* \param[out] indices_out
145
*/
146
void
147
segment
(
PointIndices
&indices_in,
PointIndices
&indices_out);
148
149
protected
:
150
// Members derived from the base class
151
using
BasePCLBase::input_
;
152
using
BasePCLBase::indices_
;
153
using
BasePCLBase::initCompute
;
154
using
BasePCLBase::deinitCompute
;
155
156
/** \brief A pointer to the spatial search object. */
157
KdTreePtr
tree_
{
nullptr
};
158
159
/** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */
160
double
cluster_tolerance_
{0.0};
161
162
/** \brief The allowed difference on the hue*/
163
float
delta_hue_
{0.0f};
164
165
/** \brief Class getName method. */
166
virtual
std::string
getClassName
()
const
{
return
(
"seededHueSegmentation"
); }
167
};
168
}
169
170
#ifdef PCL_NO_PRECOMPILE
171
#include <pcl/segmentation/impl/seeded_hue_segmentation.hpp>
172
#endif
pcl::PCLBase< PointXYZRGB >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointXYZRGB >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::PCLBase< PointXYZRGB >::initCompute
bool initCompute()
pcl::PCLBase< PointXYZRGB >::PCLBase
PCLBase()
pcl::PCLBase< PointXYZRGB >::deinitCompute
bool deinitCompute()
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:174
pcl::PointCloud< PointXYZRGB >::Ptr
shared_ptr< PointCloud< PointXYZRGB > > Ptr
Definition
point_cloud.h:414
pcl::PointCloud< PointXYZRGB >::ConstPtr
shared_ptr< const PointCloud< PointXYZRGB > > ConstPtr
Definition
point_cloud.h:415
pcl::SeededHueSegmentation::tree_
KdTreePtr tree_
A pointer to the spatial search object.
Definition
seeded_hue_segmentation.h:157
pcl::SeededHueSegmentation::setSearchMethod
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
Definition
seeded_hue_segmentation.h:116
pcl::SeededHueSegmentation::getSearchMethod
KdTreePtr getSearchMethod() const
Get a pointer to the search method used.
Definition
seeded_hue_segmentation.h:120
pcl::SeededHueSegmentation::PointIndicesPtr
PointIndices::Ptr PointIndicesPtr
Definition
seeded_hue_segmentation.h:105
pcl::SeededHueSegmentation::getClassName
virtual std::string getClassName() const
Class getName method.
Definition
seeded_hue_segmentation.h:166
pcl::SeededHueSegmentation::KdTreePtr
pcl::search::Search< PointXYZRGB >::Ptr KdTreePtr
Definition
seeded_hue_segmentation.h:103
pcl::SeededHueSegmentation::PointCloudConstPtr
PointCloud::ConstPtr PointCloudConstPtr
Definition
seeded_hue_segmentation.h:100
pcl::SeededHueSegmentation::PointCloud
pcl::PointCloud< PointXYZRGB > PointCloud
Definition
seeded_hue_segmentation.h:98
pcl::SeededHueSegmentation::delta_hue_
float delta_hue_
The allowed difference on the hue.
Definition
seeded_hue_segmentation.h:163
pcl::SeededHueSegmentation::setClusterTolerance
void setClusterTolerance(double tolerance)
Set the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition
seeded_hue_segmentation.h:126
pcl::SeededHueSegmentation::getDeltaHue
float getDeltaHue() const
Get the tolerance on the hue.
Definition
seeded_hue_segmentation.h:140
pcl::SeededHueSegmentation::KdTree
pcl::search::Search< PointXYZRGB > KdTree
Definition
seeded_hue_segmentation.h:102
pcl::SeededHueSegmentation::cluster_tolerance_
double cluster_tolerance_
The spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition
seeded_hue_segmentation.h:160
pcl::SeededHueSegmentation::setDeltaHue
void setDeltaHue(float delta_hue)
Set the tolerance on the hue.
Definition
seeded_hue_segmentation.h:136
pcl::SeededHueSegmentation::getClusterTolerance
double getClusterTolerance() const
Get the spatial cluster tolerance as a measure in the L2 Euclidean space.
Definition
seeded_hue_segmentation.h:130
pcl::SeededHueSegmentation::segment
void segment(PointIndices &indices_in, PointIndices &indices_out)
Cluster extraction in a PointCloud given by <setInputCloud (), setIndices ()>.
Definition
seeded_hue_segmentation.hpp:210
pcl::SeededHueSegmentation::PointCloudPtr
PointCloud::Ptr PointCloudPtr
Definition
seeded_hue_segmentation.h:99
pcl::SeededHueSegmentation::PointIndicesConstPtr
PointIndices::ConstPtr PointIndicesConstPtr
Definition
seeded_hue_segmentation.h:106
pcl::SeededHueSegmentation::SeededHueSegmentation
SeededHueSegmentation()=default
Empty constructor.
pcl::search::Search
Generic search class.
Definition
search.h:75
pcl::search::Search::Ptr
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition
search.h:81
pcl::seededHueSegmentation
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.
Definition
seeded_hue_segmentation.hpp:49
pcl
Definition
convolution.h:46
pcl::PointIndices
Definition
PointIndices.h:12
pcl::PointIndices::Ptr
shared_ptr< ::pcl::PointIndices > Ptr
Definition
PointIndices.h:13
pcl::PointIndices::ConstPtr
shared_ptr< const ::pcl::PointIndices > ConstPtr
Definition
PointIndices.h:14