|
void | AddDebugLevel (const long int lv) |
|
void | AddDebugLevel (const std::string &name) |
|
virtual void | AddGoodGuesses (const std::vector< SolutionType > &Guesses) |
| add some guessed solutions which are tested by RANSAC later More...
|
|
virtual void | ClearGuesses () |
| clear all guesses More...
|
|
bool | DebugLevelIsSet (const long int lv) const |
|
bool | DebugLevelIsSet (const std::string &name) const |
|
virtual bool | EvaluateSolution (const SolutionType &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< SolutionType > &solutions) |
| Compute solution(s) for the given set of samples. More...
|
|
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 |
|
| RANSACPreKnowledge () |
|
| RANSACPreKnowledge (unsigned int sample_size, unsigned int max_solutions_per_sample=1, bool refine_solution=false) |
| Construct a RANSAC object that takes samples of size sample_size, returning at most max_solutions_per_sample solutions each time. More...
|
|
virtual bool | RefineSolution (std::vector< unsigned int > &which_samples, SolutionType &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, SolutionType &solution, std::vector< bool > &inliers) |
| checks UserGuesses and calls RANSAC::SolveMaster More...
|
|
virtual | ~RANSACPreKnowledge () |
| default destructor does nothing More...
|
|
template<class SolutionType>
class BIAS::RANSACPreKnowledge< SolutionType >
Extension of RANSAC algorithm: user-supplied guesses are evaluated and refined using RANSAC criterions before actually starting the RANSAC algorithm.
- Author
- koeser 11/2003
Definition at line 42 of file RANSACPreKnowledge.hh.
template<class SolutionType >
Construct a RANSAC object that takes samples of size sample_size, returning at most max_solutions_per_sample solutions each time.
If the refine_solution flag is true, a routine has been supplied to refine the initial fits before evaluation.
Definition at line 67 of file RANSACPreKnowledge.hh.
References BIAS::Debug::NewDebugLevel().
template<class SolutionType>
bool BIAS::RANSAC< SolutionType >::EvaluateSolution |
( |
const SolutionType & |
solution, |
|
|
bool |
existing_solution_flag, |
|
|
std::vector< bool > & |
inlier, |
|
|
int & |
accept_count, |
|
|
double & |
evaluate_score, |
|
|
bool & |
ok_to_terminate_flag |
|
) |
| |
|
inlinevirtualinherited |
evaluate the goodness of a solution
For the specified solution, set
- an accept count indicating the number of data which are inliers to the given solution,
- the inlier flag for each datum to true if the datum is inlying
- an evaluate score (typically the average residual) indicating the goodness of fit of the inliers - the solver code requires a positive number where zero is a perfect solution, larger positive scores mean a worse solution.
- an ok_to_terminate flag which is set TRUE if the solution is good enough that the robust solver can discontinue search for a better solution. Only happens, if greedy is set to true.
- The return value tells the algorithm, if the solution is good enough to be refined further - meaning, if set to true and if RefineSolution_ is set to true, the solution will be refined. In the example below, true is returned even if only one samples has been found to be an inlier. Because refinement usually takes quite a while, it is sensible to use a higher threshold. For example the use of a minimum inlier fraction via a private variable in the child class can be tested on.
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.
- Parameters
-
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 in BIAS::PlaneRANSAC, and BIAS::RANSAC_double.
Definition at line 748 of file RANSAC.hh.
template<class SolutionType >
bool BIAS::RANSAC< SolutionType >::GenerateSamples |
( |
int |
sample_index, |
|
|
std::vector< unsigned int > & |
which_samples |
|
) |
| |
|
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.
Definition at line 768 of file RANSAC.hh.
template<class SolutionType>
int BIAS::RANSAC< SolutionType >::GetSampleSolutions |
( |
std::vector< unsigned int > & |
which_samples, |
|
|
std::vector< SolutionType > & |
solutions |
|
) |
| |
|
inlinevirtualinherited |
Compute solution(s) for the given set of samples.
- Returns
- the number of solutions found.
The which_samples array will be of length sample_size, selecting the indices to be fit to from the subclass's data array.
Reimplemented in BIAS::PlaneRANSAC, and BIAS::RANSAC_double.
Definition at line 738 of file RANSAC.hh.
template<class SolutionType>
bool BIAS::RANSAC< SolutionType >::RefineSolution |
( |
std::vector< unsigned int > & |
which_samples, |
|
|
SolutionType & |
solution, |
|
|
std::vector< bool > & |
new_inliers |
|
) |
| |
|
inlinevirtualinherited |
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.
- Returns
- false if no better solution than the initial could be found
Reimplemented in BIAS::PlaneRANSAC, and BIAS::RANSAC_double.
Definition at line 758 of file RANSAC.hh.
template<class SolutionType>
void BIAS::RANSAC< SolutionType >::SetMaxSamples |
( |
unsigned int |
max_samples | ) |
|
|
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.
template<class SolutionType>
void BIAS::RANSAC< SolutionType >::SetSampleCount |
( |
unsigned int |
uiSamples | ) |
|
|
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
- Author
- koeser
Definition at line 124 of file RANSAC.hh.