Point Cloud Library (PCL)  1.11.1-dev
transformation_estimation_2D.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  *
37  */
38 
39 #pragma once
40 
41 #include <pcl/registration/transformation_estimation.h>
42 
43 namespace pcl {
44 namespace registration {
45 /** @b TransformationEstimation2D implements a simple 2D rigid transformation
46  * estimation (x, y, theta) for a given pair of datasets.
47  *
48  * The two datasets should already be transformed so that the reference plane
49  * equals z = 0.
50  *
51  * \note The class is templated on the source and target point types as well as on the
52  * output scalar of the transformation matrix (i.e., float or double). Default: float.
53  *
54  * \author Suat Gedikli
55  * \ingroup registration
56  */
57 template <typename PointSource, typename PointTarget, typename Scalar = float>
59 : public TransformationEstimation<PointSource, PointTarget, Scalar> {
60 public:
61  using Ptr = shared_ptr<TransformationEstimation2D<PointSource, PointTarget, Scalar>>;
62  using ConstPtr =
63  shared_ptr<const TransformationEstimation2D<PointSource, PointTarget, Scalar>>;
64 
65  using Matrix4 =
67 
70 
71  /** \brief Estimate a rigid transformation between a source and a target point cloud
72  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] cloud_tgt the
73  * target point cloud dataset \param[out] transformation_matrix the resultant
74  * transformation matrix
75  */
76  inline void
78  const pcl::PointCloud<PointTarget>& cloud_tgt,
79  Matrix4& transformation_matrix) const;
80 
81  /** \brief Estimate a rigid transformation between a source and a target point cloud
82  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src
83  * the vector of indices describing the points of interest in \a cloud_src \param[in]
84  * cloud_tgt the target point cloud dataset \param[out] transformation_matrix the
85  * resultant transformation matrix
86  */
87  inline void
89  const std::vector<int>& indices_src,
90  const pcl::PointCloud<PointTarget>& cloud_tgt,
91  Matrix4& transformation_matrix) const;
92 
93  /** \brief Estimate a rigid transformation between a source and a target point cloud
94  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src
95  * the vector of indices describing the points of interest in \a cloud_src \param[in]
96  * cloud_tgt the target point cloud dataset \param[in] indices_tgt the vector of
97  * indices describing the correspondences of the interest points from \a indices_src
98  * \param[out] transformation_matrix the resultant transformation matrix
99  */
100  virtual void
102  const std::vector<int>& indices_src,
103  const pcl::PointCloud<PointTarget>& cloud_tgt,
104  const std::vector<int>& indices_tgt,
105  Matrix4& transformation_matrix) const;
106 
107  /** \brief Estimate a rigid transformation between a source and a target point cloud
108  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] cloud_tgt the
109  * target point cloud dataset \param[in] correspondences the vector of correspondences
110  * between source and target point cloud \param[out] transformation_matrix the
111  * resultant transformation matrix
112  */
113  virtual void
115  const pcl::PointCloud<PointTarget>& cloud_tgt,
116  const pcl::Correspondences& correspondences,
117  Matrix4& transformation_matrix) const;
118 
119 protected:
120  /** \brief Estimate a rigid rotation transformation between a source and a target
121  * \param[in] source_it an iterator over the source point cloud dataset
122  * \param[in] target_it an iterator over the target point cloud dataset
123  * \param[out] transformation_matrix the resultant transformation matrix
124  */
125  void
128  Matrix4& transformation_matrix) const;
129 
130  /** \brief Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src
131  * * tgt' \param[in] cloud_src_demean the input source cloud, demeaned, in Eigen
132  * format \param[in] centroid_src the input source centroid, in Eigen format
133  * \param[in] cloud_tgt_demean the input target cloud, demeaned, in Eigen format
134  * \param[in] centroid_tgt the input target cloud, in Eigen format
135  * \param[out] transformation_matrix the resultant 4x4 rigid transformation matrix
136  */
137  void
139  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_src_demean,
140  const Eigen::Matrix<Scalar, 4, 1>& centroid_src,
141  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_tgt_demean,
142  const Eigen::Matrix<Scalar, 4, 1>& centroid_tgt,
143  Matrix4& transformation_matrix) const;
144 };
145 
146 } // namespace registration
147 } // namespace pcl
148 
149 #include <pcl/registration/impl/transformation_estimation_2D.hpp>
pcl
Definition: convolution.h:46
pcl::registration::TransformationEstimation::Matrix4
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: transformation_estimation.h:64
pcl::registration::TransformationEstimation2D::estimateRigidTransformation
void estimateRigidTransformation(const pcl::PointCloud< PointSource > &cloud_src, const pcl::PointCloud< PointTarget > &cloud_tgt, Matrix4 &transformation_matrix) const
Estimate a rigid transformation between a source and a target point cloud in 2D.
Definition: transformation_estimation_2D.hpp:48
pcl::registration::TransformationEstimation2D::getTransformationFromCorrelation
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, Matrix4 &transformation_matrix) const
Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src.
Definition: transformation_estimation_2D.hpp:158
pcl::PointCloud< PointSource >
pcl::registration::TransformationEstimation2D::~TransformationEstimation2D
virtual ~TransformationEstimation2D()
Definition: transformation_estimation_2D.h:69
pcl::registration::TransformationEstimation2D::ConstPtr
shared_ptr< const TransformationEstimation2D< PointSource, PointTarget, Scalar > > ConstPtr
Definition: transformation_estimation_2D.h:63
pcl::registration::TransformationEstimation2D::TransformationEstimation2D
TransformationEstimation2D()
Definition: transformation_estimation_2D.h:68
pcl::registration::TransformationEstimation2D
TransformationEstimation2D implements a simple 2D rigid transformation estimation (x,...
Definition: transformation_estimation_2D.h:58
pcl::registration::TransformationEstimation2D::Ptr
shared_ptr< TransformationEstimation2D< PointSource, PointTarget, Scalar > > Ptr
Definition: transformation_estimation_2D.h:61
pcl::registration::TransformationEstimation2D::Matrix4
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
Definition: transformation_estimation_2D.h:66
pcl::ConstCloudIterator
Iterator class for point clouds with or without given indices.
Definition: cloud_iterator.h:120
pcl::Correspondences
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Definition: correspondence.h:89
pcl::registration::TransformationEstimation
TransformationEstimation represents the base class for methods for transformation estimation based on...
Definition: transformation_estimation.h:62