#include <SampleConsensusProblem.hpp>
Public Types | |
typedef MODEL_T | model_t |
Public Member Functions | |
SampleConsensusProblem (bool randomSeed=true) | |
Contructor. More... | |
virtual | ~SampleConsensusProblem () |
Destructor. | |
virtual void | getSamples (int &iterations, std::vector< int > &samples) |
Get samples for hypothesis generation. More... | |
virtual bool | isSampleGood (const std::vector< int > &sample) const |
Check if a set of samples for model generation is degenerate. More... | |
std::shared_ptr< std::vector< int > > | getIndices () const |
Get a pointer to the vector of indices used. More... | |
void | drawIndexSample (std::vector< int > &sample) |
Sub-function for getting samples for hypothesis generation. More... | |
virtual int | getSampleSize () 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< 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< 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< int > &indices, 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< 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< 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< int > &indices) |
Set the indices_ variable (see member-description). More... | |
void | setUniformIndices (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< int > > | indices_ |
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.
typedef MODEL_T opengv::sac::SampleConsensusProblem< MODEL_T >::model_t |
The model we are trying to fit
opengv::sac::SampleConsensusProblem< MODEL_T >::SampleConsensusProblem | ( | 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 indices of the samples we use for the hypothesis. |
[out] | outModel | The computed model. |
Implemented in opengv::sac_problems::relative_pose::NoncentralRelativePoseSacProblem, opengv::sac_problems::absolute_pose::AbsolutePoseSacProblem, opengv::sac_problems::relative_pose::CentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::EigensolverSacProblem, opengv::sac_problems::relative_pose::RotationOnlySacProblem, opengv::sac_problems::relative_pose::TranslationOnlySacProblem, and opengv::sac_problems::point_cloud::PointCloudSacProblem.
|
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::SampleConsensusProblem< MODEL_T >::drawIndexSample | ( | std::vector< int > & | sample | ) |
Sub-function for getting samples for hypothesis generation.
[out] | sample | The 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<int> > opengv::sac::SampleConsensusProblem< MODEL_T >::getIndices | ( | ) | const |
Get a pointer to the vector of 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 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::NoncentralRelativePoseSacProblem, opengv::sac_problems::absolute_pose::AbsolutePoseSacProblem, opengv::sac_problems::relative_pose::CentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::EigensolverSacProblem, opengv::sac_problems::relative_pose::RotationOnlySacProblem, opengv::sac_problems::relative_pose::TranslationOnlySacProblem, and opengv::sac_problems::point_cloud::PointCloudSacProblem.
|
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 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::NoncentralRelativePoseSacProblem, opengv::sac_problems::absolute_pose::AbsolutePoseSacProblem, opengv::sac_problems::relative_pose::CentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::EigensolverSacProblem, opengv::sac_problems::relative_pose::RotationOnlySacProblem, opengv::sac_problems::relative_pose::TranslationOnlySacProblem, and opengv::sac_problems::point_cloud::PointCloudSacProblem.
|
virtual |
Check if a set of samples for model generation is degenerate.
[in] | sample | The 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 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::NoncentralRelativePoseSacProblem, opengv::sac_problems::absolute_pose::AbsolutePoseSacProblem, opengv::sac_problems::relative_pose::CentralRelativePoseSacProblem, opengv::sac_problems::relative_pose::EigensolverSacProblem, opengv::sac_problems::relative_pose::RotationOnlySacProblem, opengv::sac_problems::relative_pose::TranslationOnlySacProblem, and opengv::sac_problems::point_cloud::PointCloudSacProblem.
int opengv::sac::SampleConsensusProblem< 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 indices of inlier samples. |
void opengv::sac::SampleConsensusProblem< MODEL_T >::setIndices | ( | const std::vector< int > & | indices | ) |
Set the indices_ variable (see member-description).
[in] | indices | The indices we want to use. |
void opengv::sac::SampleConsensusProblem< MODEL_T >::setUniformIndices | ( | int | N | ) |
Use this method if you want to use all samples.
[in] | N | The number of samples. |
std::shared_ptr< std::vector<int> > opengv::sac::SampleConsensusProblem< MODEL_T >::indices_ |
The indices of the samples we are using for solving the entire problem. These are not the indices for generating a hypothesis, but all indices for model verification
int opengv::sac::SampleConsensusProblem< MODEL_T >::max_sample_checks_ |
The maximum number of times we try to extract a valid set of samples
std::vector<int> opengv::sac::SampleConsensusProblem< MODEL_T >::shuffled_indices_ |
A shuffled version of the indices used for random sample drawing