Main MRPT website > C++ reference for MRPT 1.4.0
TMatchingPair.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef TMatchingPair_H
10 #define TMatchingPair_H
11 
12 #include <string>
13 #include <vector>
14 #include <mrpt/base/link_pragmas.h>
15 #include <mrpt/poses/poses_frwds.h>
16 
17 namespace mrpt
18 {
19  namespace utils
20  {
21 
22  // Pragma defined to ensure no structure packing, so we can use SSE2 vectorization on parts of this struture
23 #if defined(MRPT_IS_X86_AMD64)
24 #pragma pack(push,1)
25 #endif
26 
27  /** A structure for holding correspondences between two sets of points or points-like entities in 2D or 3D.
28  * \ingroup mrpt_base_grp
29  */
31  {
33  this_idx(0), other_idx(0),
34  this_x(0),this_y(0),this_z(0),
35  other_x(0),other_y(0),other_z(0),
36  errorSquareAfterTransformation(0)
37  {
38  }
39 
40  TMatchingPair( unsigned int _this_idx,unsigned int _other_idx, float _this_x, float _this_y,float _this_z, float _other_x,float _other_y,float _other_z ) :
41  this_idx(_this_idx), other_idx(_other_idx),
42  this_x(_this_x),this_y(_this_y),this_z(_this_z),
43  other_x(_other_x),other_y(_other_y),other_z(_other_z),
44  errorSquareAfterTransformation(0)
45  {
46  }
47 
48  unsigned int this_idx;
49  unsigned int other_idx;
50  float this_x,this_y,this_z;
51  float other_x,other_y,other_z;
53 
54  };
55 
56 #if defined(MRPT_IS_X86_AMD64)
57 #pragma pack(pop) // End of pack = 1
58 #endif
59 
60 
62 
63  /** A list of TMatchingPair
64  * \ingroup mrpt_base_grp
65  */
66  class BASE_IMPEXP TMatchingPairList : public std::vector<TMatchingPair>
67  {
68  public:
69  /** Checks if the given index from the "other" map appears in the list. */
70  bool indexOtherMapHasCorrespondence(size_t idx) const;
71  /** Saves the correspondences to a text file */
72  void dumpToFile(const std::string &fileName) const;
73  /** Saves the correspondences as a MATLAB script which draws them. */
74  void saveAsMATLABScript( const std::string &filName ) const;
75 
76  /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q"
77  * \f[ \sum\limits_i e_i \f]
78  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
79  * \sa squareErrorVector, overallSquareErrorAndPoints
80  */
81  float overallSquareError( const mrpt::poses::CPose2D &q ) const;
82 
83  /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q", and return the transformed points as well.
84  * \f[ \sum\limits_i e_i \f]
85  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
86  * \sa squareErrorVector
87  */
89  const mrpt::poses::CPose2D &q,
90  std::vector<float> &xs,
91  std::vector<float> &ys ) const;
92 
93 
94  /** Returns a vector with the square error between each pair of correspondences in the list, given the 2D transformation "q"
95  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
96  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
97  * \sa overallSquareError
98  */
99  void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector<float> &out_sqErrs ) const;
100 
101  /** Returns a vector with the square error between each pair of correspondences in the list and the transformed "other" (local) points, given the 2D transformation "q"
102  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
103  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
104  * \sa overallSquareError
105  */
107  const mrpt::poses::CPose2D &q,
108  std::vector<float> &out_sqErrs,
109  std::vector<float> &xs,
110  std::vector<float> &ys ) const;
111 
112  /** Test whether the given pair "p" is within the pairings */
113  bool contains (const TMatchingPair &p) const;
114  };
115 
116  /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx */
118 
119  /** A comparison operator */
121 
122  /** A comparison operator */
124 
125 
126  } // End of namespace
127 } // end of namespace
128 #endif
A class used to store a 2D pose.
Definition: CPose2D.h:37
A list of TMatchingPair.
Definition: TMatchingPair.h:67
void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector< float > &out_sqErrs) const
Returns a vector with the square error between each pair of correspondences in the list,...
bool contains(const TMatchingPair &p) const
Test whether the given pair "p" is within the pairings.
void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector< float > &out_sqErrs, std::vector< float > &xs, std::vector< float > &ys) const
Returns a vector with the square error between each pair of correspondences in the list and the trans...
bool indexOtherMapHasCorrespondence(size_t idx) const
Checks if the given index from the "other" map appears in the list.
float overallSquareError(const mrpt::poses::CPose2D &q) const
Computes the overall square error between the 2D points in the list of correspondences,...
void saveAsMATLABScript(const std::string &filName) const
Saves the correspondences as a MATLAB script which draws them.
float overallSquareErrorAndPoints(const mrpt::poses::CPose2D &q, std::vector< float > &xs, std::vector< float > &ys) const
Computes the overall square error between the 2D points in the list of correspondences,...
void dumpToFile(const std::string &fileName) const
Saves the correspondences to a text file.
bool BASE_IMPEXP operator==(const mrpt::utils::TCamera &a, const mrpt::utils::TCamera &b)
bool BASE_IMPEXP operator<(const TMatchingPair &a, const TMatchingPair &b)
A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx,...
TMatchingPair * TMatchingPairPtr
Definition: TMatchingPair.h:61
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
Definition: TMatchingPair.h:31
TMatchingPair(unsigned int _this_idx, unsigned int _other_idx, float _this_x, float _this_y, float _this_z, float _other_x, float _other_y, float _other_z)
Definition: TMatchingPair.h:40



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Fri Sep 3 01:11:30 UTC 2021