Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
3dsc.h
Go to the documentation of this file.
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 Willow Garage, Inc. 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: 3dsc.h 4927 2012-03-07 03:35:53Z rusu $
37  *
38  */
39 
40 #ifndef PCL_FEATURES_3DSC_H_
41 #define PCL_FEATURES_3DSC_H_
42 
43 #include <pcl/point_types.h>
44 #include <pcl/features/feature.h>
45 #include <boost/random.hpp>
46 
47 namespace pcl
48 {
76  template <typename PointInT, typename PointNT, typename PointOutT = pcl::ShapeContext>
77  class ShapeContext3DEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
78  {
79  public:
89 
92 
97  ShapeContext3DEstimation (bool random = false) :
98  radii_interval_(0),
99  theta_divisions_(0),
100  phi_divisions_(0),
101  volume_lut_(0),
102  azimuth_bins_(12),
103  elevation_bins_(11),
104  radius_bins_(15),
105  min_radius_(0.1),
106  point_density_radius_(0.2),
107  descriptor_length_ (),
108  rng_alg_ (),
109  rng_ (new boost::uniform_01<boost::mt19937> (rng_alg_))
110  {
111  feature_name_ = "ShapeContext3DEstimation";
112  search_radius_ = 2.5;
113 
114  // Create a random number generator object
115  if (random)
116  rng_->base ().seed (static_cast<unsigned> (std::time(0)));
117  else
118  rng_->base ().seed (12345u);
119  }
120 
122 
126  inline void
127  setAzimuthBins (size_t bins) { azimuth_bins_ = bins; }
128 
130  inline size_t
131  getAzimuthBins () { return (azimuth_bins_); }
132 
136  inline void
137  setElevationBins (size_t bins) { elevation_bins_ = bins; }
138 
140  inline size_t
141  getElevationBins () { return (elevation_bins_); }
142 
146  inline void
147  setRadiusBins (size_t bins) { radius_bins_ = bins; }
148 
150  inline size_t
151  getRadiusBins () { return (radius_bins_); }
152 
156  inline void
157  setMinimalRadius (double radius) { min_radius_ = radius; }
158 
160  inline double
161  getMinimalRadius () { return (min_radius_); }
162 
167  inline void
168  setPointDensityRadius (double radius) { point_density_radius_ = radius; }
169 
171  inline double
172  getPointDensityRadius () { return (point_density_radius_); }
173 
174  protected:
176  bool
177  initCompute ();
178 
187  bool
188  computePoint (size_t index, const pcl::PointCloud<PointNT> &normals, float rf[9], std::vector<float> &desc);
189 
193  void
194  computeFeature (PointCloudOut &output);
195 
197  std::vector<float> radii_interval_;
198 
200  std::vector<float> theta_divisions_;
201 
203  std::vector<float> phi_divisions_;
204 
206  std::vector<float> volume_lut_;
207 
209  size_t azimuth_bins_;
210 
212  size_t elevation_bins_;
213 
215  size_t radius_bins_;
216 
218  double min_radius_;
219 
221  double point_density_radius_;
222 
224  size_t descriptor_length_;
225 
227  boost::mt19937 rng_alg_;
228 
230  boost::shared_ptr<boost::uniform_01<boost::mt19937> > rng_;
231 
237  void
238  shiftAlongAzimuth (size_t block_size, std::vector<float>& desc);
239 
241  inline double
242  rnd ()
243  {
244  return ((*rng_) ());
245  }
246  private:
250  void
251  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &) {}
252  };
253 
279  template <typename PointInT, typename PointNT>
280  class ShapeContext3DEstimation<PointInT, PointNT, Eigen::MatrixXf> : public ShapeContext3DEstimation<PointInT, PointNT, pcl::SHOT>
281  {
282  public:
289 
290  private:
294  void
295  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output);
296 
300  void
302  };
303 }
304 
305 #endif //#ifndef PCL_3DSC_H_