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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020