43#include <pcl/registration/correspondence_rejection.h>
44#include <pcl/point_cloud.h>
45#include <pcl/point_representation.h>
47#include <unordered_map>
50namespace registration {
59 using CorrespondenceRejector::getClassName;
60 using CorrespondenceRejector::input_correspondences_;
61 using CorrespondenceRejector::rejection_name_;
70 rejection_name_ =
"CorrespondenceRejectorFeatures";
90 template <
typename FeatureT>
93 const std::string& key);
99 template <
typename FeatureT>
101 getSourceFeature(
const std::string& key);
108 template <
typename FeatureT>
111 const std::string& key);
117 template <
typename FeatureT>
119 getTargetFeature(
const std::string& key);
126 template <
typename FeatureT>
128 setDistanceThreshold(
double thresh,
const std::string& key);
140 template <
typename FeatureT>
142 setFeatureRepresentation(
144 const std::string& key);
153 getRemainingCorrespondences(*input_correspondences_, correspondences);
176 using FeaturesMap = std::unordered_map<std::string, FeatureContainerInterface::Ptr>;
188 template <
typename FeatureT>
212 inline FeatureCloudConstPtr
215 return (source_features_);
224 inline FeatureCloudConstPtr
227 return (target_features_);
239 if (!source_features_ || !target_features_)
241 return (source_features_->size() > 0 && target_features_->size() > 0);
250 feature_representation_ =
fr;
262 if (!feature_representation_)
270 if (!feature_representation_->isValid(
feat_src) ||
271 !feature_representation_->isValid(
feat_tgt)) {
272 PCL_ERROR(
"[pcl::registration::%s::getCorrespondenceScore] Invalid feature "
273 "representation given!\n",
274 this->getClassName().
c_str());
275 return (std::numeric_limits<double>::max());
280 Eigen::VectorXf::Zero(feature_representation_->getNumberOfDimensions());
283 Eigen::VectorXf::Zero(feature_representation_->getNumberOfDimensions());
298 return (getCorrespondenceScore(index) < thresh_ * thresh_);
302 FeatureCloudConstPtr source_features_, target_features_;
303 SearchMethod search_method_;
309 PointRepresentationConstPtr feature_representation_;
315#include <pcl/registration/impl/correspondence_rejection_features.hpp>
Iterator class for point clouds with or without given indices.
shared_ptr< const PointCloud< PointT > > ConstPtr
shared_ptr< const PointRepresentation< PointT > > ConstPtr
An inner class containing pointers to the source and target feature clouds and the parameters needed ...
typename pcl::PointCloud< FeatureT >::ConstPtr FeatureCloudConstPtr
~FeatureContainer()
Empty destructor.
FeatureCloudConstPtr getTargetFeature()
FeatureCloudConstPtr getSourceFeature()
void setDistanceThreshold(double thresh)
void setFeatureRepresentation(const PointRepresentationConstPtr &fr)
Provide a boost shared pointer to a PointRepresentation to be used when comparing features.
void setSourceFeature(const FeatureCloudConstPtr &source_features)
bool isCorrespondenceValid(int index) override
Check whether the correspondence pair at the given index is valid by computing the score and testing ...
typename pcl::PointRepresentation< FeatureT >::ConstPtr PointRepresentationConstPtr
double getCorrespondenceScore(int index) override
Obtain a score between a pair of correspondences.
std::function< int( const pcl::PointCloud< FeatureT > &, int, pcl::Indices &, std::vector< float > &)> SearchMethod
void setTargetFeature(const FeatureCloudConstPtr &target_features)
virtual ~FeatureContainerInterface()=default
Empty destructor.
virtual double getCorrespondenceScore(int index)=0
virtual bool isCorrespondenceValid(int index)=0
CorrespondenceRejectorFeatures implements a correspondence rejection method based on a set of feature...
void getRemainingCorrespondences(const pcl::Correspondences &original_correspondences, pcl::Correspondences &remaining_correspondences) override
Get a list of valid correspondences after rejection from the original set of correspondences.
float max_distance_
The maximum distance threshold between two correspondent points in source <-> target.
bool hasValidFeatures()
Test that all features are valid (i.e., does each key have a valid source cloud, target cloud,...
CorrespondenceRejectorFeatures()
Empty constructor.
FeaturesMap features_map_
An STL map containing features to use when performing the correspondence search.
std::unordered_map< std::string, FeatureContainerInterface::Ptr > FeaturesMap
shared_ptr< const CorrespondenceRejectorFeatures > ConstPtr
~CorrespondenceRejectorFeatures()
Empty destructor.
void applyRejection(pcl::Correspondences &correspondences) override
Apply the rejection algorithm.
CorrespondenceRejector represents the base class for correspondence rejection methods
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences