Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
RANSAC.h File Reference

Perform Random Sample Consensus (RANSAC), a robust fitting method. More...

#include "std.h"
+ Include dependency graph for RANSAC.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void RANSAC_linear_model (int n_samples, int n_iterations, float error_threshold, float *targets, int D, float(*samples)[D], uint16_t count, bool use_bias, float *params, float *fit_error)
 Perform RANSAC to fit a linear model. More...
 
void get_indices_without_replacement (int *indices_subset, int n_samples, int count)
 Get indices without replacement. More...
 
float predict_value (float *sample, float *weights, int D, bool use_bias)
 Predict the value of a sample with linear weights. More...
 

Detailed Description

Perform Random Sample Consensus (RANSAC), a robust fitting method.

The concept is to select (minimal) subsets of the samples for learning a model, then determining the error on the entire data set, and selecting the best fit. In determining the error, the individual sample errors are capped, so that outliers can be identified and have only a modest influence on the results.

Read: Fischler, M. A., & Bolles, R. C. (1981). Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography. Communications of the ACM, 24(6), 381-395.

This file depends on the function fit_linear_model in math/pprz_matrix_decomp_float.h/c

Definition in file RANSAC.h.

Function Documentation

◆ get_indices_without_replacement()

void get_indices_without_replacement ( int *  indices_subset,
int  n_samples,
int  count 
)

Get indices without replacement.

Parameters
[out]indices_subsetThis will be filled with the sampled indices
[in]n_samplesThe number of samples / indices.
[in]countThe function will sample n_sample numbers from the range 1, 2, 3,..., count

Definition at line 157 of file RANSAC.c.

References n_samples.

Referenced by RANSAC_linear_model().

+ Here is the caller graph for this function:

◆ predict_value()

float predict_value ( float *  sample,
float *  weights,
int  D,
bool  use_bias 
)

Predict the value of a sample with linear weights.

Parameters
[in]sampleThe sample vector of size D
[in]weightsThe weight vector of size D+1
[in]DThe dimension of the sample.
Returns
The predicted value

Definition at line 133 of file RANSAC.c.

References D, and weights.

Referenced by RANSAC_linear_model().

+ Here is the caller graph for this function:

◆ RANSAC_linear_model()

void RANSAC_linear_model ( int  n_samples,
int  n_iterations,
float  error_threshold,
float *  targets,
int  D,
float(*)  samples[D],
uint16_t  count,
bool  use_bias,
float *  params,
float *  fit_error 
)

Perform RANSAC to fit a linear model.

Parameters
[in]n_samplesThe number of samples to use for a single fit
[in]n_iterationsThe number of times a linear fit is performed
[in]error_thresholdThe threshold used to cap errors in the RANSAC process
[in]targetsThe target values
[in]samplesThe samples / feature vectors
[in]DThe dimensionality of the samples
[in]countThe number of samples
[in]use_biasWhether the RANSAC procedure should add a bias. If 0 it does not.
[out]parameters*Parameters of the linear fit
[out]fit_error*Total error of the fit
[in]n_samplesThe number of samples to use for a single fit
[in]n_iterationsThe number of times a linear fit is performed
[in]error_thresholdThe threshold used to cap errors in the RANSAC process
[in]targetsThe target values
[in]samplesThe samples / feature vectors
[in]DThe dimensionality of the samples
[in]countThe number of samples
[out]parameters*Parameters of the linear fit, of size D + 1 (accounting for a constant 1 being added to the samples to represent a potential bias)
[out]fit_error*Total error of the fit

Definition at line 57 of file RANSAC.c.

References D, fit_linear_model(), get_indices_without_replacement(), n_samples, and predict_value().

+ Here is the call graph for this function: