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