Main MRPT website > C++ reference
MRPT logo
ransac.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef mrpt_ransac_H
29 #define mrpt_ransac_H
30 
32 #include <mrpt/math/CMatrixD.h>
33 #include <set>
34 
35 namespace mrpt
36 {
37  namespace math
38  {
39  /** @addtogroup ransac_grp RANSAC and other model fitting algorithms
40  * \ingroup mrpt_base_grp
41  * @{ */
42 
43 
44  /** A generic RANSAC implementation with models as matrices.
45  * See \a RANSAC_Template::execute for more info on usage.
46  * \sa mrpt::math::ModelSearch, a more versatile RANSAC implementation where models can be anything else, not only matrices.
47  */
48  template <typename NUMTYPE = double>
50  {
51  public:
52 
53  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
54  typedef void (*TRansacFitFunctor)(
55  const CMatrixTemplateNumeric<NUMTYPE> &allData,
56  const mrpt::vector_size_t &useIndices,
57  std::vector< CMatrixTemplateNumeric<NUMTYPE> > &fitModels );
58 
59  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
60  typedef void (*TRansacDistanceFunctor)(
61  const CMatrixTemplateNumeric<NUMTYPE> &allData,
62  const std::vector< CMatrixTemplateNumeric<NUMTYPE> > & testModels,
63  const NUMTYPE distanceThreshold,
64  unsigned int & out_bestModelIndex,
65  mrpt::vector_size_t & out_inlierIndices );
66 
67  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
68  typedef bool (*TRansacDegenerateFunctor)(
69  const CMatrixTemplateNumeric<NUMTYPE> &allData,
70  const mrpt::vector_size_t &useIndices );
71 
72  /** An implementation of the RANSAC algorithm for robust fitting of models to data.
73  *
74  * \param data A DxN matrix with all the observed data. D is the dimensionality of data points and N the number of points.
75  * \param
76  *
77  * This implementation is highly inspired on Peter Kovesi's MATLAB scripts (http://www.csse.uwa.edu.au/~pk).
78  * \return false if no good solution can be found, true on success.
79  */
80  static bool execute(
82  TRansacFitFunctor fit_func,
83  TRansacDistanceFunctor dist_func,
84  TRansacDegenerateFunctor degen_func,
85  const double distanceThreshold,
86  const unsigned int minimumSizeSamplesToFit,
87  mrpt::vector_size_t &out_best_inliers,
88  CMatrixTemplateNumeric<NUMTYPE> &out_best_model,
89  bool verbose = false,
90  const double prob_good_sample = 0.999,
91  const size_t maxIter = 2000
92  );
93 
94  }; // end class
95 
96  typedef RANSAC_Template<double> RANSAC; //!< The default instance of RANSAC, for double type
97 
98  /** @} */
99 
100  } // End of namespace
101 } // End of namespace
102 
103 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013