template class mrpt::math::RANSAC_Template

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]/samples/math_ransac_*.

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

See also:

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

#include <mrpt/math/ransac.h>

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

    typedef std::function<void(const DATASET&allData, const std::vector<size_t>&useIndices, std::vector<MODEL>&fitModels)> TRansacFitFunctor;
    typedef std::function<void(const DATASET&allData, const std::vector<MODEL>&testModels, const NUMTYPE distanceThreshold, unsigned int&out_bestModelIndex, std::vector<size_t>&out_inlierIndices)> TRansacDistanceFunctor;
    typedef std::function<bool(const DATASET&allData, const std::vector<size_t>&useIndices)> TRansacDegenerateFunctor;

    //
methods

    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;
};

Inherited Members

public:
    // structs

    struct TMsg;

Typedefs

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

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

typedef std::function<void(const DATASET&allData, const std::vector<MODEL>&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 more info.

typedef std::function<bool(const DATASET&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 more info.

Methods

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.

[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.