38 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_FEATURES_H_
39 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_FEATURES_H_
41 #include <boost/function.hpp>
42 #include <boost/unordered_map.hpp>
49 namespace registration
62 using CorrespondenceRejector::input_correspondences_;
63 using CorrespondenceRejector::rejection_name_;
64 using CorrespondenceRejector::getClassName;
70 rejection_name_ =
"CorrespondenceRejectorFeatures";
85 template <
typename FeatureT>
inline void
87 const std::string &key);
99 template <
typename FeatureT>
inline void
101 const std::string &key);
115 template <
typename FeatureT>
inline void
128 template <
typename FeatureT>
inline void
130 const std::string &key);
148 class FeatureContainerInterface
151 virtual bool isValid () = 0;
152 virtual double getCorrespondenceScore (
int index) = 0;
153 virtual bool isCorrespondenceValid (
int index) = 0;
156 typedef boost::unordered_map<std::string, boost::shared_ptr<FeatureContainerInterface> > FeaturesMap;
159 FeaturesMap features_map_;
167 template <
typename FeatureT>
168 class FeatureContainer :
public pcl::registration::CorrespondenceRejectorFeatures::FeatureContainerInterface
172 typedef boost::function<int (const pcl::PointCloud<FeatureT> &, int, std::vector<int> &,
173 std::vector<float> &)> SearchMethod;
177 FeatureContainer () : thresh_(std::numeric_limits<double>::max ()), feature_representation_()
184 source_features_ = source_features;
187 inline FeatureCloudConstPtr
190 return (source_features_);
196 target_features_ = target_features;
199 inline FeatureCloudConstPtr
202 return (target_features_);
214 if (!source_features_ || !target_features_)
217 return (source_features_->points.size () > 0 &&
218 target_features_->points.size () > 0);
227 feature_representation_ = fr;
234 virtual inline double
235 getCorrespondenceScore (
int index)
238 if (!feature_representation_)
239 feature_representation_.reset (
new DefaultFeatureRepresentation<FeatureT>);
242 const FeatureT &feat_src = source_features_->points[index];
243 const FeatureT &feat_tgt = target_features_->points[index];
246 if (!feature_representation_->isValid (feat_src) || !feature_representation_->isValid (feat_tgt))
248 PCL_ERROR (
"[pcl::registration::CorrespondenceRejectorFeatures::getCorrespondenceScore] Invalid feature representation given!\n");
249 return (std::numeric_limits<double>::max ());
253 Eigen::VectorXf feat_src_ptr = Eigen::VectorXf::Zero (feature_representation_->getNumberOfDimensions ());
254 feature_representation_->vectorize (FeatureT (feat_src), feat_src_ptr);
255 Eigen::VectorXf feat_tgt_ptr = Eigen::VectorXf::Zero (feature_representation_->getNumberOfDimensions ());
256 feature_representation_->vectorize (FeatureT (feat_tgt), feat_tgt_ptr);
259 return ((feat_src_ptr - feat_tgt_ptr).squaredNorm ());
268 isCorrespondenceValid (
int index)
270 if (getCorrespondenceScore (index) < thresh_ * thresh_)
277 FeatureCloudConstPtr source_features_, target_features_;
278 SearchMethod search_method_;
284 PointRepresentationConstPtr feature_representation_;