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 mrpt_ransac_H 00029 #define mrpt_ransac_H 00030 00031 #include <mrpt/utils/CDebugOutputCapable.h> 00032 #include <mrpt/math/CMatrixD.h> 00033 #include <set> 00034 00035 namespace mrpt 00036 { 00037 namespace math 00038 { 00039 /** A generic RANSAC implementation with models as matrices. 00040 * See \a RANSAC_Template::execute for more info on usage. 00041 * \sa mrpt::math::ModelSearch, a more versatile RANSAC implementation where models can be anything else, not only matrices. 00042 */ 00043 template <typename NUMTYPE = double> 00044 class BASE_IMPEXP RANSAC_Template : public mrpt::utils::CDebugOutputCapable 00045 { 00046 public: 00047 00048 /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */ 00049 typedef void (*TRansacFitFunctor)( 00050 const CMatrixTemplateNumeric<NUMTYPE> &allData, 00051 const mrpt::vector_size_t &useIndices, 00052 std::vector< CMatrixTemplateNumeric<NUMTYPE> > &fitModels ); 00053 00054 /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */ 00055 typedef void (*TRansacDistanceFunctor)( 00056 const CMatrixTemplateNumeric<NUMTYPE> &allData, 00057 const std::vector< CMatrixTemplateNumeric<NUMTYPE> > & testModels, 00058 const NUMTYPE distanceThreshold, 00059 unsigned int & out_bestModelIndex, 00060 mrpt::vector_size_t & out_inlierIndices ); 00061 00062 /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */ 00063 typedef bool (*TRansacDegenerateFunctor)( 00064 const CMatrixTemplateNumeric<NUMTYPE> &allData, 00065 const mrpt::vector_size_t &useIndices ); 00066 00067 /** An implementation of the RANSAC algorithm for robust fitting of models to data. 00068 * 00069 * \param data A DxN matrix with all the observed data. D is the dimensionality of data points and N the number of points. 00070 * \param 00071 * 00072 * This implementation is highly inspired on Peter Kovesi's MATLAB scripts (http://www.csse.uwa.edu.au/~pk). 00073 * \return false if no good solution can be found, true on success. 00074 */ 00075 static bool execute( 00076 const CMatrixTemplateNumeric<NUMTYPE> &data, 00077 TRansacFitFunctor fit_func, 00078 TRansacDistanceFunctor dist_func, 00079 TRansacDegenerateFunctor degen_func, 00080 const double distanceThreshold, 00081 const unsigned int minimumSizeSamplesToFit, 00082 mrpt::vector_size_t &out_best_inliers, 00083 CMatrixTemplateNumeric<NUMTYPE> &out_best_model, 00084 bool verbose = false, 00085 const double prob_good_sample = 0.999, 00086 const size_t maxIter = 2000 00087 ); 00088 00089 }; // end class 00090 00091 typedef RANSAC_Template<double> RANSAC; //!< The default instance of RANSAC, for double type 00092 00093 } // End of namespace 00094 } // End of namespace 00095 00096 #endif
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011 |