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



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST