Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 #include <ostream>
17 
18 namespace mrpt
19 {
20  namespace utils
21  {
22 
23  // Pragma defined to ensure no structure packing, so we can use SSE2 vectorization on parts of this struture
24 #if defined(MRPT_IS_X86_AMD64)
25 #pragma pack(push,1)
26 #endif
27 
28  /** A structure for holding correspondences between two sets of points or points-like entities in 2D or 3D.
29  * \ingroup mrpt_base_grp
30  */
32  {
34  this_idx(0), other_idx(0),
35  this_x(0),this_y(0),this_z(0),
36  other_x(0),other_y(0),other_z(0),
37  errorSquareAfterTransformation(0)
38  {
39  }
40 
41  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 ) :
42  this_idx(_this_idx), other_idx(_other_idx),
43  this_x(_this_x),this_y(_this_y),this_z(_this_z),
44  other_x(_other_x),other_y(_other_y),other_z(_other_z),
45  errorSquareAfterTransformation(0)
46  {
47  }
48 
49  friend std::ostream& operator<<(
50  std::ostream& o,
51  const mrpt::utils::TMatchingPair& pair) {
52  o << "[" << pair.this_idx << "->" << pair.other_idx << "]" << ": "
53  << "(" << pair.this_x << "," << pair.this_y << "," << pair.this_z << ")" << " -> "
54  << "(" << pair.other_x << "," << pair.other_y << "," << pair.other_z << ")";
55 
56  return o;
57  }
58 
59  unsigned int this_idx;
60  unsigned int other_idx;
61  float this_x,this_y,this_z;
62  float other_x,other_y,other_z;
64 
65  };
66 
67 #if defined(MRPT_IS_X86_AMD64)
68 #pragma pack(pop) // End of pack = 1
69 #endif
70 
71 
74 
75  /** A list of TMatchingPair
76  * \ingroup mrpt_base_grp
77  */
78  class BASE_IMPEXP TMatchingPairList : public std::vector<TMatchingPair>
79  {
80  public:
81  /** Checks if the given index from the "other" map appears in the list. */
82  bool indexOtherMapHasCorrespondence(size_t idx) const;
83  /** Saves the correspondences to a text file */
84  void dumpToFile(const std::string &fileName) const;
85  /** Saves the correspondences as a MATLAB script which draws them. */
86  void saveAsMATLABScript( const std::string &filName ) const;
87 
88  /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q"
89  * \f[ \sum\limits_i e_i \f]
90  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
91  * \sa squareErrorVector, overallSquareErrorAndPoints
92  */
93  float overallSquareError( const mrpt::poses::CPose2D &q ) const;
94 
95  /** 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.
96  * \f[ \sum\limits_i e_i \f]
97  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
98  * \sa squareErrorVector
99  */
100  float overallSquareErrorAndPoints(
101  const mrpt::poses::CPose2D &q,
102  std::vector<float> &xs,
103  std::vector<float> &ys ) const;
104 
105 
106  /** Returns a vector with the square error between each pair of correspondences in the list, given the 2D transformation "q"
107  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
108  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
109  * \sa overallSquareError
110  */
111  void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector<float> &out_sqErrs ) const;
112 
113  /** 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"
114  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
115  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
116  * \sa overallSquareError
117  */
118  void squareErrorVector(
119  const mrpt::poses::CPose2D &q,
120  std::vector<float> &out_sqErrs,
121  std::vector<float> &xs,
122  std::vector<float> &ys ) const;
123 
124  /** Test whether the given pair "p" is within the pairings */
125  bool contains (const TMatchingPair &p) const;
126 
127  /** Creates a filtered list of pairings with those ones which have a single correspondence which coincides
128  * in both directions, i.e. the best pairing of element `i` in map `this` is the best match for element `j` in map `other`,
129  * and viceversa*/
130  void filterUniqueRobustPairs(const size_t num_elements_this_map, TMatchingPairList &out_filtered_list) const;
131  };
132 
133  /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx */
134  bool BASE_IMPEXP operator < (const TMatchingPair& a, const TMatchingPair& b);
135 
136  /** A comparison operator */
138 
139  /** A comparison operator */
141 
142 
143  } // End of namespace
144 } // end of namespace
145 #endif
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3626
friend std::ostream & operator<<(std::ostream &o, const mrpt::utils::TMatchingPair &pair)
Definition: TMatchingPair.h:49
bool operator<(const CArray< T, N > &x, const CArray< T, N > &y)
Definition: CArray.h:281
A list of TMatchingPair.
Definition: TMatchingPair.h:78
GLubyte GLubyte b
Definition: glext.h:5575
GLsizei const GLchar ** string
Definition: glext.h:3919
TMatchingPair const * TMatchingPairConstPtr
Definition: TMatchingPair.h:73
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:36
TMatchingPair * TMatchingPairPtr
Definition: TMatchingPair.h:72
bool operator==(const CArray< T, N > &x, const CArray< T, N > &y)
Definition: CArray.h:277
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:41
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
GLfloat GLfloat p
Definition: glext.h:5587
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
Definition: TMatchingPair.h:31



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019