Template Class RANSAC_Template

Inheritance Relationships

Base Type

  • public mrpt::system::COutputLogger

Class Documentation

template<typename NUMTYPE = double, typename DATASET = CMatrixDynamic<NUMTYPE>, typename MODEL = CMatrixDynamic<NUMTYPE>>
class RANSAC_Template : public mrpt::system::COutputLogger

A generic RANSAC implementation. By default, the input “dataset” and output “model” are matrices, but this can be changed via template arguments to be any user-defined type. Define ransacDatasetSize() for your custom data types.

See RANSAC_Template::execute for more info on usage, and examples under [MRPT]/mrpt_examples_cpp/math_ransac_*.

See also

mrpt::math::ModelSearch, another RANSAC implementation where models can be anything else, not only matrices, and capable of genetic algorithms.

Note

New in MRPT 2.0.2: The second and third template arguments.

Public Types

using TRansacFitFunctor = std::function<void(const DATASET &allData, const std::vector<size_t> &useIndices, std::vector<MODEL> &fitModels)>

The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info.

using TRansacDistanceFunctor = std::function<void(const DATASET &allData, const std::vector<MODEL> &testModels, const NUMTYPE distanceThreshold, unsigned int &out_bestModelIndex, std::vector<size_t> &out_inlierIndices)>

The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info.

using TRansacDegenerateFunctor = std::function<bool(const DATASET &allData, const std::vector<size_t> &useIndices)>

The type of the function passed to mrpt::math::ransac - See the documentation for that method for more info.

Public Functions

inline RANSAC_Template()
bool execute(const DATASET &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, MODEL &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.

Note

[MRPT 1.5.0] verbose parameter has been removed, supersedded by COutputLogger settings.

Parameters:
  • data – A DxN matrix with all the observed data. D is the dimensionality of data points and N the number of points.

  • This – implementation is highly inspired on Peter Kovesi’s MATLAB scripts (http://www.csse.uwa.edu.au/~pk).

Returns:

false if no good solution can be found, true on success.