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> &,
195 source_features_ = source_features;
198 inline FeatureCloudConstPtr
201 return (source_features_);
207 target_features_ = target_features;
210 inline FeatureCloudConstPtr
213 return (target_features_);
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 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 ());
281 if (getCorrespondenceScore (index) < thresh_ * thresh_)
288 FeatureCloudConstPtr source_features_, target_features_;
295 PointRepresentationConstPtr feature_representation_;
301 #include <pcl/registration/impl/correspondence_rejection_features.hpp>
boost::shared_ptr< const CorrespondenceRejectorFeatures > ConstPtr
void setSourceFeature(const FeatureCloudConstPtr &source_features)
CorrespondenceRejector represents the base class for correspondence rejection methods ...
boost::shared_ptr< const PointRepresentation< PointT > > ConstPtr
void setDistanceThreshold(double thresh)
FeaturesMap features_map_
An STL map containing features to use when performing the correspondence search.
pcl::PointRepresentation< FeatureT >::ConstPtr PointRepresentationConstPtr
const std::string & getClassName() const
Get a string representation of the name of this class.
virtual bool isCorrespondenceValid(int index)
Check whether the correspondence pair at the given index is valid by computing the score and testing ...
boost::shared_ptr< CorrespondenceRejectorFeatures > Ptr
virtual double getCorrespondenceScore(int index)
Obtain a score between a pair of correspondences.
CorrespondenceRejectorFeatures implements a correspondence rejection method based on a set of feature...
virtual ~FeatureContainerInterface()
Empty destructor.
virtual ~CorrespondenceRejectorFeatures()
Empty destructor.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
float max_distance_
The maximum distance threshold between two correspondent points in source <-> target.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
boost::unordered_map< std::string, boost::shared_ptr< FeatureContainerInterface > > FeaturesMap
virtual ~FeatureContainer()
Empty destructor.
FeatureCloudConstPtr getTargetFeature()
DefaulFeatureRepresentation extends PointRepresentation and is intended to be used when defining the ...
void setTargetFeature(const FeatureCloudConstPtr &target_features)
CorrespondencesConstPtr input_correspondences_
The input correspondences.
pcl::PointCloud< FeatureT >::ConstPtr FeatureCloudConstPtr
boost::function< int(const pcl::PointCloud< FeatureT > &, int, std::vector< int > &, std::vector< float > &)> SearchMethod
std::string rejection_name_
The name of the rejection method.
void setFeatureRepresentation(const PointRepresentationConstPtr &fr)
Provide a boost shared pointer to a PointRepresentation to be used when comparing features...
FeatureCloudConstPtr getSourceFeature()
An inner class containing pointers to the source and target feature clouds and the parameters needed ...
void applyRejection(pcl::Correspondences &correspondences)
Apply the rejection algorithm.
CorrespondenceRejectorFeatures()
Empty constructor.