00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 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 00038 /** A structure for holding correspondences between two sets of points or points-like entities in 2D or 3D. 00039 */ 00040 struct BASE_IMPEXP TMatchingPair 00041 { 00042 TMatchingPair() : 00043 this_idx(0), other_idx(0), 00044 this_x(0),this_y(0),this_z(0), 00045 other_x(0),other_y(0),other_z(0), 00046 errorSquareAfterTransformation(0) 00047 { 00048 } 00049 00050 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 ) : 00051 this_idx(_this_idx), other_idx(_other_idx), 00052 this_x(_this_x),this_y(_this_y),this_z(_this_z), 00053 other_x(_other_x),other_y(_other_y),other_z(_other_z), 00054 errorSquareAfterTransformation(0) 00055 { 00056 } 00057 00058 unsigned int this_idx; 00059 unsigned int other_idx; 00060 float this_x,this_y,this_z; 00061 float other_x,other_y,other_z; 00062 float errorSquareAfterTransformation; 00063 00064 }; 00065 00066 typedef TMatchingPair* TMatchingPairPtr; 00067 00068 /** A list of TMatchingPair 00069 */ 00070 class BASE_IMPEXP TMatchingPairList : public std::deque<TMatchingPair> 00071 { 00072 public: 00073 00074 /** Checks if the given index from the "other" map appears in the list. 00075 */ 00076 bool indexOtherMapHasCorrespondence(unsigned int idx); 00077 00078 /** Saves the correspondences to a text file 00079 */ 00080 void dumpToFile(const std::string &fileName); 00081 00082 /** Saves the correspondences as a MATLAB script which draws them. 00083 */ 00084 void saveAsMATLABScript( const std::string &filName ); 00085 00086 /** Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q" 00087 * \f[ \sum\limits_i e_i \f] 00088 * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector 00089 * \sa squareErrorVector, overallSquareErrorAndPoints 00090 */ 00091 float overallSquareError( const CPose2D &q ) const; 00092 00093 /** 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. 00094 * \f[ \sum\limits_i e_i \f] 00095 * Where \f$ e_i \f$ are the elements of the square error vector as computed by computeSquareErrorVector 00096 * \sa squareErrorVector 00097 */ 00098 float overallSquareErrorAndPoints( 00099 const CPose2D &q, 00100 vector_float &xs, 00101 vector_float &ys ) const; 00102 00103 00104 /** Returns a vector with the square error between each pair of correspondences in the list, given the 2D transformation "q" 00105 * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q": 00106 * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f] 00107 * \sa overallSquareError 00108 */ 00109 void squareErrorVector(const CPose2D &q, vector_float &out_sqErrs ) const; 00110 00111 /** 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" 00112 * Each element \f$ e_i \f$ is the square distance between the "this" (global) point and the "other" (local) point transformed through "q": 00113 * \f[ e_i = | x_{this} - q \oplus x_{other} |^2 \f] 00114 * \sa overallSquareError 00115 */ 00116 void squareErrorVector( 00117 const CPose2D &q, 00118 vector_float &out_sqErrs, 00119 vector_float &xs, 00120 vector_float &ys ) const; 00121 00122 /** Test whether the given pair "p" is within the pairings */ 00123 bool contains (const TMatchingPair &p) const; 00124 }; 00125 00126 /** A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx, if equals, by other_idx */ 00127 bool BASE_IMPEXP operator < (const TMatchingPair& a, const TMatchingPair& b); 00128 00129 /** A comparison operator */ 00130 bool BASE_IMPEXP operator == (const TMatchingPair& a,const TMatchingPair& b); 00131 00132 /** A comparison operator */ 00133 bool BASE_IMPEXP operator == (const TMatchingPairList& a,const TMatchingPairList& b); 00134 00135 00136 } // End of namespace 00137 } // end of namespace 00138 #endif
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |
