Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multiscale_feature_persistence.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: multiscale_feature_persistence.h 4864 2012-03-01 01:11:22Z rusu $
36  */
37 
38 #ifndef PCL_MULTISCALE_FEATURE_PERSISTENCE_H_
39 #define PCL_MULTISCALE_FEATURE_PERSISTENCE_H_
40 
41 #include <pcl/pcl_base.h>
42 #include <pcl/features/feature.h>
44 #include <pcl/common/norms.h>
45 #include <list>
46 
47 namespace pcl
48 {
61  template <typename PointSource, typename PointFeature>
62  class MultiscaleFeaturePersistence : public PCLBase<PointSource>
63  {
64  public:
68  typedef boost::shared_ptr<const pcl::PointRepresentation <PointFeature> > FeatureRepresentationConstPtr;
69 
71 
74 
76  void
78 
84  void
85  determinePersistentFeatures (FeatureCloud &output_features,
86  boost::shared_ptr<std::vector<int> > &output_indices);
87 
91  inline void
92  setScalesVector (std::vector<float> &scale_values) { scale_values_ = scale_values; }
93 
95  inline std::vector<float>
96  getScalesVector () { return scale_values_; }
97 
103  inline void
104  setFeatureEstimator (FeatureEstimatorPtr feature_estimator) { feature_estimator_ = feature_estimator; };
105 
107  inline FeatureEstimatorPtr
108  getFeatureEstimator () { return feature_estimator_; }
109 
113  inline void
114  setPointRepresentation (const FeatureRepresentationConstPtr& feature_representation) { feature_representation_ = feature_representation; }
115 
117  inline FeatureRepresentationConstPtr const
118  getPointRepresentation () { return feature_representation_; }
119 
123  inline void
124  setAlpha (float alpha) { alpha_ = alpha; }
125 
127  inline float
128  getAlpha () { return alpha_; }
129 
133  inline void
134  setDistanceMetric (NormType distance_metric) { distance_metric_ = distance_metric; }
135 
137  inline NormType
138  getDistanceMetric () { return distance_metric_; }
139 
140 
141  private:
143  bool
144  initCompute ();
145 
146 
148  virtual void
149  computeFeatureAtScale (float &scale,
150  FeatureCloudPtr &features);
151 
152 
156  float
157  distanceBetweenFeatures (const std::vector<float> &a,
158  const std::vector<float> &b);
159 
163  void
164  calculateMeanFeature ();
165 
169  void
170  extractUniqueFeatures ();
171 
172 
174  std::vector<float> scale_values_;
175 
177  float alpha_;
178 
180  NormType distance_metric_;
181 
183  FeatureEstimatorPtr feature_estimator_;
184 
185  std::vector<FeatureCloudPtr> features_at_scale_;
186  std::vector<std::vector<std::vector<float> > > features_at_scale_vectorized_;
187  std::vector<float> mean_feature_;
188  FeatureRepresentationConstPtr feature_representation_;
189 
193  std::vector<std::list<size_t> > unique_features_indices_;
194  std::vector<std::vector<bool> > unique_features_table_;
195  };
196 }
197 
198 
199 #endif /* PCL_MULTISCALE_FEATURE_PERSISTENCE_H_ */