Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyramid_feature_matching.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Alexandru-Eugen Ichim
5  * Willow Garage, Inc
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * $Id: pyramid_feature_matching.h 4866 2012-03-01 02:45:17Z rusu $
36  */
37 
38 #ifndef PCL_PYRAMID_FEATURE_MATCHING_H_
39 #define PCL_PYRAMID_FEATURE_MATCHING_H_
40 
41 #include <pcl/pcl_base.h>
43 
44 namespace pcl
45 {
64  template <typename PointFeature>
65  class PyramidFeatureHistogram : public PCLBase<PointFeature>
66  {
67  public:
69 
70  typedef boost::shared_ptr<PyramidFeatureHistogram<PointFeature> > Ptr;
72  typedef boost::shared_ptr<const pcl::PointRepresentation<PointFeature> > FeatureRepresentationConstPtr;
73 
74 
77 
81  inline void
82  setInputDimensionRange (std::vector<std::pair<float, float> > &dimension_range_input)
83  { dimension_range_input_ = dimension_range_input; }
84 
86  inline std::vector<std::pair<float, float> >
87  getInputDimensionRange () { return dimension_range_input_; }
88 
92  inline void
93  setTargetDimensionRange (std::vector<std::pair<float, float> > &dimension_range_target)
94  { dimension_range_target_ = dimension_range_target; }
95 
97  inline std::vector<std::pair<float, float> >
98  getTargetDimensionRange () { return dimension_range_target_; }
99 
103  inline void
104  setPointRepresentation (const FeatureRepresentationConstPtr& feature_representation) { feature_representation_ = feature_representation; }
105 
107  inline FeatureRepresentationConstPtr const
108  getPointRepresentation () { return feature_representation_; }
109 
111  void
112  compute ();
113 
115  inline bool
116  isComputed () { return is_computed_; }
117 
123  static float
125  const PyramidFeatureHistogramPtr &pyramid_b);
126 
127 
128  private:
129  size_t nr_dimensions, nr_levels, nr_features;
130  std::vector<std::pair<float, float> > dimension_range_input_, dimension_range_target_;
131  FeatureRepresentationConstPtr feature_representation_;
132  bool is_computed_;
133 
135  bool
136  initializeHistogram ();
137 
141  void
142  convertFeatureToVector (const PointFeature &feature,
143  std::vector<float> &feature_vector);
144 
146  void
147  addFeature (std::vector<float> &feature);
148 
154  inline unsigned int&
155  at (std::vector<size_t> &access,
156  size_t &level);
157 
162  inline unsigned int&
163  at (std::vector<float> &feature,
164  size_t &level);
165 
167  struct PyramidFeatureHistogramLevel
168  {
169  PyramidFeatureHistogramLevel () :
170  hist (),
171  bins_per_dimension (),
172  bin_step ()
173  {
174  }
175 
176  PyramidFeatureHistogramLevel (std::vector<size_t> &a_bins_per_dimension, std::vector<float> &a_bin_step) :
177  hist (),
178  bins_per_dimension (a_bins_per_dimension),
179  bin_step (a_bin_step)
180  {
181  initializeHistogramLevel ();
182  }
183 
184  void
185  initializeHistogramLevel ();
186 
187  std::vector<unsigned int> hist;
188  std::vector<size_t> bins_per_dimension;
189  std::vector<float> bin_step;
190  };
191  std::vector<PyramidFeatureHistogramLevel> hist_levels;
192  };
193 }
194 
195 #endif /* PCL_PYRAMID_FEATURE_MATCHING_H_ */