40 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_FEATURES_H_
41 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_FEATURES_H_
43 #include <pcl/registration/correspondence_rejection.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/point_representation.h>
46 #include <pcl/registration/boost.h>
50 namespace registration
67 typedef boost::shared_ptr<CorrespondenceRejectorFeatures>
Ptr;
68 typedef boost::shared_ptr<const CorrespondenceRejectorFeatures>
ConstPtr;
73 rejection_name_ =
"CorrespondenceRejectorFeatures";
91 template <
typename FeatureT>
inline void
93 const std::string &key);
99 getSourceFeature (
const std::string &key);
105 template <
typename FeatureT>
inline void
107 const std::string &key);
113 getTargetFeature (
const std::string &key);
121 template <
typename FeatureT>
inline void
122 setDistanceThreshold (
double thresh,
const std::string &key);
134 template <
typename FeatureT>
inline void
136 const std::string &key);
146 getRemainingCorrespondences (*input_correspondences_, correspondences);
159 virtual bool isValid () = 0;
160 virtual double getCorrespondenceScore (
int index) = 0;
161 virtual bool isCorrespondenceValid (
int index) = 0;
164 typedef boost::unordered_map<std::string, boost::shared_ptr<FeatureContainerInterface> >
FeaturesMap;
175 template <
typename FeatureT>
180 typedef boost::function<int (const pcl::PointCloud<FeatureT> &, int, std::vector<int> &,
185 FeatureContainer () : thresh_(std::numeric_limits<double>::max ()), feature_representation_()
195 source_features_ = source_features;
198 inline FeatureCloudConstPtr
201 return (source_features_);
207 target_features_ = target_features;
210 inline FeatureCloudConstPtr
213 return (target_features_);
217 setDistanceThreshold (
double thresh)
225 if (!source_features_ || !target_features_)
228 return (source_features_->points.size () > 0 &&
229 target_features_->points.size () > 0);
238 feature_representation_ = fr;
245 virtual inline double
246 getCorrespondenceScore (
int index)
249 if (!feature_representation_)
253 const FeatureT &feat_src = source_features_->points[index];
254 const FeatureT &feat_tgt = target_features_->points[index];
257 if (!feature_representation_->isValid (feat_src) || !feature_representation_->isValid (feat_tgt))
259 PCL_ERROR (
"[pcl::registration::%s::getCorrespondenceScore] Invalid feature representation given!\n", this->getClassName ().c_str ());
260 return (std::numeric_limits<double>::max ());
264 Eigen::VectorXf feat_src_ptr = Eigen::VectorXf::Zero (feature_representation_->getNumberOfDimensions ());
265 feature_representation_->vectorize (FeatureT (feat_src), feat_src_ptr);
266 Eigen::VectorXf feat_tgt_ptr = Eigen::VectorXf::Zero (feature_representation_->getNumberOfDimensions ());
267 feature_representation_->vectorize (FeatureT (feat_tgt), feat_tgt_ptr);
270 return ((feat_src_ptr - feat_tgt_ptr).squaredNorm ());
279 isCorrespondenceValid (
int index)
281 if (getCorrespondenceScore (index) < thresh_ * thresh_)
288 FeatureCloudConstPtr source_features_, target_features_;
289 SearchMethod search_method_;
295 PointRepresentationConstPtr feature_representation_;
301 #include <pcl/registration/impl/correspondence_rejection_features.hpp>