Main MRPT website > C++ reference
MRPT logo
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-2014, 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 
70  /** Checks if the given index from the "other" map appears in the list.
71  */
72  bool indexOtherMapHasCorrespondence(unsigned int idx);
73 
74  /** Saves the correspondences to a text file
75  */
76  void dumpToFile(const std::string &fileName);
77 
78  /** Saves the correspondences as a MATLAB script which draws them.
79  */
80  void saveAsMATLABScript( const std::string &filName );
81 
82  /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q"
83  * \f[ \sum\limits_i e_i \f]
84  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
85  * \sa squareErrorVector, overallSquareErrorAndPoints
86  */
87  float overallSquareError( const mrpt::poses::CPose2D &q ) const;
88 
89  /** 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.
90  * \f[ \sum\limits_i e_i \f]
91  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
92  * \sa squareErrorVector
93  */
94  float overallSquareErrorAndPoints(
95  const mrpt::poses::CPose2D &q,
96  std::vector<float> &xs,
97  std::vector<float> &ys ) const;
98 
99 
100  /** Returns a vector with the square error between each pair of correspondences in the list, given the 2D transformation "q"
101  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
102  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
103  * \sa overallSquareError
104  */
105  void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector<float> &out_sqErrs ) const;
106 
107  /** 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"
108  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
109  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
110  * \sa overallSquareError
111  */
112  void squareErrorVector(
113  const mrpt::poses::CPose2D &q,
114  std::vector<float> &out_sqErrs,
115  std::vector<float> &xs,
116  std::vector<float> &ys ) const;
117 
118  /** Test whether the given pair "p" is within the pairings */
119  bool contains (const TMatchingPair &p) const;
120  };
121 
122  /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx */
123  bool BASE_IMPEXP operator < (const TMatchingPair& a, const TMatchingPair& b);
124 
125  /** A comparison operator */
126  bool BASE_IMPEXP operator == (const TMatchingPair& a,const TMatchingPair& b);
127 
128  /** A comparison operator */
130 
131 
132  } // End of namespace
133 } // end of namespace
134 #endif
bool BASE_IMPEXP operator==(const mrpt::utils::TCamera &a, const mrpt::utils::TCamera &b)
A list of TMatchingPair.
Definition: TMatchingPair.h:66
bool BASE_IMPEXP operator<(const TMatchingPair &a, const TMatchingPair &b)
A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose.
Definition: CPose2D.h:36
TMatchingPair * TMatchingPairPtr
Definition: TMatchingPair.h:61
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
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
Definition: TMatchingPair.h:30



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014