Point Cloud Library (PCL)  1.8.1
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 #ifndef PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_H_
39 #define PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_H_
40 
41 #include <pcl/registration/transformation_estimation.h>
42 
43 namespace pcl
44 {
45  namespace registration
46  {
47  /** @b TransformationEstimation2D implements a simple 2D rigid transformation
48  * estimation (x, y, theta) for a given pair of datasets.
49  *
50  * The two datasets should already be transformed so that the reference plane
51  * equals z = 0.
52  *
53  * \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.
54  *
55  * \author Suat Gedikli
56  * \ingroup registration
57  */
58  template <typename PointSource, typename PointTarget, typename Scalar = float>
59  class TransformationEstimation2D : public TransformationEstimation<PointSource, PointTarget, Scalar>
60  {
61  public:
62  typedef boost::shared_ptr<TransformationEstimation2D<PointSource, PointTarget, Scalar> > Ptr;
63  typedef boost::shared_ptr<const TransformationEstimation2D<PointSource, PointTarget, Scalar> > ConstPtr;
64 
66 
69 
70  /** \brief Estimate a rigid transformation between a source and a target point cloud in 2D.
71  * \param[in] cloud_src the source point cloud dataset
72  * \param[in] cloud_tgt the target point cloud dataset
73  * \param[out] transformation_matrix the resultant transformation matrix
74  */
75  inline void
77  const pcl::PointCloud<PointSource> &cloud_src,
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 in 2D.
82  * \param[in] cloud_src the source point cloud dataset
83  * \param[in] indices_src the vector of indices describing the points of interest in \a cloud_src
84  * \param[in] cloud_tgt the target point cloud dataset
85  * \param[out] transformation_matrix the resultant transformation matrix
86  */
87  inline void
89  const pcl::PointCloud<PointSource> &cloud_src,
90  const std::vector<int> &indices_src,
91  const pcl::PointCloud<PointTarget> &cloud_tgt,
92  Matrix4 &transformation_matrix) const;
93 
94  /** \brief Estimate a rigid transformation between a source and a target point cloud in 2D.
95  * \param[in] cloud_src the source point cloud dataset
96  * \param[in] indices_src the vector of indices describing the points of interest in \a cloud_src
97  * \param[in] cloud_tgt the target point cloud dataset
98  * \param[in] indices_tgt the vector of indices describing the correspondences of the interst points from \a indices_src
99  * \param[out] transformation_matrix the resultant transformation matrix
100  */
101  virtual void
103  const pcl::PointCloud<PointSource> &cloud_src,
104  const std::vector<int> &indices_src,
105  const pcl::PointCloud<PointTarget> &cloud_tgt,
106  const std::vector<int> &indices_tgt,
107  Matrix4 &transformation_matrix) const;
108 
109  /** \brief Estimate a rigid transformation between a source and a target point cloud in 2D.
110  * \param[in] cloud_src the source point cloud dataset
111  * \param[in] cloud_tgt the target point cloud dataset
112  * \param[in] correspondences the vector of correspondences between source and target point cloud
113  * \param[out] transformation_matrix the resultant transformation matrix
114  */
115  virtual void
117  const pcl::PointCloud<PointSource> &cloud_src,
118  const pcl::PointCloud<PointTarget> &cloud_tgt,
119  const pcl::Correspondences &correspondences,
120  Matrix4 &transformation_matrix) const;
121 
122  protected:
123 
124  /** \brief Estimate a rigid rotation transformation between a source and a target
125  * \param[in] source_it an iterator over the source point cloud dataset
126  * \param[in] target_it an iterator over the target point cloud dataset
127  * \param[out] transformation_matrix the resultant transformation matrix
128  */
129  void
132  Matrix4 &transformation_matrix) const;
133 
134  /** \brief Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src * tgt'
135  * \param[in] cloud_src_demean the input source cloud, demeaned, in Eigen format
136  * \param[in] centroid_src the input source centroid, in Eigen format
137  * \param[in] cloud_tgt_demean the input target cloud, demeaned, in Eigen format
138  * \param[in] centroid_tgt the input target cloud, in Eigen format
139  * \param[out] transformation_matrix the resultant 4x4 rigid transformation matrix
140  */
141  void
143  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_src_demean,
144  const Eigen::Matrix<Scalar, 4, 1> &centroid_src,
145  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &cloud_tgt_demean,
146  const Eigen::Matrix<Scalar, 4, 1> &centroid_tgt,
147  Matrix4 &transformation_matrix) const;
148  };
149 
150  }
151 }
152 
153 #include <pcl/registration/impl/transformation_estimation_2D.hpp>
154 
155 #endif /* PCL_REGISTRATION_TRANSFORMATION_ESTIMATION_2D_H_ */
Iterator class for point clouds with or without given indices.
boost::shared_ptr< const TransformationEstimation2D< PointSource, PointTarget, Scalar > > ConstPtr
TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
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.
boost::shared_ptr< TransformationEstimation2D< PointSource, PointTarget, Scalar > > Ptr
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 * tgt&#39;.
TransformationEstimation represents the base class for methods for transformation estimation based on...
TransformationEstimation2D implements a simple 2D rigid transformation estimation (x...