Loading...
Searching...
No Matches
opengv::sac::MultiSampleConsensusProblem< MODEL_T > Class Template Referenceabstract

`#include <MultiSampleConsensusProblem.hpp>`

## Public Types

typedef MODEL_T | model_t

## Public Member Functions

| MultiSampleConsensusProblem (bool randomSeed=true)
| Contructor.
virtual | ~MultiSampleConsensusProblem ()
| Destructor.
virtual void | getSamples (int &iterations, std::vector< std::vector< int > > &samples)
| Get samples for hypothesis generation.
virtual bool | isSampleGood (const std::vector< std::vector< int > > &sample) const
| Check if a set of samples for model generation is degenerate.
std::shared_ptr< std::vector< std::vector< int > > > | getIndices () const
| Get a pointer to the vector of multi-indices used.
void | drawIndexSample (std::vector< std::vector< int > > &sample)
| Sub-function for getting samples for hypothesis generation.
virtual std::vector< int > | getSampleSizes () const =0
| Get the number of samples needed for a hypothesis generation. Needs implementation in the child class.
virtual bool | computeModelCoefficients (const std::vector< std::vector< int > > &indices, model_t &outModel) const =0
| Compute a model from a set of samples. Needs implementation in the child-class.
virtual void | optimizeModelCoefficients (const std::vector< std::vector< int > > &inliers, const model_t &model_coefficients, model_t &optimized_coefficients)=0
| Refine the model coefficients over a given set (inliers). Needs implementation in the child-class.
virtual void | getSelectedDistancesToModel (const model_t &model, const std::vector< std::vector< int > > &indices, std::vector< std::vector< double > > &scores) const =0
| Compute the distances of all samples whith respect to given model coefficients. Needs implementation in the child-class.
virtual void | getDistancesToModel (const model_t &model_coefficients, std::vector< std::vector< double > > &distances)
| Compute the distances of all samples which respect to given model coefficients.
virtual void | selectWithinDistance (const model_t &model_coefficients, const double threshold, std::vector< std::vector< int > > &inliers)
| Select all the inlier samples whith respect to given model coefficients.
virtual int | countWithinDistance (const model_t &model_coefficients, const double threshold)
| Count all the inlier samples whith respect to given model coefficients.
void | setIndices (const std::vector< std::vector< int > > &indices)
| Set the indices_ variable (see member-description).
void | setUniformIndices (std::vector< int > N)
| Use this method if you want to use all samples.
int | rnd ()
| Get a random number.

## Public Attributes

int | max_sample_checks_
std::shared_ptr< std::vector< std::vector< int > > > | indices_
std::vector< std::vector< int > > | shuffled_indices_
std::mt19937 | rng_alg_
| std-based random number generator algorithm.
std::shared_ptr< std::uniform_int_distribution<> > | rng_dist_
| std-based random number generator distribution.
std::shared_ptr< std::function< int()> > | rng_gen_
| std-based random number generator.

## Detailed Description

template<typename MODEL_T>
class opengv::sac::MultiSampleConsensusProblem< MODEL_T >

Basis-class for Sample-consensus problems containing the three basic functions for model-fitting. This one is using multi-indices for homogeneous sampling over groups of samples.

## Member Typedef Documentation

## model_t

template<typename MODEL_T>

typedef MODEL_T opengv::sac::MultiSampleConsensusProblem< MODEL_T >::model_t

The model we are trying to fit

## Constructor & Destructor Documentation

## MultiSampleConsensusProblem()

template<typename MODEL_T>

opengv::sac::MultiSampleConsensusProblem< MODEL_T >::MultiSampleConsensusProblem | ( | bool | randomSeed = true | ) |

Contructor.

Parameters

  [in] | randomSeed | Setting the seed of the random number generator with something unique, namely the current time.

## Member Function Documentation

## computeModelCoefficients()

template<typename MODEL_T>

virtual bool opengv::sac::MultiSampleConsensusProblem< MODEL_T >::computeModelCoefficients | ( | const std::vector< std::vector< int > > & | indices,
|  | model_t & | outModel ) const

pure virtual

Compute a model from a set of samples. Needs implementation in the child-class.

Parameters

  [in] | indices | The multi-indices of the samples we use for the hypothesis.
  [out] | outModel | The computed model.

Returns
  Success?

Implemented in opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem.

## countWithinDistance()

template<typename MODEL_T>

virtual int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::countWithinDistance | ( | const model_t & | model_coefficients,
|  | const double | threshold )

virtual

Count all the inlier samples whith respect to given model coefficients.

Parameters

  [in] | model_coefficients | The coefficients of the model hypothesis.
  [in] | threshold | A maximum admissible distance threshold for determining the inliers and outliers.

Returns
  The resultant number of inliers

## drawIndexSample()

template<typename MODEL_T>

void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::drawIndexSample | ( | std::vector< std::vector< int > > & | sample | ) |

Sub-function for getting samples for hypothesis generation.

Parameters

  [out] | sample | The multi-indices of the samples we attempt to use.

