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