41 #ifndef PCL_REGISTRATION_H_
42 #define PCL_REGISTRATION_H_
45 #include <pcl/pcl_base.h>
46 #include <pcl/common/transforms.h>
47 #include <pcl/pcl_macros.h>
48 #include <pcl/search/kdtree.h>
49 #include <pcl/kdtree/kdtree_flann.h>
50 #include <pcl/registration/boost.h>
51 #include <pcl/registration/transformation_estimation.h>
52 #include <pcl/registration/correspondence_estimation.h>
53 #include <pcl/registration/correspondence_rejection.h>
61 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar =
float>
65 typedef Eigen::Matrix<Scalar, 4, 4>
Matrix4;
72 typedef boost::shared_ptr< Registration<PointSource, PointTarget, Scalar> >
Ptr;
73 typedef boost::shared_ptr< const Registration<PointSource, PointTarget, Scalar> >
ConstPtr;
127 , point_representation_ ()
222 bool force_no_recompute =
false)
225 if (force_no_recompute)
250 bool force_no_recompute =
false)
253 if ( force_no_recompute )
363 point_representation_ = point_representation;
370 template<
typename FunctionSignature>
inline bool
373 if (visualizerCallback != NULL)
387 getFitnessScore (
double max_range = std::numeric_limits<double>::max ());
395 getFitnessScore (
const std::vector<float> &distances_a,
const std::vector<float> &distances_b);
417 inline const std::string&
451 inline std::vector<CorrespondenceRejectorPtr>
570 boost::function<void(const pcl::PointCloud<PointSource> &cloud_src,
571 const std::vector<int> &indices_src,
583 std::vector<int> &indices, std::vector<float> &distances)
585 int k =
tree_->nearestKSearch (cloud, index, 1, indices, distances);
599 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
603 #include <pcl/registration/impl/registration.hpp>
605 #endif //#ifndef PCL_REGISTRATION_H_
boost::shared_ptr< const Registration< PointSource, PointTarget, Scalar > > ConstPtr
boost::shared_ptr< KdTree< PointT > > Ptr
pcl::PointCloud< PointTarget > PointCloudTarget
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
PointCloudTargetConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.
Registration represents the base registration class for general purpose, ICP-like methods...
void setCorrespondenceEstimation(const CorrespondenceEstimationPtr &ce)
Provide a pointer to the correspondence estimation object.
int ransac_iterations_
The number of iterations RANSAC should run for.
Abstract CorrespondenceEstimationBase class.
bool source_cloud_updated_
Variable that stores whether we have a new source cloud, meaning we need to pre-process it again...
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
PointCloudConstPtr const getInputCloud()
Get a pointer to the input point cloud dataset.
CorrespondencesPtr correspondences_
The set of correspondences determined at this ICP step.
boost::shared_ptr< Correspondences > CorrespondencesPtr
CorrespondenceEstimation::Ptr CorrespondenceEstimationPtr
pcl::registration::CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > CorrespondenceEstimation
double inlier_threshold_
The inlier distance threshold for the internal RANSAC outlier rejection loop.
TransformationEstimation represents the base class for methods for transformation estimation based on...
boost::shared_ptr< const PointRepresentation > PointRepresentationConstPtr
pcl::search::KdTree< PointSource > KdTreeReciprocal
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
bool searchForNeighbors(const PointCloudSource &cloud, int index, std::vector< int > &indices, std::vector< float > &distances)
Search for the closest nearest neighbor of a given point.
PointCloudSource::ConstPtr PointCloudSourceConstPtr
PointCloudSourceConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
virtual ~Registration()
destructor.
Eigen::Matrix< Scalar, 4, 4 > Matrix4
virtual void setInputSource(const PointCloudSourceConstPtr &cloud)
Provide a pointer to the input source (e.g., the point cloud that we want to align to the target) ...
virtual void computeTransformation(PointCloudSource &output, const Matrix4 &guess)=0
Abstract transformation computation method with initial guess.
bool registerVisualizationCallback(boost::function< FunctionSignature > &visualizerCallback)
Register the user callback function which will be called from registration thread in order to update ...
boost::shared_ptr< PointCloud< PointT > > Ptr
void setMaximumIterations(int nr_iterations)
Set the maximum number of iterations the internal optimization should run for.
void addCorrespondenceRejector(const CorrespondenceRejectorPtr &rejector)
Add a new correspondence rejector to the list.
const std::string & getClassName() const
Abstract class get name method.
KdTreePtr getSearchMethodTarget() const
Get a pointer to the search method used to find correspondences in the target cloud.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
boost::shared_ptr< CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > Ptr
CorrespondenceEstimation::ConstPtr CorrespondenceEstimationConstPtr
double getMaxCorrespondenceDistance()
Get the maximum distance threshold between two correspondent points in source <-> target...
int getMaximumIterations()
Get the maximum number of iterations the internal optimization should run for, as set by the user...
KdTree::PointRepresentationConstPtr PointRepresentationConstPtr
bool force_no_recompute_reciprocal_
A flag which, if set, means the tree operating on the source cloud will never be recomputed.
pcl::registration::TransformationEstimation< PointSource, PointTarget, Scalar > TransformationEstimation
boost::shared_ptr< TransformationEstimation< PointSource, PointTarget, Scalar > > Ptr
bool initCompute()
Internal computation initalization.
bool target_cloud_updated_
Variable that stores whether we have a new target cloud, meaning we need to pre-process it again...
void align(PointCloudSource &output)
Call the registration algorithm which estimates the transformation and returns the transformed source...
pcl::PointCloud< PointSource > PointCloudSource
PointCloudConstPtr input_
The input point cloud dataset.
double getTransformationEpsilon()
Get the transformation epsilon (maximum allowable difference between two consecutive transformations)...
boost::shared_ptr< const TransformationEstimation< PointSource, PointTarget, Scalar > > ConstPtr
boost::function< void(const pcl::PointCloud< PointSource > &cloud_src, const std::vector< int > &indices_src, const pcl::PointCloud< PointTarget > &cloud_tgt, const std::vector< int > &indices_tgt)> update_visualizer_
Callback function to update intermediate source point cloud position during it's registration to the ...
Matrix4 getLastIncrementalTransformation()
Get the last incremental transformation matrix estimated by the registration method.
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
bool hasConverged()
Return the state of convergence after the last align run.
boost::shared_ptr< const CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > ConstPtr
double getRANSACOutlierRejectionThreshold()
Get the inlier distance threshold for the internal outlier rejection loop as set by the user...
PCL_DEPRECATED(void setInputCloud(const PointCloudSourceConstPtr &cloud),"[pcl::registration::Registration::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.")
Provide a pointer to the input source (e.g., the point cloud that we want to align to the target) ...
Matrix4 previous_transformation_
The previous transformation matrix estimated by the registration method (used internally).
int min_number_correspondences_
The minimum number of correspondences that the algorithm needs before attempting to estimate the tran...
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
void setEuclideanFitnessEpsilon(double epsilon)
Set the maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the algorithm is considered to have converged.
void setTransformationEpsilon(double epsilon)
Set the transformation epsilon (maximum allowable difference between two consecutive transformations)...
PointCloudTarget::ConstPtr PointCloudTargetConstPtr
double transformation_epsilon_
The maximum difference between two consecutive transformations in order to consider convergence (user...
double euclidean_fitness_epsilon_
The maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the algorithm is considered to have converged.
bool removeCorrespondenceRejector(unsigned int i)
Remove the i-th correspondence rejector in the list.
void setTransformationEstimation(const TransformationEstimationPtr &te)
Provide a pointer to the transformation estimation object.
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
The list of correspondence rejectors to use.
boost::shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Matrix4 transformation_
The transformation matrix estimated by the registration method.
TransformationEstimation::ConstPtr TransformationEstimationConstPtr
KdTree::Ptr KdTreeReciprocalPtr
double getEuclideanFitnessEpsilon()
Get the maximum allowed distance error before the algorithm will be considered to have converged...
PointCloudTarget::Ptr PointCloudTargetPtr
void setRANSACIterations(int ransac_iterations)
Set the number of iterations RANSAC should run for.
void clearCorrespondenceRejectors()
Clear the list of correspondence rejectors.
void setRANSACOutlierRejectionThreshold(double inlier_threshold)
Set the inlier distance threshold for the internal RANSAC outlier rejection loop. ...
Matrix4 getFinalTransformation()
Get the final transformation matrix estimated by the registration method.
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a boost shared pointer to the PointRepresentation to be used when comparing points...
void setSearchMethodTarget(const KdTreePtr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the target cloud...
KdTreeReciprocalPtr getSearchMethodSource() const
Get a pointer to the search method used to find correspondences in the source cloud.
double corr_dist_threshold_
The maximum distance threshold between two correspondent points in source <-> target.
PointCloudSource::Ptr PointCloudSourcePtr
TransformationEstimation::Ptr TransformationEstimationPtr
bool converged_
Holds internal convergence state, given user parameters.
PointCloudTargetConstPtr target_
The input point cloud dataset target.
KdTreePtr tree_
A pointer to the spatial search object.
pcl::registration::CorrespondenceRejector::Ptr CorrespondenceRejectorPtr
boost::shared_ptr< CorrespondenceRejector > Ptr
std::string reg_name_
The registration method name.
std::vector< CorrespondenceRejectorPtr > getCorrespondenceRejectors()
Get the list of correspondence rejectors.
bool initComputeReciprocal()
Internal computation when reciprocal lookup is needed.
boost::shared_ptr< KdTree< PointT > > Ptr
virtual void setInputTarget(const PointCloudTargetConstPtr &cloud)
Provide a pointer to the input target (e.g., the point cloud that we want to align the input source t...
pcl::search::KdTree< PointTarget > KdTree
void setMaxCorrespondenceDistance(double distance_threshold)
Set the maximum distance threshold between two correspondent points in source <-> target...
Matrix4 final_transformation_
The final transformation matrix estimated by the registration method after N iterations.
int nr_iterations_
The number of iterations the internal optimization ran for (used internally).
Registration()
Empty constructor.
double getFitnessScore(double max_range=std::numeric_limits< double >::max())
Obtain the Euclidean fitness score (e.g., sum of squared distances from the source to the target) ...
void setSearchMethodSource(const KdTreeReciprocalPtr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the source cloud (usually used...
double getRANSACIterations()
Get the number of iterations RANSAC should run for, as set by the user.
int max_iterations_
The maximum number of iterations the internal optimization should run for.
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object of the source.
pcl::search::KdTree< PointTarget >::Ptr KdTreePtr