Point Cloud Library (PCL)  1.7.0
transformation_validation.h
1 /*
2  * Software License Agreement (BSD License)
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  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 #ifndef PCL_REGISTRATION_TRANSFORMATION_VALIDATION_H_
41 #define PCL_REGISTRATION_TRANSFORMATION_VALIDATION_H_
42 
43 #include <pcl/correspondence.h>
44 #include <pcl/features/feature.h>
45 #include <pcl/common/transforms.h>
46 #include <pcl/registration/correspondence_types.h>
47 
48 namespace pcl
49 {
50  namespace registration
51  {
52  /** \brief TransformationValidation represents the base class for methods
53  * that validate the correctness of a transformation found through \ref TransformationEstimation.
54  *
55  * The inputs for a validation estimation can take any or all of the following:
56  *
57  * - source point cloud
58  * - target point cloud
59  * - estimated transformation between source and target
60  *
61  * The output is in the form of a score or a confidence measure.
62  *
63  * \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.
64  * \author Radu B. Rusu
65  * \ingroup registration
66  */
67  template <typename PointSource, typename PointTarget, typename Scalar = float>
69  {
70  public:
71  typedef Eigen::Matrix<Scalar, 4, 4> Matrix4;
72  typedef boost::shared_ptr<TransformationValidation<PointSource, PointTarget, Scalar> > Ptr;
73  typedef boost::shared_ptr<const TransformationValidation<PointSource, PointTarget, Scalar> > ConstPtr;
74 
78 
82 
85 
86  /** \brief Validate the given transformation with respect to the input cloud data, and return a score. Pure virtual.
87  *
88  * \param[in] cloud_src the source point cloud dataset
89  * \param[in] cloud_tgt the target point cloud dataset
90  * \param[out] transformation_matrix the transformation matrix
91  *
92  * \return the score or confidence measure for the given
93  * transformation_matrix with respect to the input data
94  */
95  virtual double
97  const PointCloudSourceConstPtr &cloud_src,
98  const PointCloudTargetConstPtr &cloud_tgt,
99  const Matrix4 &transformation_matrix) const = 0;
100 
101  /** \brief Comparator function for deciding which score is better after running the
102  * validation on multiple transforms. Pure virtual.
103  *
104  * \note For example, for Euclidean distances smaller is better, for inliers the oposite.
105  *
106  * \param[in] score1 the first value
107  * \param[in] score2 the second value
108  *
109  * \return true if score1 is better than score2
110  */
111  virtual bool
112  operator() (const double &score1, const double &score2) const = 0;
113 
114  /** \brief Check if the score is valid for a specific transformation. Pure virtual.
115  *
116  * \param[in] cloud_src the source point cloud dataset
117  * \param[in] cloud_tgt the target point cloud dataset
118  * \param[out] transformation_matrix the transformation matrix
119  *
120  * \return true if the transformation is valid, false otherwise.
121  */
122  virtual bool
123  isValid (
124  const PointCloudSourceConstPtr &cloud_src,
125  const PointCloudTargetConstPtr &cloud_tgt,
126  const Matrix4 &transformation_matrix) const = 0;
127  };
128  }
129 }
130 
131 #endif // PCL_REGISTRATION_TRANSFORMATION_VALIDATION_H_