Main MRPT website > C++ reference
MRPT logo
ransac.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (c) 2005-2013, Individual contributors, see AUTHORS file |
7  | Copyright (c) 2005-2013, MAPIR group, University of Malaga |
8  | Copyright (c) 2012-2013, University of Almeria |
9  | All rights reserved. |
10  | |
11  | Redistribution and use in source and binary forms, with or without |
12  | modification, are permitted provided that the following conditions are |
13  | met: |
14  | * Redistributions of source code must retain the above copyright |
15  | notice, this list of conditions and the following disclaimer. |
16  | * Redistributions in binary form must reproduce the above copyright |
17  | notice, this list of conditions and the following disclaimer in the |
18  | documentation and/or other materials provided with the distribution. |
19  | * Neither the name of the copyright holders nor the |
20  | names of its contributors may be used to endorse or promote products |
21  | derived from this software without specific prior written permission.|
22  | |
23  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24  | 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
25  | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR|
26  | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE |
27  | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL|
28  | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR|
29  | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30  | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
31  | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
32  | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
33  | POSSIBILITY OF SUCH DAMAGE. |
34  +---------------------------------------------------------------------------+ */
35 #ifndef mrpt_ransac_H
36 #define mrpt_ransac_H
37 
39 #include <mrpt/math/CMatrixD.h>
40 #include <set>
41 
42 namespace mrpt
43 {
44  namespace math
45  {
46  /** @addtogroup ransac_grp RANSAC and other model fitting algorithms
47  * \ingroup mrpt_base_grp
48  * @{ */
49 
50 
51  /** A generic RANSAC implementation with models as matrices.
52  * See \a RANSAC_Template::execute for more info on usage.
53  * \sa mrpt::math::ModelSearch, a more versatile RANSAC implementation where models can be anything else, not only matrices.
54  */
55  template <typename NUMTYPE = double>
57  {
58  public:
59 
60  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
61  typedef void (*TRansacFitFunctor)(
62  const CMatrixTemplateNumeric<NUMTYPE> &allData,
63  const mrpt::vector_size_t &useIndices,
64  std::vector< CMatrixTemplateNumeric<NUMTYPE> > &fitModels );
65 
66  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
67  typedef void (*TRansacDistanceFunctor)(
68  const CMatrixTemplateNumeric<NUMTYPE> &allData,
69  const std::vector< CMatrixTemplateNumeric<NUMTYPE> > & testModels,
70  const NUMTYPE distanceThreshold,
71  unsigned int & out_bestModelIndex,
72  mrpt::vector_size_t & out_inlierIndices );
73 
74  /** The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info. */
75  typedef bool (*TRansacDegenerateFunctor)(
76  const CMatrixTemplateNumeric<NUMTYPE> &allData,
77  const mrpt::vector_size_t &useIndices );
78 
79  /** An implementation of the RANSAC algorithm for robust fitting of models to data.
80  *
81  * \param data A DxN matrix with all the observed data. D is the dimensionality of data points and N the number of points.
82  * \param
83  *
84  * This implementation is highly inspired on Peter Kovesi's MATLAB scripts (http://www.csse.uwa.edu.au/~pk).
85  * \return false if no good solution can be found, true on success.
86  */
87  static bool execute(
89  TRansacFitFunctor fit_func,
90  TRansacDistanceFunctor dist_func,
91  TRansacDegenerateFunctor degen_func,
92  const double distanceThreshold,
93  const unsigned int minimumSizeSamplesToFit,
94  mrpt::vector_size_t &out_best_inliers,
95  CMatrixTemplateNumeric<NUMTYPE> &out_best_model,
96  bool verbose = false,
97  const double prob_good_sample = 0.999,
98  const size_t maxIter = 2000
99  );
100 
101  }; // end class
102 
103  typedef RANSAC_Template<double> RANSAC; //!< The default instance of RANSAC, for double type
104 
105  /** @} */
106 
107  } // End of namespace
108 } // End of namespace
109 
110 #endif
std::vector< size_t > vector_size_t
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
RANSAC_Template< double > RANSAC
The default instance of RANSAC, for double type.
Definition: ransac.h:103
A generic RANSAC implementation with models as matrices.
Definition: ransac.h:56
This base class provides a common printf-like method to send debug information to std::cout...



Page generated by Doxygen 1.8.14 for MRPT 1.0.2 SVN: at lun oct 28 00:52:41 CET 2019 Hosted on:
SourceForge.net Logo