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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST