00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2011, Alexandru-Eugen Ichim 00006 * Copyright (c) 2012-, Open Perception, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * * Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * * Redistributions in binary form must reproduce the above 00017 * copyright notice, this list of conditions and the following 00018 * disclaimer in the documentation and/or other materials provided 00019 * with the distribution. 00020 * * Neither the name of the copyright holder(s) nor the names of its 00021 * contributors may be used to endorse or promote products derived 00022 * from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00027 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00028 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00030 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00034 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 * $Id$ 00038 */ 00039 00040 #ifndef PCL_MULTISCALE_FEATURE_PERSISTENCE_H_ 00041 #define PCL_MULTISCALE_FEATURE_PERSISTENCE_H_ 00042 00043 #include <pcl/pcl_base.h> 00044 #include <pcl/features/feature.h> 00045 #include <pcl/point_representation.h> 00046 #include <pcl/common/norms.h> 00047 #include <list> 00048 00049 namespace pcl 00050 { 00063 template <typename PointSource, typename PointFeature> 00064 class MultiscaleFeaturePersistence : public PCLBase<PointSource> 00065 { 00066 public: 00067 typedef boost::shared_ptr<MultiscaleFeaturePersistence<PointSource, PointFeature> > Ptr; 00068 typedef boost::shared_ptr<const MultiscaleFeaturePersistence<PointSource, PointFeature> > ConstPtr; 00069 typedef pcl::PointCloud<PointFeature> FeatureCloud; 00070 typedef typename pcl::PointCloud<PointFeature>::Ptr FeatureCloudPtr; 00071 typedef typename pcl::Feature<PointSource, PointFeature>::Ptr FeatureEstimatorPtr; 00072 typedef boost::shared_ptr<const pcl::PointRepresentation <PointFeature> > FeatureRepresentationConstPtr; 00073 00074 using pcl::PCLBase<PointSource>::input_; 00075 00077 MultiscaleFeaturePersistence (); 00078 00080 virtual ~MultiscaleFeaturePersistence () {} 00081 00083 void 00084 computeFeaturesAtAllScales (); 00085 00091 void 00092 determinePersistentFeatures (FeatureCloud &output_features, 00093 boost::shared_ptr<std::vector<int> > &output_indices); 00094 00098 inline void 00099 setScalesVector (std::vector<float> &scale_values) { scale_values_ = scale_values; } 00100 00102 inline std::vector<float> 00103 getScalesVector () { return scale_values_; } 00104 00110 inline void 00111 setFeatureEstimator (FeatureEstimatorPtr feature_estimator) { feature_estimator_ = feature_estimator; }; 00112 00114 inline FeatureEstimatorPtr 00115 getFeatureEstimator () { return feature_estimator_; } 00116 00120 inline void 00121 setPointRepresentation (const FeatureRepresentationConstPtr& feature_representation) { feature_representation_ = feature_representation; } 00122 00124 inline FeatureRepresentationConstPtr const 00125 getPointRepresentation () { return feature_representation_; } 00126 00130 inline void 00131 setAlpha (float alpha) { alpha_ = alpha; } 00132 00134 inline float 00135 getAlpha () { return alpha_; } 00136 00140 inline void 00141 setDistanceMetric (NormType distance_metric) { distance_metric_ = distance_metric; } 00142 00144 inline NormType 00145 getDistanceMetric () { return distance_metric_; } 00146 00147 00148 private: 00150 bool 00151 initCompute (); 00152 00153 00155 virtual void 00156 computeFeatureAtScale (float &scale, 00157 FeatureCloudPtr &features); 00158 00159 00163 float 00164 distanceBetweenFeatures (const std::vector<float> &a, 00165 const std::vector<float> &b); 00166 00170 void 00171 calculateMeanFeature (); 00172 00176 void 00177 extractUniqueFeatures (); 00178 00179 00181 std::vector<float> scale_values_; 00182 00184 float alpha_; 00185 00187 NormType distance_metric_; 00188 00190 FeatureEstimatorPtr feature_estimator_; 00191 00192 std::vector<FeatureCloudPtr> features_at_scale_; 00193 std::vector<std::vector<std::vector<float> > > features_at_scale_vectorized_; 00194 std::vector<float> mean_feature_; 00195 FeatureRepresentationConstPtr feature_representation_; 00196 00200 std::vector<std::list<size_t> > unique_features_indices_; 00201 std::vector<std::vector<bool> > unique_features_table_; 00202 }; 00203 } 00204 00205 #ifdef PCL_NO_PRECOMPILE 00206 #include <pcl/features/impl/multiscale_feature_persistence.hpp> 00207 #endif 00208 00209 #endif /* PCL_MULTISCALE_FEATURE_PERSISTENCE_H_ */