Main MRPT website > C++ reference
MRPT logo

TMatchingPair.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef  TMatchingPair_H
00029 #define  TMatchingPair_H
00030 
00031 #include <mrpt/utils/utils_defs.h>
00032 
00033 namespace mrpt
00034 {
00035         namespace utils
00036         {
00037                 using namespace mrpt::poses;
00038         
00039                 /** A structure for holding correspondences between two sets of points or points-like entities in 2D or 3D.
00040                   */
00041                 struct BASE_IMPEXP TMatchingPair
00042                 {
00043                         TMatchingPair() :
00044                                 this_idx(0), other_idx(0),
00045                                 this_x(0),this_y(0),this_z(0),
00046                                 other_x(0),other_y(0),other_z(0),
00047                                 errorSquareAfterTransformation(0)
00048                         {
00049                         }
00050 
00051                         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 ) :
00052                                         this_idx(_this_idx), other_idx(_other_idx),
00053                                         this_x(_this_x),this_y(_this_y),this_z(_this_z),
00054                                         other_x(_other_x),other_y(_other_y),other_z(_other_z),
00055                                         errorSquareAfterTransformation(0)
00056                         {
00057                         }
00058 
00059                         unsigned int    this_idx;
00060                         unsigned int    other_idx;
00061                         float                   this_x,this_y,this_z;
00062                         float                   other_x,other_y,other_z;
00063                         float                   errorSquareAfterTransformation;
00064 
00065                 };
00066 
00067                 typedef TMatchingPair*  TMatchingPairPtr;
00068 
00069                 /** A list of TMatchingPair
00070                   */
00071                 class BASE_IMPEXP TMatchingPairList : public std::deque<TMatchingPair>
00072                 {
00073                 public:
00074 
00075                         /** Checks if the given index from the "other" map appears in the list.
00076                           */
00077                         bool  indexOtherMapHasCorrespondence(unsigned int idx);
00078 
00079                         /** Saves the correspondences to a text file
00080                           */
00081                         void  dumpToFile(const std::string &fileName);
00082 
00083                         /** Saves the correspondences as a MATLAB script which draws them.
00084                           */
00085                         void saveAsMATLABScript( const std::string &filName );
00086 
00087                         /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q"
00088                           *    \f[ \sum\limits_i e_i  \f]
00089                           *  Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
00090                           * \sa squareErrorVector, overallSquareErrorAndPoints
00091                           */
00092                         float overallSquareError( const CPose2D &q ) const;
00093 
00094                         /** 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.
00095                           *    \f[ \sum\limits_i e_i  \f]
00096                           *  Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector
00097                           * \sa squareErrorVector
00098                           */
00099                         float overallSquareErrorAndPoints(
00100                                 const CPose2D &q,
00101                                 vector_float &xs,
00102                                 vector_float &ys ) const;
00103 
00104 
00105                         /**  Returns a vector with the square error between each pair of correspondences in the list, given the 2D transformation "q"
00106                           *    Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
00107                           *    \f[ e_i = | x_{this} -  q \oplus x_{other}  |^2 \f]
00108                           * \sa overallSquareError
00109                           */
00110                         void  squareErrorVector(const CPose2D &q, vector_float &out_sqErrs ) const;
00111 
00112                         /**  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"
00113                           *    Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q":
00114                           *    \f[ e_i = | x_{this} -  q \oplus x_{other}  |^2 \f]
00115                           * \sa overallSquareError
00116                           */
00117                         void  squareErrorVector(
00118                                 const CPose2D &q,
00119                                 vector_float &out_sqErrs,
00120                                 vector_float &xs,
00121                                 vector_float &ys ) const;
00122 
00123                         /** Test whether the given pair "p" is within the pairings */
00124                         bool contains (const TMatchingPair &p) const;
00125                 };
00126                 
00127                 /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx   */
00128                 bool BASE_IMPEXP operator < (const TMatchingPair& a, const TMatchingPair& b);
00129 
00130                 /** A comparison operator  */
00131                 bool BASE_IMPEXP operator == (const TMatchingPair& a,const TMatchingPair& b);
00132 
00133                 /** A comparison operator */
00134                 bool BASE_IMPEXP operator == (const TMatchingPairList& a,const TMatchingPairList& b);
00135                 
00136                 
00137         } // End of namespace
00138 } // end of namespace
00139 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011