Main MRPT website > C++ reference for MRPT 1.9.9
ransac.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 #include <set>
14 #include <functional>
15 
16 namespace mrpt
17 {
18 namespace math
19 {
20 /** @addtogroup ransac_grp RANSAC and other model fitting algorithms
21  * \ingroup mrpt_math_grp
22  * @{ */
23 
24 /** A generic RANSAC implementation with models as matrices.
25  * See \a RANSAC_Template::execute for more info on usage.
26  * \sa mrpt::math::ModelSearch, a more versatile RANSAC implementation where
27  * models can be anything else, not only matrices.
28  */
29 template <typename NUMTYPE = double>
31 {
32  public:
33  RANSAC_Template() : mrpt::system::COutputLogger("RANSAC_Template") {}
34  /** The type of the function passed to mrpt::math::ransac - See the
35  * documentation for that method for more info. */
36  using TRansacFitFunctor = std::function<void(
37  const CMatrixTemplateNumeric<NUMTYPE>& allData,
38  const std::vector<size_t>& useIndices,
39  std::vector<CMatrixTemplateNumeric<NUMTYPE>>& fitModels)>;
40 
41  /** The type of the function passed to mrpt::math::ransac - See the
42  * documentation for that method for more info. */
43  using TRansacDistanceFunctor = std::function<void(
44  const CMatrixTemplateNumeric<NUMTYPE>& allData,
45  const std::vector<CMatrixTemplateNumeric<NUMTYPE>>& testModels,
46  const NUMTYPE distanceThreshold, unsigned int& out_bestModelIndex,
47  std::vector<size_t>& out_inlierIndices)>;
48 
49  /** The type of the function passed to mrpt::math::ransac - See the
50  * documentation for that method for more info. */
51  using TRansacDegenerateFunctor = std::function<bool(
52  const CMatrixTemplateNumeric<NUMTYPE>& allData,
53  const std::vector<size_t>& useIndices)>;
54 
55  /** An implementation of the RANSAC algorithm for robust fitting of models
56  * to data.
57  *
58  * \param data A DxN matrix with all the observed data. D is the
59  * dimensionality of data points and N the number of points.
60  * \param
61  *
62  * This implementation is highly inspired on Peter Kovesi's MATLAB scripts
63  * (http://www.csse.uwa.edu.au/~pk).
64  * \return false if no good solution can be found, true on success.
65  * \note [MRPT 1.5.0] `verbose` parameter has been removed, supersedded by
66  * COutputLogger settings.
67  */
68  bool execute(
70  const TRansacFitFunctor& fit_func,
71  const TRansacDistanceFunctor& dist_func,
72  const TRansacDegenerateFunctor& degen_func,
73  const double distanceThreshold,
74  const unsigned int minimumSizeSamplesToFit,
75  std::vector<size_t>& out_best_inliers,
76  CMatrixTemplateNumeric<NUMTYPE>& out_best_model,
77  const double prob_good_sample = 0.999,
78  const size_t maxIter = 2000) const;
79 
80 }; // end class
81 
82 /** The default instance of RANSAC, for double type */
84 
85 /** @} */
86 
87 } // End of namespace
88 } // End of namespace
mrpt::math::RANSAC_Template::TRansacFitFunctor
std::function< void(const CMatrixTemplateNumeric< NUMTYPE > &allData, const std::vector< size_t > &useIndices, std::vector< CMatrixTemplateNumeric< NUMTYPE > > &fitModels)> TRansacFitFunctor
The type of the function passed to mrpt::math::ransac - See the documentation for that method for mor...
Definition: ransac.h:39
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::math::CMatrixTemplateNumeric
A matrix of dynamic size.
Definition: CMatrixTemplateNumeric.h:37
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
COutputLogger.h
CMatrixTemplateNumeric.h
mrpt::math::RANSAC_Template::TRansacDegenerateFunctor
std::function< bool(const CMatrixTemplateNumeric< NUMTYPE > &allData, const std::vector< size_t > &useIndices)> TRansacDegenerateFunctor
The type of the function passed to mrpt::math::ransac - See the documentation for that method for mor...
Definition: ransac.h:53
mrpt::math::RANSAC_Template::RANSAC_Template
RANSAC_Template()
Definition: ransac.h:33
mrpt::math::RANSAC_Template::execute
bool execute(const CMatrixTemplateNumeric< NUMTYPE > &data, const TRansacFitFunctor &fit_func, const TRansacDistanceFunctor &dist_func, const TRansacDegenerateFunctor &degen_func, const double distanceThreshold, const unsigned int minimumSizeSamplesToFit, std::vector< size_t > &out_best_inliers, CMatrixTemplateNumeric< NUMTYPE > &out_best_model, const double prob_good_sample=0.999, const size_t maxIter=2000) const
An implementation of the RANSAC algorithm for robust fitting of models to data.
Definition: ransac.cpp:24
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
void
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
mrpt::math::RANSAC_Template::TRansacDistanceFunctor
std::function< void(const CMatrixTemplateNumeric< NUMTYPE > &allData, const std::vector< CMatrixTemplateNumeric< NUMTYPE > > &testModels, const NUMTYPE distanceThreshold, unsigned int &out_bestModelIndex, std::vector< size_t > &out_inlierIndices)> TRansacDistanceFunctor
The type of the function passed to mrpt::math::ransac - See the documentation for that method for mor...
Definition: ransac.h:47
mrpt::math::RANSAC_Template
A generic RANSAC implementation with models as matrices.
Definition: ransac.h:30
mrpt::system::COutputLogger::COutputLogger
COutputLogger()
Default class constructor.
Definition: COutputLogger.cpp:59



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST