Point Cloud Library (PCL)  1.7.0
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 PointInT, typename PointOutT = pcl::ShapeContext1980, 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.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
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. */
181 
182  /** \brief Bins along the elevation dimension. */
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. */
193 
194  /** \brief Descriptor length. */
196 
197  /** \brief Radius to compute local RF. */
199  };
200 }
201 
202 #ifdef PCL_NO_PRECOMPILE
203 #include <pcl/features/impl/usc.hpp>
204 #endif
205 
206 #endif //#ifndef PCL_USC_H_
std::vector< float > volume_lut_
Volumes look up table.
Definition: usc.h:177
UniqueShapeContext implements the Unique Shape Context Descriptor described here: ...
Definition: usc.h:64
double getLocalRadius() const
Definition: usc.h:147
void setMinimalRadius(double radius)
The minimal radius value for the search sphere (rmin) in the original paper.
Definition: usc.h:122
size_t azimuth_bins_
Bins along the azimuth dimension.
Definition: usc.h:180
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:183
size_t getAzimuthBins() const
Definition: usc.h:102
std::string feature_name_
The feature name.
Definition: feature.h:222
Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: usc.h:79
std::vector< float > phi_divisions_
Phi divisions interval.
Definition: usc.h:174
virtual void computeFeature(PointCloudOut &output)
The actual feature computation.
Definition: usc.hpp:247
double local_radius_
Radius to compute local RF.
Definition: usc.h:198
double getMinimalRadius() const
Definition: usc.h:126
double min_radius_
Minimal radius value.
Definition: usc.h:189
void setLocalRadius(double radius)
Set the local RF radius value.
Definition: usc.h:143
size_t getElevationBins() const
Definition: usc.h:109
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:192
std::vector< float > theta_divisions_
Theta divisions interval.
Definition: usc.h:171
double getPointDensityRadius() const
Definition: usc.h:137
size_t getRadiusBins() const
Definition: usc.h:116
std::vector< float > radii_interval_
values of the radii interval.
Definition: usc.h:168
size_t descriptor_length_
Descriptor length.
Definition: usc.h:195
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:186
void setPointDensityRadius(double radius)
This radius is used to compute local point density density = number of points within this radius...
Definition: usc.h:133
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