## getDistancesToModel()

template<typename MODEL_T>

virtual void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::getDistancesToModel | ( | const model_t & | model_coefficients,
|  | std::vector< std::vector< double > > & | distances )

virtual

Compute the distances of all samples which respect to given model coefficients.

Parameters

  [in] | model_coefficients | The coefficients of the model hypothesis.
  [out] | distances | The resultant distances of all samples. Low distances mean a good fit.

## getIndices()

template<typename MODEL_T>

std::shared_ptr< std::vector< std::vector< int > > > opengv::sac::MultiSampleConsensusProblem< MODEL_T >::getIndices | ( |  | ) | const

Get a pointer to the vector of multi-indices used.

Returns
  A pointer to the vector of multi-indices used.

## getSamples()

template<typename MODEL_T>

virtual void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::getSamples | ( | int & | iterations,
|  | std::vector< std::vector< int > > & | samples )

virtual

Get samples for hypothesis generation.

Parameters

  [in] | iterations | We won't try forever to get a good sample, this parameter keeps track of the iterations.
  [out] | samples | The multi-indices of the samples we attempt to use.

## getSampleSizes()

template<typename MODEL_T>

virtual std::vector< int > opengv::sac::MultiSampleConsensusProblem< MODEL_T >::getSampleSizes | ( |  | ) | const

pure virtual

Get the number of samples needed for a hypothesis generation. Needs implementation in the child class.

Returns
  The number of samples in each group needed for hypothesis generation.

Implemented in opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem.

## getSelectedDistancesToModel()

template<typename MODEL_T>

virtual void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::getSelectedDistancesToModel | ( | const model_t & | model,
|  | const std::vector< std::vector< int > > & | indices,
|  | std::vector< std::vector< double > > & | scores ) const

pure virtual

Compute the distances of all samples whith respect to given model coefficients. Needs implementation in the child-class.

Parameters

  [in] | model | The coefficients of the model hypothesis.
  [in] | indices | The multi-indices of the samples of which we compute distances.
  [out] | scores | The resultant distances of the selected samples. Low distances mean a good fit.

Implemented in opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem.

## isSampleGood()

template<typename MODEL_T>

virtual bool opengv::sac::MultiSampleConsensusProblem< MODEL_T >::isSampleGood | ( | const std::vector< std::vector< int > > & | sample | ) | const

virtual

Check if a set of samples for model generation is degenerate.

Parameters

  [in] | sample | The multi-indices of the samples we attempt to use for model instantiation.

Returns
  Is this set of samples ok?

## optimizeModelCoefficients()

template<typename MODEL_T>

virtual void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::optimizeModelCoefficients | ( | const std::vector< std::vector< int > > & | inliers,
|  | const model_t & | model_coefficients,
|  | model_t & | optimized_coefficients )

pure virtual

Refine the model coefficients over a given set (inliers). Needs implementation in the child-class.

Parameters

  [in] | inliers | The multi-indices of the inlier samples supporting the model.
  [in] | model_coefficients | The initial guess for the model coefficients.
  [out] | optimized_coefficients | The resultant refined coefficients.

Implemented in opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem.

## rnd()

template<typename MODEL_T>

int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::rnd | ( |  | ) |

Get a random number.

Returns
  A random number.

## selectWithinDistance()

template<typename MODEL_T>

virtual void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::selectWithinDistance | ( | const model_t & | model_coefficients,
|  | const double | threshold,
|  | std::vector< std::vector< int > > & | inliers )

virtual

Select all the inlier samples whith respect to given model coefficients.

Parameters

  [in] | model_coefficients | The coefficients of the model hypothesis.
  [in] | threshold | A maximum admissible distance threshold for determining the inliers and outliers.
  [out] | inliers | The resultant multi-indices of inlier samples.

## setIndices()

template<typename MODEL_T>

void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::setIndices | ( | const std::vector< std::vector< int > > & | indices | ) |

Set the indices_ variable (see member-description).

Parameters

  [in] | indices | The multi-indices we want to use.

## setUniformIndices()

template<typename MODEL_T>

void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::setUniformIndices | ( | std::vector< int > | N | ) |

Use this method if you want to use all samples.

Parameters

  [in] | N | The number of samples in each group.

## Member Data Documentation

## indices_

template<typename MODEL_T>

std::shared_ptr< std::vector< std::vector<int> > > opengv::sac::MultiSampleConsensusProblem< MODEL_T >::indices_

The multi-indices of the samples we are using for solving the entire problem. These are not the multi-indices for generating a hypothesis, but all indices for model verification

## max_sample_checks_

template<typename MODEL_T>

int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::max_sample_checks_

The maximum number of times we try to extract a valid set of samples

## shuffled_indices_

template<typename MODEL_T>

std::vector< std::vector<int> > opengv::sac::MultiSampleConsensusProblem< MODEL_T >::shuffled_indices_

A shuffled version of the multi-indices used for random sample drawing

The documentation for this class was generated from the following file:

- include/opengv/sac/MultiSampleConsensusProblem.hpp