PCL - ICP代碼研讀(十四 ) - CorrespondenceEstimation架構
前言
CorrespondenceEstimation
類別繼承自抽象類別CorrespondenceEstimationBase
(參考PCL - ICP代碼研讀(十二 ) - CorrespondenceEstimationBase架構),實現了determineCorrespondences
和determineReciprocalCorrespondences
函數,可以用於估計兩點雲間的配對。
本篇對應到correspondence_estimation.h
這個檔案。
CorrespondenceEstimation
/** \brief @b CorrespondenceEstimation represents the base class for
* determining correspondences between target and query point
* sets/features.
*
* Code example:
*
* \code
* pcl::PointCloud<pcl::PointXYZRGBA>::Ptr source, target;
* // ... read or fill in source and target
* pcl::CorrespondenceEstimation<pcl::PointXYZ, pcl::PointXYZ> est;
* est.setInputSource (source);
* est.setInputTarget (target);
*
* pcl::Correspondences all_correspondences;
* // Determine all reciprocal correspondences
* est.determineReciprocalCorrespondences (all_correspondences);
* \endcode
*
* \author Radu B. Rusu, Michael Dixon, Dirk Holz
* \ingroup registration
*/
template <typename PointSource, typename PointTarget, typename Scalar = float>
class CorrespondenceEstimation
: public CorrespondenceEstimationBase<PointSource, PointTarget, Scalar> {
public:
using
定義名稱,方便後續使用:
using Ptr = shared_ptr<CorrespondenceEstimation<PointSource, PointTarget, Scalar>>;
using ConstPtr =
shared_ptr<const CorrespondenceEstimation<PointSource, PointTarget, Scalar>>;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
point_representation_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
input_transformed_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::tree_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
tree_reciprocal_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::corr_name_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::target_indices_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::getClassName;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::initCompute;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::
initComputeReciprocal;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::indices_;
using CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::input_fields_;
using PCLBase<PointSource>::deinitCompute;
using KdTree = pcl::search::KdTree<PointTarget>;
using KdTreePtr = typename KdTree::Ptr;
using PointCloudSource = pcl::PointCloud<PointSource>;
using PointCloudSourcePtr = typename PointCloudSource::Ptr;
using PointCloudSourceConstPtr = typename PointCloudSource::ConstPtr;
using PointCloudTarget = pcl::PointCloud<PointTarget>;
using PointCloudTargetPtr = typename PointCloudTarget::Ptr;
using PointCloudTargetConstPtr = typename PointCloudTarget::ConstPtr;
using PointRepresentationConstPtr = typename KdTree::PointRepresentationConstPtr;
constructor和destructor
/** \brief Empty constructor. */
CorrespondenceEstimation() { corr_name_ = "CorrespondenceEstimation"; }
/** \brief Empty destructor */
~CorrespondenceEstimation() {}
determineCorrespondences和determineReciprocalCorrespondences函數
這兩個函數是CorrespondenceEstimation
類別的核心,它們會尋找兩點雲中距離小於max_distance
者當作點對,並填入correspondences
這個容器裡。
如果不要求兩點互為最近鄰,則使用determineCorrespondences
函數,否則使用determineReciprocalCorrespondences
函數。
/** \brief Determine the correspondences between input and target cloud.
* \param[out] correspondences the found correspondences (index of query point, index
* of target point, distance) \param[in] max_distance maximum allowed distance between
* correspondences
*/
void
determineCorrespondences(
pcl::Correspondences& correspondences,
double max_distance = std::numeric_limits<double>::max()) override;
/** \brief Determine the reciprocal correspondences between input and target cloud.
* A correspondence is considered reciprocal if both Src_i has Tgt_i as a
* correspondence, and Tgt_i has Src_i as one.
*
* \param[out] correspondences the found correspondences (index of query and target
* point, distance) \param[in] max_distance maximum allowed distance between
* correspondences
*/
void
determineReciprocalCorrespondences(
pcl::Correspondences& correspondences,
double max_distance = std::numeric_limits<double>::max()) override;
clone函數
返回一份自己的克隆。
/** \brief Clone and cast to CorrespondenceEstimationBase */
typename CorrespondenceEstimationBase<PointSource, PointTarget, Scalar>::Ptr
clone() const override
{
Ptr copy(new CorrespondenceEstimation<PointSource, PointTarget, Scalar>(*this));
return (copy);
}
};
} // namespace registration
} // namespace pcl
#include <pcl/registration/impl/correspondence_estimation.hpp>