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