template class mrpt::math::RANSAC_Template
Overview
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_*.
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; // construction RANSAC_Template(); // 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; // fields bool logging_enable_console_output {true}; bool logging_enable_keep_record {false}; // methods void logStr(const VerbosityLevel level, std::string_view msg_str) const; void logFmt(const VerbosityLevel level, const char* fmt, ...) const; void void logCond(const VerbosityLevel level, bool cond, const std::string& msg_str) const; void setLoggerName(const std::string& name); std::string getLoggerName() const; void setVerbosityLevel(const VerbosityLevel level); void setVerbosityLevelForCallbacks(const VerbosityLevel level); void setMinLoggingLevel(const VerbosityLevel level); VerbosityLevel getMinLoggingLevel() const; VerbosityLevel getMinLoggingLevelForCallbacks() const; bool isLoggingLevelVisible(VerbosityLevel level) const; void getLogAsString(std::string& log_contents) const; std::string getLogAsString() const; void writeLogToFile(const std::optional<std::string>& fname_in = std::nullopt) const; void dumpLogToConsole() const; std::string getLoggerLastMsg() const; void getLoggerLastMsg(std::string& msg_str) const; void loggerReset(); void logRegisterCallback(output_logger_callback_t userFunc); bool logDeregisterCallback(output_logger_callback_t userFunc); COutputLogger& operator = (const COutputLogger&); COutputLogger& operator = (COutputLogger&&); static std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors(); static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names();
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.