#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. | |
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.
typedef MODEL_T opengv::sac::MultiSampleConsensusProblem< MODEL_T >::model_t |
The model we are trying to fit
opengv::sac::MultiSampleConsensusProblem< MODEL_T >::MultiSampleConsensusProblem | ( | bool | randomSeed = true | ) |
Contructor.
[in] | randomSeed | Setting the seed of the random number generator with something unique, namely the current time. |
|
pure virtual |
Compute a model from a set of samples. Needs implementation in the child-class.
[in] | indices | The multi-indices of the samples we use for the hypothesis. |
[out] | outModel | The computed model. |
Implemented in opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem.
|
virtual |
Count all the inlier samples whith respect to given model coefficients.
[in] | model_coefficients | The coefficients of the model hypothesis. |
[in] | threshold | A maximum admissible distance threshold for determining the inliers and outliers. |
void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::drawIndexSample | ( | std::vector< std::vector< int > > & | sample | ) |
Sub-function for getting samples for hypothesis generation.
[out] | sample | The multi-indices of the samples we attempt to use. |
|
virtual |
Compute the distances of all samples which respect to given model coefficients.
[in] | model_coefficients | The coefficients of the model hypothesis. |
[out] | distances | The resultant distances of all samples. Low distances mean a good fit. |
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.
|
virtual |
Get samples for hypothesis generation.
[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. |
|
pure virtual |
Get the number of samples needed for a hypothesis generation. Needs implementation in the child class.
Implemented in opengv::sac_problems::relative_pose::MultiNoncentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem.
|
pure virtual |
Compute the distances of all samples whith respect to given model coefficients. Needs implementation in the child-class.
[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::relative_pose::MultiNoncentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem.
|
virtual |
Check if a set of samples for model generation is degenerate.
[in] | sample | The multi-indices of the samples we attempt to use for model instantiation. |
|
pure virtual |
Refine the model coefficients over a given set (inliers). Needs implementation in the child-class.
[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::relative_pose::MultiNoncentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::MultiCentralRelativePoseSacProblem, and opengv::sac_problems::absolute_pose::MultiNoncentralAbsolutePoseSacProblem.
int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::rnd | ( | ) |
Get a random number.
|
virtual |
Select all the inlier samples whith respect to given model coefficients.
[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. |
void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::setIndices | ( | const std::vector< std::vector< int > > & | indices | ) |
Set the indices_ variable (see member-description).
[in] | indices | The multi-indices we want to use. |
void opengv::sac::MultiSampleConsensusProblem< MODEL_T >::setUniformIndices | ( | std::vector< int > | N | ) |
Use this method if you want to use all samples.
[in] | N | The number of samples in each group. |
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
int opengv::sac::MultiSampleConsensusProblem< MODEL_T >::max_sample_checks_ |
The maximum number of times we try to extract a valid set of samples
std::vector< std::vector<int> > opengv::sac::MultiSampleConsensusProblem< MODEL_T >::shuffled_indices_ |
A shuffled version of the multi-indices used for random sample drawing