Main MRPT website > C++ reference
MRPT logo
TMatchingPair.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef TMatchingPair_H
29 #define TMatchingPair_H
30 
31 #include <mrpt/utils/utils_defs.h>
32 
33 namespace mrpt
34 {
35  namespace utils
36  {
37  using namespace mrpt::poses;
38 
39  // Pragma defined to ensure no structure packing, so we can use SSE2 vectorization on parts of this struture
40 #pragma pack(push,1)
41 
42  /** A structure for holding correspondences between two sets of points or points-like entities in 2D or 3D.
43  * \ingroup mrpt_base_grp
44  */
46  {
48  this_idx(0), other_idx(0),
49  this_x(0),this_y(0),this_z(0),
50  other_x(0),other_y(0),other_z(0),
51  errorSquareAfterTransformation(0)
52  {
53  }
54 
55  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 ) :
56  this_idx(_this_idx), other_idx(_other_idx),
57  this_x(_this_x),this_y(_this_y),this_z(_this_z),
58  other_x(_other_x),other_y(_other_y),other_z(_other_z),
59  errorSquareAfterTransformation(0)
60  {
61  }
62 
63  unsigned int this_idx;
64  unsigned int other_idx;
65  float this_x,this_y,this_z;
66  float other_x,other_y,other_z;
68 
69  };
70 
71 #pragma pack(pop) // End of pack = 1
72 
73 
75 
76  /** A list of TMatchingPair
77  * \ingroup mrpt_base_grp
78  */
79  class BASE_IMPEXP TMatchingPairList : public std::vector<TMatchingPair>
80  {
81  public:
82 
83  /** Checks if the given index from the "other" map appears in the list.
84  */
85  bool indexOtherMapHasCorrespondence(unsigned int idx);
86 
87  /** Saves the correspondences to a text file
88  */
89  void dumpToFile(const std::string &fileName);
90 
91  /** Saves the correspondences as a MATLAB script which draws them.
92  */
93  void saveAsMATLABScript( const std::string &filName );
94 
95  /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q"
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, overallSquareErrorAndPoints
99  */
100  float overallSquareError( const CPose2D &q ) const;
101 
102  /** 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.
103  * \f[ \sum\limits_i e_i \f]
104  * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
105  * \sa squareErrorVector
106  */
107  float overallSquareErrorAndPoints(
108  const CPose2D &q,
109  vector_float &xs,
110  vector_float &ys ) const;
111 
112 
113  /** Returns a vector with the square error between each pair of correspondences in the list, 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(const CPose2D &q, vector_float &out_sqErrs ) const;
119 
120  /** 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"
121  * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
122  * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f]
123  * \sa overallSquareError
124  */
125  void squareErrorVector(
126  const CPose2D &q,
127  vector_float &out_sqErrs,
128  vector_float &xs,
129  vector_float &ys ) const;
130 
131  /** Test whether the given pair "p" is within the pairings */
132  bool contains (const TMatchingPair &p) const;
133  };
134 
135  /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx */
136  bool BASE_IMPEXP operator < (const TMatchingPair& a, const TMatchingPair& b);
137 
138  /** A comparison operator */
139  bool BASE_IMPEXP operator == (const TMatchingPair& a,const TMatchingPair& b);
140 
141  /** A comparison operator */
143 
144 
145  } // End of namespace
146 } // end of namespace
147 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013