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