Point Cloud Library (PCL)  1.11.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
poses_from_matches.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, 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 #pragma once
39 
40 #include <pcl/memory.h>
41 #include <pcl/pcl_macros.h>
42 #include <pcl/correspondence.h>
43 
44 namespace pcl
45 {
46  /**
47  * \brief calculate 3D transformation based on point correspondences
48  * \author Bastian Steder
49  * \ingroup common
50  */
51  class PCL_EXPORTS PosesFromMatches
52  {
53  public:
54  // =====STRUCTS=====
55  //! Parameters used in this class
56  struct PCL_EXPORTS Parameters
57  {
58  float max_correspondence_distance_error = 0.2f; // As a fraction
59  };
60 
61  //! A result of the pose estimation process
62  struct PoseEstimate
63  {
64  Eigen::Affine3f transformation = Eigen::Affine3f::Identity (); //!< The estimated transformation between the two coordinate systems
65  float score = 0; //!< An estimate in [0,1], how good the estimated pose is
66  std::vector<int> correspondence_indices; //!< The indices of the used correspondences
67 
68  struct IsBetter
69  {
70  bool operator()(const PoseEstimate& pe1, const PoseEstimate& pe2) const { return pe1.score>pe2.score;}
71  };
72  public:
74  };
75 
76  // =====TYPEDEFS=====
77  using PoseEstimatesVector = std::vector<PoseEstimate, Eigen::aligned_allocator<PoseEstimate> >;
78 
79 
80  // =====STATIC METHODS=====
81 
82  // =====PUBLIC METHODS=====
83  /** Use single 6DOF correspondences to estimate transformations between the coordinate systems.
84  * Use max_no_of_results=-1 to use all.
85  * It is assumed, that the correspondences are sorted from good to bad. */
86  void
87  estimatePosesUsing1Correspondence (
88  const PointCorrespondences6DVector& correspondences,
89  int max_no_of_results, PoseEstimatesVector& pose_estimates) const;
90 
91  /** Use pairs of 6DOF correspondences to estimate transformations between the coordinate systems.
92  * It is assumed, that the correspondences are sorted from good to bad. */
93  void
94  estimatePosesUsing2Correspondences (
95  const PointCorrespondences6DVector& correspondences,
96  int max_no_of_tested_combinations, int max_no_of_results,
97  PoseEstimatesVector& pose_estimates) const;
98 
99  /** Use triples of 6DOF correspondences to estimate transformations between the coordinate systems.
100  * It is assumed, that the correspondences are sorted from good to bad. */
101  void
102  estimatePosesUsing3Correspondences (
103  const PointCorrespondences6DVector& correspondences,
104  int max_no_of_tested_combinations, int max_no_of_results,
105  PoseEstimatesVector& pose_estimates) const;
106 
107  /// Get a reference to the parameters struct
108  Parameters&
109  getParameters () { return parameters_; }
110 
111  protected:
112  // =====PROTECTED MEMBER VARIABLES=====
114 
115  };
116 
117 } // end namespace pcl
std::vector< int > correspondence_indices
The indices of the used correspondences.
bool operator()(const PoseEstimate &pe1, const PoseEstimate &pe2) const
Parameters & getParameters()
Get a reference to the parameters struct.
std::vector< PointCorrespondence6D, Eigen::aligned_allocator< PointCorrespondence6D > > PointCorrespondences6DVector
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:63
calculate 3D transformation based on point correspondences
A result of the pose estimation process.
std::vector< PoseEstimate, Eigen::aligned_allocator< PoseEstimate > > PoseEstimatesVector
float score
An estimate in [0,1], how good the estimated pose is.
Parameters used in this class.