Point Cloud Library (PCL)  1.9.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 conjunction with ACM Multimedia 2010
56  *
57  * The suggested PointOutT is pcl::UniqueShapeContext1960
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 PointInT, typename PointOutT = pcl::UniqueShapeContext1960, typename PointRFT = pcl::ReferenceFrame>
64  class UniqueShapeContext : public Feature<PointInT, PointOutT>,
65  public FeatureWithLocalReferenceFrames<PointInT, PointRFT>
66  {
67  public:
78 
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. */
90  {
91  feature_name_ = "UniqueShapeContext";
92  search_radius_ = 2.0;
93  }
94 
95  virtual ~UniqueShapeContext() { }
96 
97  /** \return The number of bins along the azimuth. */
98  inline size_t
99  getAzimuthBins () const { return (azimuth_bins_); }
100 
101  /** \return The number of bins along the elevation */
102  inline size_t
103  getElevationBins () const { return (elevation_bins_); }
104 
105  /** \return The number of bins along the radii direction. */
106  inline size_t
107  getRadiusBins () const { return (radius_bins_); }
108 
109  /** The minimal radius value for the search sphere (rmin) in the original paper
110  * \param[in] radius the desired minimal radius
111  */
112  inline void
113  setMinimalRadius (double radius) { min_radius_ = radius; }
114 
115  /** \return The minimal sphere radius. */
116  inline double
117  getMinimalRadius () const { return (min_radius_); }
118 
119  /** This radius is used to compute local point density
120  * density = number of points within this radius
121  * \param[in] radius Value of the point density search radius
122  */
123  inline void
124  setPointDensityRadius (double radius) { point_density_radius_ = radius; }
125 
126  /** \return The point density search radius. */
127  inline double
129 
130  /** Set the local RF radius value
131  * \param[in] radius the desired local RF radius
132  */
133  inline void
134  setLocalRadius (double radius) { local_radius_ = radius; }
135 
136  /** \return The local RF radius. */
137  inline double
138  getLocalRadius () const { return (local_radius_); }
139 
140  protected:
141  /** Compute 3D shape context feature descriptor
142  * \param[in] index point index in input_
143  * \param[out] desc descriptor to compute
144  */
145  void
146  computePointDescriptor (size_t index, std::vector<float> &desc);
147 
148  /** \brief Initialize computation by allocating all the intervals and the volume lookup table. */
149  virtual bool
150  initCompute ();
151 
152  /** \brief The actual feature computation.
153  * \param[out] output the resultant features
154  */
155  virtual void
156  computeFeature (PointCloudOut &output);
157 
158  /** \brief values of the radii interval. */
159  std::vector<float> radii_interval_;
160 
161  /** \brief Theta divisions interval. */
162  std::vector<float> theta_divisions_;
163 
164  /** \brief Phi divisions interval. */
165  std::vector<float> phi_divisions_;
166 
167  /** \brief Volumes look up table. */
168  std::vector<float> volume_lut_;
169 
170  /** \brief Bins along the azimuth dimension. */
172 
173  /** \brief Bins along the elevation dimension. */
175 
176  /** \brief Bins along the radius dimension. */
177  size_t radius_bins_;
178 
179  /** \brief Minimal radius value. */
180  double min_radius_;
181 
182  /** \brief Point density radius. */
184 
185  /** \brief Descriptor length. */
187 
188  /** \brief Radius to compute local RF. */
190  };
191 }
192 
193 #ifdef PCL_NO_PRECOMPILE
194 #include <pcl/features/impl/usc.hpp>
195 #endif
196 
197 #endif //#ifndef PCL_USC_H_
std::vector< float > volume_lut_
Volumes look up table.
Definition: usc.h:168
UniqueShapeContext implements the Unique Shape Context Descriptor described here: ...
Definition: usc.h:64
double getLocalRadius() const
Definition: usc.h:138
void setMinimalRadius(double radius)
The minimal radius value for the search sphere (rmin) in the original paper.
Definition: usc.h:113
size_t azimuth_bins_
Bins along the azimuth dimension.
Definition: usc.h:171
void computePointDescriptor(size_t index, std::vector< float > &desc)
Compute 3D shape context feature descriptor.
Definition: usc.hpp:144
size_t elevation_bins_
Bins along the elevation dimension.
Definition: usc.h:174
size_t getAzimuthBins() const
Definition: usc.h:99
std::string feature_name_
The feature name.
Definition: feature.h:222
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: usc.h:79
std::vector< float > phi_divisions_
Phi divisions interval.
Definition: usc.h:165
virtual void computeFeature(PointCloudOut &output)
The actual feature computation.
Definition: usc.hpp:247
double local_radius_
Radius to compute local RF.
Definition: usc.h:189
double getMinimalRadius() const
Definition: usc.h:117
double min_radius_
Minimal radius value.
Definition: usc.h:180
void setLocalRadius(double radius)
Set the local RF radius value.
Definition: usc.h:134
size_t getElevationBins() const
Definition: usc.h:103
Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: usc.h:80
virtual bool initCompute()
Initialize computation by allocating all the intervals and the volume lookup table.
Definition: usc.hpp:52
boost::shared_ptr< UniqueShapeContext< PointInT, PointOutT, PointRFT > > Ptr
Definition: usc.h:81
double point_density_radius_
Point density radius.
Definition: usc.h:183
std::vector< float > theta_divisions_
Theta divisions interval.
Definition: usc.h:162
double getPointDensityRadius() const
Definition: usc.h:128
size_t getRadiusBins() const
Definition: usc.h:107
std::vector< float > radii_interval_
values of the radii interval.
Definition: usc.h:159
size_t descriptor_length_
Descriptor length.
Definition: usc.h:186
PointCloud represents the base class in PCL for storing collections of 3D points. ...
UniqueShapeContext()
Constructor.
Definition: usc.h:86
Feature represents the base feature class.
Definition: feature.h:105
FeatureWithLocalReferenceFrames provides a public interface for descriptor extractor classes which ne...
Definition: feature.h:447
size_t radius_bins_
Bins along the radius dimension.
Definition: usc.h:177
void setPointDensityRadius(double radius)
This radius is used to compute local point density density = number of points within this radius...
Definition: usc.h:124
boost::shared_ptr< const UniqueShapeContext< PointInT, PointOutT, PointRFT > > ConstPtr
Definition: usc.h:82
virtual ~UniqueShapeContext()
Definition: usc.h:95
double search_radius_
The nearest neighbors search radius for each point.
Definition: feature.h:239