OpenGV
A library for solving calibrated central and non-central geometric vision problems
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. More...
 
virtual ~MultiSampleConsensusProblem ()
 Destructor.
 
virtual void getSamples (int &iterations, std::vector< std::vector< int > > &samples)
 Get samples for hypothesis generation. More...
 
virtual bool isSampleGood (const std::vector< std::vector< int > > &sample) const
 Check if a set of samples for model generation is degenerate. More...
 
std::shared_ptr< std::vector< std::vector< int > > > getIndices () const
 Get a pointer to the vector of multi-indices used. More...
 
void drawIndexSample (std::vector< std::vector< int > > &sample)
 Sub-function for getting samples for hypothesis generation. More...
 
virtual std::vector< int > getSampleSizes () const =0
 Get the number of samples needed for a hypothesis generation. Needs implementation in the child class. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual int countWithinDistance (const model_t &model_coefficients, const double threshold)
 Count all the inlier samples whith respect to given model coefficients. More...
 
void setIndices (const std::vector< std::vector< int > > &indices)
 Set the indices_ variable (see member-description). More...
 
void setUniformIndices (std::vector< int > N)
 Use this method if you want to use all samples. More...
 
int rnd ()
 Get a random number. More...
 

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

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

The model we are trying to fit

Constructor & Destructor Documentation

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

Contructor.

Parameters
[in]randomSeedSetting the seed of the random number generator with something unique, namely the current time.

Member Function Documentation

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]indicesThe multi-indices of the samples we use for the hypothesis.
[out]outModelThe computed model.
Returns
Success?

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

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_coefficientsThe coefficients of the model hypothesis.
[in]thresholdA maximum admissible distance threshold for determining the inliers and outliers.
Returns
The resultant number of inliers
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]sampleThe multi-indices of the samples we attempt to use.
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_coefficientsThe coefficients of the model hypothesis.
[out]distancesThe resultant distances of all samples. Low distances mean a good fit.
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.
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]iterationsWe won't try forever to get a good sample, this parameter keeps track of the iterations.
[out]samplesThe multi-indices of the samples we attempt to use.
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::relative_pose::MultiNoncentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem.

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]modelThe coefficients of the model hypothesis.
[in]indicesThe multi-indices of the samples of which we compute distances.
[out]scoresThe resultant distances of the selected samples. Low distances mean a good fit.

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

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]sampleThe multi-indices of the samples we attempt to use for model instantiation.
Returns
Is this set of samples ok?
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]inliersThe multi-indices of the inlier samples supporting the model.
[in]model_coefficientsThe initial guess for the model coefficients.
[out]optimized_coefficientsThe resultant refined coefficients.

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

template<typename MODEL_T>
int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::rnd ( )

Get a random number.

Returns
A random number.
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_coefficientsThe coefficients of the model hypothesis.
[in]thresholdA maximum admissible distance threshold for determining the inliers and outliers.
[out]inliersThe resultant multi-indices of inlier samples.
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]indicesThe multi-indices we want to use.
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]NThe number of samples in each group.

Member Data Documentation

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

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

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: