PCL - ICP代碼研讀(二十 ) - TransformationEstimation剛體變換估計
前言
TransformationEstimation
是一個抽象類別,提供了多個用於估計剛體變換的介面。
本篇對應到transformation_estimation.h
這個檔案。
TransformationEstimation
/**
* 使用:
* 1. 表示配對的向量
* 2. 兩個相同大小的點雲
* 3. 一個帶有indices的點雲與另外一個點雲
* 4. 兩個帶有相同大小indices的點雲
**/
/** \brief TransformationEstimation represents the base class for methods for
* transformation estimation based on:
* - correspondence vectors
* - two point clouds (source and target) of the same size
* - a point cloud with a set of indices (source), and another point cloud (target)
* - two point clouds with two sets of indices (source and target) of the same size
*
* \note The class is templated on the source and target point types as well as on the
* output scalar of the transformation matrix (i.e., float or double). Default: float.
* \author Dirk Holz, Radu B. Rusu
* \ingroup registration
*/
// 模板參數還可以指定default value
template <typename PointSource, typename PointTarget, typename Scalar = float>
class TransformationEstimation {
public:
using
定義名稱,方便後續使用:
using Matrix4 = Eigen::Matrix<Scalar, 4, 4>;
using Ptr = shared_ptr<TransformationEstimation<PointSource, PointTarget, Scalar>>;
using ConstPtr =
shared_ptr<const TransformationEstimation<PointSource, PointTarget, Scalar>>;
constructor和destructor
TransformationEstimation(){};
virtual ~TransformationEstimation(){};
估計剛體變換的函數
提供四個不同接口、用於估計剛體變換的函數。注意到它們都是虛擬函數,由TransformationEstimation
的子類別各自實作。
第一個函數接受source點雲和target點雲作為輸入:
/** \brief Estimate a rigid rotation transformation between a source and a target
* point cloud. \param[in] cloud_src the source point cloud dataset \param[in]
* cloud_tgt the target point cloud dataset \param[out] transformation_matrix the
* resultant transformation matrix
*/
virtual void
estimateRigidTransformation(const pcl::PointCloud<PointSource>& cloud_src,
const pcl::PointCloud<PointTarget>& cloud_tgt,
Matrix4& transformation_matrix) const = 0;
第二個函數接受source點雲及索引和target點雲作為輸入:
/** \brief Estimate a rigid rotation transformation between a source and a target
* point cloud. \param[in] cloud_src the source point cloud dataset \param[in]
* indices_src the vector of indices describing the points of interest in \a cloud_src
* \param[in] cloud_tgt the target point cloud dataset
* \param[out] transformation_matrix the resultant transformation matrix
*/
// src有指定索引
virtual void
estimateRigidTransformation(const pcl::PointCloud<PointSource>& cloud_src,
const pcl::Indices& indices_src,
const pcl::PointCloud<PointTarget>& cloud_tgt,
Matrix4& transformation_matrix) const = 0;
第三個函數接受source點雲及索引和target點雲及索引作為輸入:
/** \brief Estimate a rigid rotation transformation between a source and a target
* point cloud. \param[in] cloud_src the source point cloud dataset \param[in]
* indices_src the vector of indices describing the points of interest in \a cloud_src
* \param[in] cloud_tgt the target point cloud dataset
* \param[in] indices_tgt the vector of indices describing the correspondences of the
* interest points from \a indices_src
* \param[out] transformation_matrix the resultant transformation matrix
*/
// src跟tgt都有指定索引
virtual void
estimateRigidTransformation(const pcl::PointCloud<PointSource>& cloud_src,
const pcl::Indices& indices_src,
const pcl::PointCloud<PointTarget>& cloud_tgt,
const pcl::Indices& indices_tgt,
Matrix4& transformation_matrix) const = 0;
第四個函數接受source點雲、target點雲和多組配對作為輸入:
/** \brief Estimate a rigid rotation transformation between a source and a target
* point cloud. \param[in] cloud_src the source point cloud dataset \param[in]
* cloud_tgt the target point cloud dataset \param[in] correspondences the vector of
* correspondences between source and target point cloud \param[out]
* transformation_matrix the resultant transformation matrix
*/
/**
* pcl::Correspondences: pcl::Correspondence所組成的向量,
* pcl::Correspondence有index_query和index_match,
* 分別表示source點雲裡的索引和target點雲裡的索引
**/
virtual void
estimateRigidTransformation(const pcl::PointCloud<PointSource>& cloud_src,
const pcl::PointCloud<PointTarget>& cloud_tgt,
const pcl::Correspondences& correspondences,
Matrix4& transformation_matrix) const = 0;
// using ...
};