PCL - ICP代碼研讀(二十 ) - TransformationEstimation剛體變換估計

本文详细介绍了PCL库中TransformationEstimation类的基础,包括其模板类定义、构造函数和析构函数,以及四种估计刚体变换的不同接口。重点展示了如何通过对应向量、点云对、带索引的点云等输入来计算旋转矩阵。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ...
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值