Basic Image AlgorithmS Library
2.8.0
|
Robust mean computation for double values using RANSAC. More...
#include <MathAlgo/Examples/ExampleRANSAC_double.hh>
Public Member Functions | |
void | AddDebugLevel (const long int lv) |
void | AddDebugLevel (const std::string &name) |
bool | DebugLevelIsSet (const long int lv) const |
bool | DebugLevelIsSet (const std::string &name) const |
virtual bool | EvaluateSolution (const double &solution, bool existing_solution_flag, std::vector< bool > &inlier, int &accept_count, double &evaluate_score, bool &ok_to_terminate_flag) |
evaluate the goodness of a solution More... | |
virtual bool | GenerateSamples (int sample_index, std::vector< unsigned int > &which_samples) |
pick a set of samples More... | |
bool | GenerateSamplesEvenspace (int sample_index, std::vector< unsigned int > &sample_table) |
bool | GenerateSamplesRandom (int sample_index, std::vector< unsigned int > &sampletable) |
int | GetDebugLevel () const |
std::ostream & | GetDebugStream () const |
void | GetDebugStream (std::ostream &os) const |
double | GetFinalScore () const |
virtual int | GetSampleSolutions (std::vector< unsigned int > &which_samples, std::vector< double > &solutions) |
Compute solution(s) for the given set of samples. More... | |
void | Init (std::vector< double > &data, unsigned int sample_size, double inlier_distance_threshold, bool refine_solution, double expected_inlier_fraction, double solution_error_threshold) |
void | Init (unsigned int sample_size, unsigned int max_solutions_per_sample=1, bool refine_solution=false, bool greedy=false) |
long int | Name2DebugLevel (const std::string &name) const |
looks up a debuglevel in the internal map, returns 0 if not found More... | |
long int | NewDebugLevel (const std::string &name) |
creates a new debuglevel More... | |
void | PrintDebugLevel (std::ostream &os=std::cout) const |
RANSAC_double () | |
virtual bool | RefineSolution (std::vector< unsigned int > &which_samples, double &solution, std::vector< bool > &new_inliers) |
refine previously computed solution based on its inliers More... | |
void | RemoveDebugLevel (const long int lv) |
void | RemoveDebugLevel (const std::string &name) |
void | SetDebugLevel (const long int lv) |
void | SetDebugLevel (const std::string &name) |
void | SetDebugStream (const std::ostream &os) |
void | SetMaxSamples (unsigned int max_samples) |
Explicitly set max number of samples. More... | |
void | SetSampleCount (unsigned int uiSamples) |
Explicitly set number of samples. More... | |
void | ShowDebugLevel (std::ostream &os=std::cout) const |
prints all internally known debuglevels More... | |
virtual int | SolveMaster (double inlying_data_fraction, double &solution, std::vector< bool > &inliers) |
Main computation function called by user. More... | |
~RANSAC_double () | |
Static Public Member Functions | |
static long int | GetGlobalDebugLevel () |
static void | SetGlobalDebugLevel (long int lev) |
Protected Member Functions | |
long | ConsumeNextFreeDebuglevel_ () |
returns the next available debuglevel More... | |
Static Protected Member Functions | |
static int | ComputeSampleCount (double inlying_data_fraction, double desired_prob_good, unsigned int sample_size) |
Protected Attributes | |
bool | _bRefineSolution |
do we want to refine a good sample (one for which evaluate solution returned true)? More... | |
double | _dBestInlierEvaluateScore |
double | _dBestSampleEvaluateScore |
double | _dExpectedInlierFraction |
double | _dInlierDistanceThreshold |
double | _dLastBestSampleEvaluateScore |
double | _dProbabilityOfGoodSolution |
prob. for computing number of samples, set close to 1 More... | |
double | _dSolutionErrorThreshold |
double | _dSoSmallSolutionChange |
If all other conditions are right, and the fractional change in the solution statistics is less than this, stop sampling. More... | |
bool | _got_solution_flag |
if we already have a solution for which EvaluateSolution returned true More... | |
bool | _greedy |
if true, the first acceptable solution is returned More... | |
int | _iBestInlierAcceptCount |
refined best values More... | |
int | _iBestSampleAcceptCount |
sampled best values More... | |
long int | _liDebugLevel |
long int | _liNextDebugLevel |
new concept, debuglevel are managed here in the debug class More... | |
std::map< std::string, long int > | _String2Debuglevel |
unsigned | _uiDataSize |
number of data elements needed to compute a solution More... | |
unsigned int | _uiExplicitSampleNo |
use this number of samples More... | |
unsigned int | _uiMaxSamples |
absolute max number of samples More... | |
unsigned | _uiMaxSolutionsPerSample |
max number of solutions that are to be computed for one sample set More... | |
unsigned | _uiSampleSize |
number of samples available More... | |
std::vector< double > | _vData |
Static Protected Attributes | |
static std::ostream | _zDebugStream |
static long int | GlobalDebugLevel = 0 |
Robust mean computation for double values using RANSAC.
This class implements a simple example for RANSAC class overloading.
Method RANSAC_double::GetSampleSolutions picks a number of values and computes the mean from them. The sample size is not fixed here but can be chosen when calling method RANSAC_double::Init.
Method RANSAC_double::EvaluateSolution evaluates how many values are considered as "inliers" with respect to the mean hypothesis, i.e. their distance to the mean does not exceed a certain threshold.
In RANSAC_double::RefineSolution the mean is recomputed for all inliers.
You have to set the inlier threshold (max. distance to mean to accept a value as being an inlier) and the fraction of valid input values which will define the number of samples evaluated by RANSAC.
Definition at line 53 of file ExampleRANSAC_double.hh.
BIAS::RANSAC_double::RANSAC_double | ( | ) |
Definition at line 94 of file ExampleRANSAC_double.hh.
BIAS::RANSAC_double::~RANSAC_double | ( | ) |
Definition at line 97 of file ExampleRANSAC_double.hh.
|
inlineinherited |
Definition at line 355 of file Debug.hh.
Referenced by BIAS::GLProjectionParametersBase::AddDebugLevel(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::FilterBase< InputStorageType, OutputStorageType >::FilterBase(), BIAS::ShowCamWxVideoSourceFactory::OpenDevice(), and BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph().
|
inlineinherited |
|
inlinestaticprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
Definition at line 341 of file Debug.hh.
Referenced by BIAS::GenSynthMatches::_AddUniformDistributedOutliers(), BIAS::GenSynthMatches::_CreateCamMovement(), BIAS::GenSynthMatches::_CreateStatic2DPoints(), BIAS::UnscentedTransform::ComputeSigmaPoints_(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::GenSynthMatches::GetGTNormalizedF(), BIAS::MonteCarloTransform::GetSamples_(), and BIAS::MonteCarloTransform::Transform().
|
inlineinherited |
|
virtual |
evaluate the goodness of a solution
For the specified solution, set
If existing_solution_flag is true, then the best accept count so far is in accept_count. The function can terminate early if it is not going to beat this.
A skeleton implementation of this function would be written as follows:
* int my_accept_count = 0; * for (unsigned int i=0; i<_uiDataSize; i++) { * inlier[i] = Consistent(corner_matches[i], solution); * if (inlier[i]) { * my_accept_count++; * evaluate_score += Residual(corner_matches[i], solution); * if (existing_solution_flag && my_accept_count>accept_count) * break; * } * } * accept_count=my_accept_count; * evaluate_score=(accept_count!=0)?(evaluate_score/accept_count): * (DBL_MAX); * if (evaluate_score < solution_error_threshold && * (double)accept_count/(double)_uiDataSize > min_inlier_fraction) * ok_to_terminate_flag=true; * else * ok_to_terminate_flag=false; * return (accept_count!=0) // maybe even (accept_count>inl_frac) *
The line if (existing_solution_flag && my_accept_count>accept_count) break; causes the algorithm to not determine the score and acceptcount correctly, only so far as to top the so far best solution. It can be used for very fast solutions, however if the exact inliers are needed and refineSolution_ is set to false, the evaluation should not be omnitted.
solution | (in) solution to be evaluated |
existing_solution_flag | (in) if true the best accept_cout so far is given in accept_count |
accept_count | (in/out) input: best accept_cout so far if existing_solution_flag==true, output: number of inliers to the current solution |
inlier | (out) inlier[i] ==> datum i is inlying |
evaluate_score | (out) a score for the solution, 0 means ideal solution, larger score means worse solution |
ok_to_termiate_flag | (out) if true, RANSACing will stop |
Reimplemented from BIAS::RANSAC< double >.
Definition at line 129 of file ExampleRANSAC_double.hh.
References _dExpectedInlierFraction, _dInlierDistanceThreshold, _dSolutionErrorThreshold, BIAS::RANSAC< double >::_uiDataSize, and _vData.
|
inlinevirtualinherited |
pick a set of samples
Override this to specialize the technique used to generate samples. By default, random sampling is assumed but implementations may wish to use the latin-square sampling provided by generate_sample_evenspace (below), or some other problem-specific sampling strategy.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Definition at line 332 of file Debug.hh.
Referenced by BIAS::listenthread(), BIAS::Image< StorageType >::operator=(), and BIAS::ImageBase::operator=().
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Definition at line 260 of file RANSAC.hh.
References BIAS::RANSAC< SolutionType >::_dLastBestSampleEvaluateScore.
|
inlinestaticinherited |
|
virtual |
Compute solution(s) for the given set of samples.
The which_samples array will be of length sample_size, selecting the indices to be fit to from the subclass's data array.
Reimplemented from BIAS::RANSAC< double >.
Definition at line 116 of file ExampleRANSAC_double.hh.
References _vData.
void BIAS::RANSAC_double::Init | ( | std::vector< double > & | data, |
unsigned int | sample_size, | ||
double | inlier_distance_threshold, | ||
bool | refine_solution, | ||
double | expected_inlier_fraction, | ||
double | solution_error_threshold | ||
) |
Definition at line 100 of file ExampleRANSAC_double.hh.
References _dExpectedInlierFraction, _dInlierDistanceThreshold, _dSolutionErrorThreshold, BIAS::RANSAC< double >::_uiDataSize, _vData, and BIAS::RANSAC< SolutionType >::Init().
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
creates a new debuglevel
Definition at line 474 of file Debug.hh.
Referenced by BIAS::COSAC< SolutionType >::COSAC(), BIAS::ProjectionParametersPerspectiveDepth::Init(), BIAS::MonteCarloTransform::MonteCarloTransform(), BIAS::PMatrixEstimation::PMatrixEstimation(), BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC(), BIAS::RANSACPreKnowledge< SolutionType >::RANSACPreKnowledge(), BIAS::ROI::ROI(), BIAS::RotationAveraging::RotationAveraging(), BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph(), BIAS::ThreeDOutOpenSceneGraph::ThreeDOutOpenSceneGraph(), BIAS::Triangulation::Triangulation(), and BIAS::UnscentedTransform::UnscentedTransform().
|
inlineinherited |
|
virtual |
refine previously computed solution based on its inliers
If implemented, this function should compute a more accurate solution, e.g. a least squares on all inliers, possibly using as an initial estimate the solution in solution. The output array new_inliers should be set to reflect the inliers to the new solution.
Reimplemented from BIAS::RANSAC< double >.
Definition at line 167 of file ExampleRANSAC_double.hh.
References _dInlierDistanceThreshold, BIAS::RANSAC< double >::_uiDataSize, and _vData.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Definition at line 318 of file Debug.hh.
Referenced by BIAS::ShowCamWxVideoSourceFactory::CreateBumbleBee(), BIAS::ShowCamWxVideoSourceFactory::CreateDCAM(), BIAS::VideoSource_MDcam::ScanBus(), BIAS::GLProjectionParametersBase::SetDebugLevel(), BIAS::VideoSource_Disk::VideoSource_Disk(), BIAS::VideoSource_DV2::VideoSource_DV2(), BIAS::VideoSource_DV::VideoSource_DV_Internal_Init_(), and BIAS::VideoSource_V4L::VideoSource_V4L().
|
inlineinherited |
|
inlineinherited |
|
inlinestaticinherited |
|
inlineinherited |
Explicitly set max number of samples.
Ransacing will stop after max_samples samples, regardless of solution quality. Normally, more than a few thousand samples signifies a problem.
Definition at line 112 of file RANSAC.hh.
References BIAS::RANSAC< SolutionType >::_uiMaxSamples.
|
inlineinherited |
Explicitly set number of samples.
Explicitly set number of samples to make in SolveMaster, i.e. Value of ComputeSampleCount() is ignored if this function is called with a strictly positive value uiSamples. Note: SolveMaster performs at most min(_uiMaxSamples, uiSamples) iterations
Definition at line 124 of file RANSAC.hh.
References BIAS::RANSAC< SolutionType >::_uiExplicitSampleNo.
|
inlineinherited |
|
inlinevirtualinherited |
Main computation function called by user.
This function is called to run the computation. On output, solution is set to the best solution found and inliers indicate which data were inliers to that solution. The inlying_data_fraction is responsible for the maximal number of sample sets taken from the data. The smaller the inlying_data_fraction, the more sample sets are taken
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
Definition at line 90 of file ExampleRANSAC_double.hh.
Referenced by EvaluateSolution(), and Init().
|
protected |
Definition at line 86 of file ExampleRANSAC_double.hh.
Referenced by EvaluateSolution(), Init(), and RefineSolution().
|
protectedinherited |
|
protectedinherited |
|
protected |
Definition at line 91 of file ExampleRANSAC_double.hh.
Referenced by EvaluateSolution(), and Init().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Definition at line 510 of file Debug.hh.
Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().
|
protectedinherited |
new concept, debuglevel are managed here in the debug class
Definition at line 516 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
protectedinherited |
Definition at line 517 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
protectedinherited |
number of data elements needed to compute a solution
Definition at line 270 of file RANSAC.hh.
Referenced by EvaluateSolution(), Init(), and RefineSolution().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
Definition at line 83 of file ExampleRANSAC_double.hh.
Referenced by EvaluateSolution(), GetSampleSolutions(), Init(), and RefineSolution().
|
staticprotectedinherited |
Definition at line 511 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |