Point Cloud Library (PCL)
1.7.1
Main Page
Modules
Namespaces
Classes
features
include
pcl
features
usc.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
* Copyright (c) 2012-, Open Perception, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of the copyright holder(s) nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* $Id$
38
*
39
*/
40
41
#ifndef PCL_FEATURES_USC_H_
42
#define PCL_FEATURES_USC_H_
43
44
#include <pcl/point_types.h>
45
#include <pcl/features/feature.h>
46
47
namespace
pcl
48
{
49
/** \brief UniqueShapeContext implements the Unique Shape Context Descriptor
50
* described here:
51
*
52
* - F. Tombari, S. Salti, L. Di Stefano,
53
* "Unique Shape Context for 3D data description",
54
* International Workshop on 3D Object Retrieval (3DOR 10) -
55
* in conjuction with ACM Multimedia 2010
56
*
57
* The suggested PointOutT is pcl::ShapeContext1980
58
*
59
* \author Alessandro Franchi, Federico Tombari, Samuele Salti (original code)
60
* \author Nizar Sallem (port to PCL)
61
* \ingroup features
62
*/
63
template
<
typename
Po
int
InT,
typename
Po
int
OutT = pcl::ShapeContext1980,
typename
Po
int
RFT = pcl::ReferenceFrame>
64
class
UniqueShapeContext
:
public
Feature
<PointInT, PointOutT>,
65
public
FeatureWithLocalReferenceFrames
<PointInT, PointRFT>
66
{
67
public
:
68
using
Feature<PointInT, PointOutT>::feature_name_
;
69
using
Feature<PointInT, PointOutT>::getClassName
;
70
using
Feature<PointInT, PointOutT>::indices_
;
71
using
Feature<PointInT, PointOutT>::search_parameter_
;
72
using
Feature<PointInT, PointOutT>::search_radius_
;
73
using
Feature<PointInT, PointOutT>::surface_
;
74
using
Feature<PointInT, PointOutT>::fake_surface_
;
75
using
Feature<PointInT, PointOutT>::input_
;
76
using
Feature<PointInT, PointOutT>::searchForNeighbors
;
77
using
FeatureWithLocalReferenceFrames<PointInT, PointRFT>::frames_
;
78
79
typedef
typename
Feature<PointInT, PointOutT>::PointCloudOut
PointCloudOut
;
80
typedef
typename
Feature<PointInT, PointOutT>::PointCloudIn
PointCloudIn
;
81
typedef
typename
boost::shared_ptr<UniqueShapeContext<PointInT, PointOutT, PointRFT> >
Ptr
;
82
typedef
typename
boost::shared_ptr<const UniqueShapeContext<PointInT, PointOutT, PointRFT> >
ConstPtr
;
83
84
85
/** \brief Constructor. */
86
UniqueShapeContext
() :
87
radii_interval_
(0),
theta_divisions_
(0),
phi_divisions_
(0),
volume_lut_
(0),
88
azimuth_bins_
(12),
elevation_bins_
(11),
radius_bins_
(15),
89
min_radius_
(0.1),
point_density_radius_
(0.2),
descriptor_length_
(),
local_radius_
(2.5)
90
{
91
feature_name_
=
"UniqueShapeContext"
;
92
search_radius_
= 2.5;
93
}
94
95
virtual
~UniqueShapeContext
() { }
96
97
//inline void
98
//setAzimuthBins (size_t bins) { azimuth_bins_ = bins; }
99
100
/** \return The number of bins along the azimuth. */
101
inline
size_t
102
getAzimuthBins
()
const
{
return
(
azimuth_bins_
); }
103
104
//inline void
105
//setElevationBins (size_t bins) { elevation_bins_ = bins; }
106
107
/** \return The number of bins along the elevation */
108
inline
size_t
109
getElevationBins
()
const
{
return
(
elevation_bins_
); }
110
111
//inline void
112
//setRadiusBins (size_t bins) { radius_bins_ = bins; }
113
114
/** \return The number of bins along the radii direction. */
115
inline
size_t
116
getRadiusBins
()
const
{
return
(
radius_bins_
); }
117
118
/** The minimal radius value for the search sphere (rmin) in the original paper
119
* \param[in] radius the desired minimal radius
120
*/
121
inline
void
122
setMinimalRadius
(
double
radius) {
min_radius_
= radius; }
123
124
/** \return The minimal sphere radius. */
125
inline
double
126
getMinimalRadius
()
const
{
return
(
min_radius_
); }
127
128
/** This radius is used to compute local point density
129
* density = number of points within this radius
130
* \param[in] radius Value of the point density search radius
131
*/
132
inline
void
133
setPointDensityRadius
(
double
radius) {
point_density_radius_
= radius; }
134
135
/** \return The point density search radius. */
136
inline
double
137
getPointDensityRadius
()
const
{
return
(
point_density_radius_
); }
138
139
/** Set the local RF radius value
140
* \param[in] radius the desired local RF radius
141
*/
142
inline
void
143
setLocalRadius
(
double
radius) {
local_radius_
= radius; }
144
145
/** \return The local RF radius. */
146
inline
double
147
getLocalRadius
()
const
{
return
(
local_radius_
); }
148
149
protected
:
150
/** Compute 3D shape context feature descriptor
151
* \param[in] index point index in input_
152
* \param[out] desc descriptor to compute
153
*/
154
void
155
computePointDescriptor
(
size_t
index, std::vector<float> &desc);
156
157
/** \brief Initialize computation by allocating all the intervals and the volume lookup table. */
158
virtual
bool
159
initCompute
();
160
161
/** \brief The actual feature computation.
162
* \param[out] output the resultant features
163
*/
164
virtual
void
165
computeFeature
(
PointCloudOut
&output);
166
167
/** \brief values of the radii interval. */
168
std::vector<float>
radii_interval_
;
169
170
/** \brief Theta divisions interval. */
171
std::vector<float>
theta_divisions_
;
172
173
/** \brief Phi divisions interval. */
174
std::vector<float>
phi_divisions_
;
175
176
/** \brief Volumes look up table. */
177
std::vector<float>
volume_lut_
;
178
179
/** \brief Bins along the azimuth dimension. */
180
size_t
azimuth_bins_
;
181
182
/** \brief Bins along the elevation dimension. */
183
size_t
elevation_bins_
;
184
185
/** \brief Bins along the radius dimension. */
186
size_t
radius_bins_
;
187
188
/** \brief Minimal radius value. */
189
double
min_radius_
;
190
191
/** \brief Point density radius. */
192
double
point_density_radius_
;
193
194
/** \brief Descriptor length. */
195
size_t
descriptor_length_
;
196
197
/** \brief Radius to compute local RF. */
198
double
local_radius_
;
199
};
200
}
201
202
#ifdef PCL_NO_PRECOMPILE
203
#include <pcl/features/impl/usc.hpp>
204
#endif
205
206
#endif //#ifndef PCL_USC_H_