Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
transformation_estimation_point_to_point_robust.h
1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2011, Willow Garage, Inc.
6 * Copyright (c) 2012-, Open Perception, Inc.
7 *
8 * All rights reserved.
9 */
10
11#pragma once
12
13#include <pcl/registration/transformation_estimation.h>
14#include <pcl/cloud_iterator.h>
15#include <pcl/pcl_config.h> // for PCL_NO_PRECOMPILE
16
17namespace pcl {
18namespace registration {
19/** @b TransformationEstimationPointToPointRobust implements SVD-based estimation of
20 * the transformation aligning the given correspondences for minimizing the Welsch
21 * function instead of L2-norm, For additional details, see "Fast and Robust Iterative
22 * Closest Point", Juyong Zhang, Yuxin Yao, Bailin Deng, 2021.
23 * \note The class is templated on the source and target point types as well as on the
24 * output scalar of the transformation matrix (i.e., float or double). Default: float.
25 * \author Yuxin Yao
26 * \ingroup registration
27 */
28template <typename PointSource, typename PointTarget, typename Scalar = float>
30: public TransformationEstimation<PointSource, PointTarget, Scalar> {
31public:
32 using Ptr = shared_ptr<
34 using ConstPtr =
35 shared_ptr<const TransformationEstimationPointToPointRobust<PointSource,
36 PointTarget,
37 Scalar>>;
38
39 using Matrix4 =
41
42 /** \brief Constructor */
44
46
47 /** \brief Estimate a rigid rotation transformation between a source and a target
48 * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
49 * \param[in] cloud_tgt the target point cloud dataset
50 * \param[out] transformation_matrix the resultant transformation matrix
51 */
52 inline void
54 const pcl::PointCloud<PointTarget>& cloud_tgt,
55 Matrix4& transformation_matrix) const override;
56
57 /** \brief Estimate a rigid rotation transformation between a source and a target
58 * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
59 * \param[in] indices_src the vector of indices describing the points of interest in
60 * \a cloud_src
61 * \param[in] cloud_tgt the target point cloud dataset
62 * \param[out] transformation_matrix the resultant transformation matrix
63 */
64 inline void
66 const pcl::Indices& indices_src,
67 const pcl::PointCloud<PointTarget>& cloud_tgt,
68 Matrix4& transformation_matrix) const override;
69
70 /** \brief Estimate a rigid rotation transformation between a source and a target
71 * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
72 * \param[in] indices_src the vector of indices describing the points of interest in
73 * \a cloud_src
74 * \param[in] cloud_tgt the target point cloud dataset
75 * \param[in] indices_tgt the vector of indices describing the correspondences of the
76 * interest points from \a indices_src
77 * \param[out] transformation_matrix the resultant transformation matrix
78 */
79 inline void
81 const pcl::Indices& indices_src,
82 const pcl::PointCloud<PointTarget>& cloud_tgt,
83 const pcl::Indices& indices_tgt,
84 Matrix4& transformation_matrix) const override;
85
86 /** \brief Estimate a rigid rotation transformation between a source and a target
87 * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
88 * \param[in] cloud_tgt the target point cloud dataset
89 * \param[in] correspondences the vector of correspondences between source and target
90 * point cloud \param[out] transformation_matrix the resultant transformation matrix
91 */
92 void
94 const pcl::PointCloud<PointTarget>& cloud_tgt,
95 const pcl::Correspondences& correspondences,
96 Matrix4& transformation_matrix) const override;
97
98 /** \brief Set the Welsch scale parameter used for robust reweighting.
99 *
100 * If set to a positive value, this exact sigma is used. If set to a negative
101 * value (default), sigma is estimated automatically from current correspondences.
102 * Smaller positive values increase outlier suppression, larger values make the
103 * estimator closer to standard least-squares behavior.
104 */
105 void
106 setSigma(Scalar sigma)
107 {
108 sigma_ = sigma;
109 };
110
111protected:
112 /** \brief Estimate a rigid rotation transformation between a source and a target
113 * \param[in] source_it an iterator over the source point cloud dataset
114 * \param[in] target_it an iterator over the target point cloud dataset
115 * \param[out] transformation_matrix the resultant transformation matrix
116 */
117 void
120 Matrix4& transformation_matrix) const;
121
122 /** \brief Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src
123 * * tgt' \param[in] cloud_src_demean the input source cloud, demeaned, in Eigen
124 * format \param[in] centroid_src the input source centroid, in Eigen format
125 * \param[in] cloud_tgt_demean the input target cloud, demeaned, in Eigen format
126 * \param[in] centroid_tgt the input target cloud, in Eigen format
127 * \param[out] transformation_matrix the resultant 4x4 rigid transformation matrix
128 */
129 virtual void
131 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_src_demean,
132 const Eigen::Matrix<Scalar, 4, 1>& centroid_src,
133 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_tgt_demean,
134 const Eigen::Matrix<Scalar, 4, 1>& centroid_tgt,
135 const Eigen::Matrix<Scalar, Eigen::Dynamic, 1>& weights,
136 Matrix4& transformation_matrix) const;
137
138 /** \brief Compute the 3D (X-Y-Z) centroid of a set of weighted points and return it
139 * as a 3D vector.
140 * \param[in] cloud_iterator an iterator over the input point cloud
141 * \param[in] weights the weights corresponding to points in the input point cloud
142 * \param[out] centroid the output centroid
143 * \return number of valid points used to determine the centroid. In case of dense
144 * point clouds, this is the same as the size of input cloud.
145 * \note if return value is 0, the centroid is not changed, thus not valid.
146 * The last component of the vector is set to 1, this allows to transform the centroid
147 * vector with 4x4 matrices.
148 * \ingroup common
149 */
150 template <typename PointT>
151 inline unsigned int
153 const Eigen::Matrix<Scalar, Eigen::Dynamic, 1>& weights,
154 Eigen::Matrix<Scalar, 4, 1>& centroid) const;
155
156 /** parameter for the Welsch function */
157 Scalar sigma_ = -1;
158};
159
160} // namespace registration
161} // namespace pcl
162
163#include <pcl/registration/impl/transformation_estimation_point_to_point_robust.hpp>
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
TransformationEstimation represents the base class for methods for transformation estimation based on...
TransformationEstimationPointToPointRobust implements SVD-based estimation of the transformation alig...
shared_ptr< TransformationEstimationPointToPointRobust< PointSource, PointTarget, Scalar > > Ptr
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
shared_ptr< const TransformationEstimationPointToPointRobust< PointSource, PointTarget, Scalar > > ConstPtr
void estimateRigidTransformation(const pcl::PointCloud< PointSource > &cloud_src, const pcl::PointCloud< PointTarget > &cloud_tgt, Matrix4 &transformation_matrix) const override
Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
virtual void getTransformationFromCorrelation(const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &cloud_src_demean, const Eigen::Matrix< Scalar, 4, 1 > &centroid_src, const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &cloud_tgt_demean, const Eigen::Matrix< Scalar, 4, 1 > &centroid_tgt, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &weights, Matrix4 &transformation_matrix) const
Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src.
void setSigma(Scalar sigma)
Set the Welsch scale parameter used for robust reweighting.
unsigned int computeWeighted3DCentroid(ConstCloudIterator< PointT > &cloud_iterator, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &weights, Eigen::Matrix< Scalar, 4, 1 > &centroid) const
Compute the 3D (X-Y-Z) centroid of a set of weighted points and return it as a 3D vector.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133