Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::PreemptiveRANSAC< SolutionType > Class Template Reference

Fast RANSAC after David Nister, "Preemptive RANSAC for Live Structure And Motion Estimation", Internation Conference on Computer Vision (ICCV) 2003. More...

#include <MathAlgo/PreemptiveRANSAC.hh>

+ Inheritance diagram for BIAS::PreemptiveRANSAC< SolutionType >:
+ Collaboration diagram for BIAS::PreemptiveRANSAC< SolutionType >:

Classes

struct  SolStruct
 

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
void AddSolutionGuesses (const std::vector< SolutionType > &guesses)
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
void Init ()
 
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...
 
 PreemptiveRANSAC (RANSACEvaluatorInterface< SolutionType > *shi)
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
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 SetEvaluationBlockSize (const unsigned eval_block_size)
 after each EvaluationBlockSize-th measurement, the solutions are compared and only the better half is kept More...
 
void SetGreedy (const bool greedy)
 
void SetMaxSamples (const unsigned max_samples)
 Set max number of samples. More...
 
void SetMinNumInitialInliers (const unsigned min_num_initial_inl)
 when less than MinNumInitialInliers are found, the solution is rejected straight away More...
 
void SetMinSamples (const unsigned min_samples)
 Set min number of samples. More...
 
void SetNumInitialChecked (const unsigned num_initial_checked)
 the number of measurements that is initially evaluated More...
 
void SetRefineSolutions (const bool refine_solutions)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
int SolveMaster (const double inlying_data_fraction, const double max_score, SolutionType &solution, std::vector< bool > &inliers, unsigned &num_inliers, double &score, const bool auto_compute_max_samples=false)
 
virtual ~PreemptiveRANSAC ()
 

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...
 
void ConvertInliers_ (const std::vector< bool > &inliers_in_eval_order, std::vector< bool > &inliers) const
 
void EvaluateSolutions_ (const unsigned start_index, const unsigned data_size)
 
void GenerateEvaluationOrder_ (const unsigned data_size)
 
int GenerateRefinedSolutions_ (const unsigned data_size)
 returns the number of succesfully refined solutions More...
 
int GenerateSolutions_ (const unsigned block_num, const unsigned sample_size, const unsigned data_size)
 returns the number of generated solution More...
 
int GetSolution_ (const unsigned min_num_inliers, const double max_score, SolutionType &solution, std::vector< bool > &inliers, unsigned &num_inliers, double &score) const
 
struct SolStructGetSolutionMaxInliers_ (const unsigned min_num_inliers, const double max_score) const
 
struct SolStructGetSolutionMinScore_ (const unsigned min_num_inliers, const double max_score) const
 
int InitialRejectTcd_ (const unsigned min_num_inliers, const unsigned num_checked)
 returns the number of rejected solutions More...
 
bool IsInlier_ (typename std::list< SolStruct >::iterator solution, const unsigned data_index, double &score)
 
int RejectSolutions_ (const unsigned eval_index)
 returns the number of rejected solutions More...
 

Protected Attributes

bool _bGreedy
 should termination be aborted when first good solution is found? More...
 
bool _bInitialised
 just to check if the class is used correctly More...
 
bool _bRefineSolutions
 should the solutions be refined? More...
 
std::vector< unsigned > _EvaluationOrder
 the order in which data is used for solutions evaluation More...
 
long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
RANSACEvaluatorInterface
< SolutionType > * 
_RANSACEvaluator
 the helper class for solution computation and sample evaluation More...
 
std::list< SolStruct_Solutions
 all (remaining) solutions More...
 
std::map< std::string, long int > _String2Debuglevel
 
unsigned _uiDataSize
 the number of data for evaluation More...
 
unsigned _uiEvaluationBlockSize
 after EvaluationBlockSize, bad solutions are removed More...
 
unsigned _uiMaxSamples
 
unsigned _uiMinNumInitialInliers
 the minimum number of inlier from _uiNumInitialChecked More...
 
unsigned _uiMinSamples
 the minimu and maximum number of samples investigated More...
 
unsigned _uiNumInitialChecked
 the number of datat points that is initially checked More...
 
unsigned _uiSampleSize
 the number of samples needed by GetSampleSolutions More...
 
BIAS::Random randomizer_
 randomizer instance used for evaluation order computation More...
 
int sample_offset
 prevents that calls to GenerateSample_() generate the same random sample if sample solution creation fails! More...
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long int GlobalDebugLevel = 0
 

Detailed Description

template<class SolutionType>
class BIAS::PreemptiveRANSAC< SolutionType >

Fast RANSAC after David Nister, "Preemptive RANSAC for Live Structure And Motion Estimation", Internation Conference on Computer Vision (ICCV) 2003.

The algorithm (preemptive RANSAC) is decoupled from the problem (for example HMatrix estimation) using a common interface class, the RANSACEvaluatorInterace. To use this class it is therefore necessary to derive from RANSACEvaluatorInterface and overload the functions:

bool IsInlier(const SolutionType& solution, const unsigned data_index, double& score) = 0;

int GetSampleSolutions(const std::vector<unsigned> &which_samples, std::vector<SolutionType> &solutions)= 0;

bool RefineSolution(const std::vector<bool>& inliers, SolutionType& solution) = 0;

Instantiate PreemptiveRANSAC with a pointer to the sibling of RANSACEvaluatorInterface as argment to the constructor and call alternatingly

Init() and SolveMaster()

Author
woelk 2006?

Definition at line 85 of file PreemptiveRANSAC.hh.

Constructor & Destructor Documentation

template<class SolutionType >
BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC ( RANSACEvaluatorInterface< SolutionType > *  shi)
template<class SolutionType>
virtual BIAS::PreemptiveRANSAC< SolutionType >::~PreemptiveRANSAC ( )
inlinevirtual

Definition at line 90 of file PreemptiveRANSAC.hh.

Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

template<class SolutionType >
void BIAS::PreemptiveRANSAC< SolutionType >::AddSolutionGuesses ( const std::vector< SolutionType > &  guesses)
long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

template<class SolutionType >
void BIAS::PreemptiveRANSAC< SolutionType >::ConvertInliers_ ( const std::vector< bool > &  inliers_in_eval_order,
std::vector< bool > &  inliers 
) const
inlineprotected

Definition at line 828 of file PreemptiveRANSAC.hh.

bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

template<class SolutionType >
void BIAS::PreemptiveRANSAC< SolutionType >::EvaluateSolutions_ ( const unsigned  start_index,
const unsigned  data_size 
)
protected

Definition at line 713 of file PreemptiveRANSAC.hh.

template<class SolutionType >
void BIAS::PreemptiveRANSAC< SolutionType >::GenerateEvaluationOrder_ ( const unsigned  data_size)
protected

Definition at line 526 of file PreemptiveRANSAC.hh.

template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::GenerateRefinedSolutions_ ( const unsigned  data_size)
protected
template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::GenerateSolutions_ ( const unsigned  block_num,
const unsigned  sample_size,
const unsigned  data_size 
)
protected
int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::GetSolution_ ( const unsigned  min_num_inliers,
const double  max_score,
SolutionType &  solution,
std::vector< bool > &  inliers,
unsigned &  num_inliers,
double &  score 
) const
protected
template<class SolutionType>
struct SolStruct* BIAS::PreemptiveRANSAC< SolutionType >::GetSolutionMaxInliers_ ( const unsigned  min_num_inliers,
const double  max_score 
) const
inlineprotected
template<class SolutionType>
struct SolStruct* BIAS::PreemptiveRANSAC< SolutionType >::GetSolutionMinScore_ ( const unsigned  min_num_inliers,
const double  max_score 
) const
inlineprotected
template<class SolutionType >
void BIAS::PreemptiveRANSAC< SolutionType >::Init ( )

Definition at line 304 of file PreemptiveRANSAC.hh.

template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::InitialRejectTcd_ ( const unsigned  min_num_inliers,
const unsigned  num_checked 
)
protected

returns the number of rejected solutions

Definition at line 636 of file PreemptiveRANSAC.hh.

template<class SolutionType >
bool BIAS::PreemptiveRANSAC< SolutionType >::IsInlier_ ( typename std::list< SolStruct >::iterator  solution,
const unsigned  data_index,
double &  score 
)
inlineprotected

Definition at line 677 of file PreemptiveRANSAC.hh.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::RejectSolutions_ ( const unsigned  eval_index)
protected

returns the number of rejected solutions

Definition at line 735 of file PreemptiveRANSAC.hh.

References BIAS::Median1D< DataType >::Compute(), and BIAS::Median1D< DataType >::GetMedian().

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetEvaluationBlockSize ( const unsigned  eval_block_size)
inline

after each EvaluationBlockSize-th measurement, the solutions are compared and only the better half is kept

Definition at line 138 of file PreemptiveRANSAC.hh.

References BIAS::PreemptiveRANSAC< SolutionType >::_uiEvaluationBlockSize.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetGreedy ( const bool  greedy)
inline
template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetMaxSamples ( const unsigned  max_samples)
inline

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 111 of file PreemptiveRANSAC.hh.

References BIAS::PreemptiveRANSAC< SolutionType >::_uiMaxSamples.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetMinNumInitialInliers ( const unsigned  min_num_initial_inl)
inline

when less than MinNumInitialInliers are found, the solution is rejected straight away

Definition at line 130 of file PreemptiveRANSAC.hh.

References BIAS::PreemptiveRANSAC< SolutionType >::_uiMinNumInitialInliers.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetMinSamples ( const unsigned  min_samples)
inline

Set min number of samples.

Ransacing will evaluate and compare solutions using sets of MinSamples solutions.

Definition at line 118 of file PreemptiveRANSAC.hh.

References BIAS::PreemptiveRANSAC< SolutionType >::_uiMinSamples.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetNumInitialChecked ( const unsigned  num_initial_checked)
inline

the number of measurements that is initially evaluated

Definition at line 125 of file PreemptiveRANSAC.hh.

References BIAS::PreemptiveRANSAC< SolutionType >::_uiNumInitialChecked.

template<class SolutionType>
void BIAS::PreemptiveRANSAC< SolutionType >::SetRefineSolutions ( const bool  refine_solutions)
inline
void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

template<class SolutionType >
int BIAS::PreemptiveRANSAC< SolutionType >::SolveMaster ( const double  inlying_data_fraction,
const double  max_score,
SolutionType &  solution,
std::vector< bool > &  inliers,
unsigned &  num_inliers,
double &  score,
const bool  auto_compute_max_samples = false 
)
Returns
PRANSAC_OK when a solution could be found, a positive number when a solution could be found whcih did not met the minimum qulaity criteria (i.e. min_num_inliers and maximum score) and a negative number when absolutly no solution could be found

for (int block=0; block<num_blocks; block++){

Definition at line 336 of file PreemptiveRANSAC.hh.

Member Data Documentation

template<class SolutionType>
bool BIAS::PreemptiveRANSAC< SolutionType >::_bGreedy
protected

should termination be aborted when first good solution is found?

Definition at line 153 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetGreedy().

template<class SolutionType>
bool BIAS::PreemptiveRANSAC< SolutionType >::_bInitialised
protected

just to check if the class is used correctly

Definition at line 163 of file PreemptiveRANSAC.hh.

template<class SolutionType>
bool BIAS::PreemptiveRANSAC< SolutionType >::_bRefineSolutions
protected

should the solutions be refined?

Definition at line 159 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetRefineSolutions().

template<class SolutionType>
std::vector<unsigned> BIAS::PreemptiveRANSAC< SolutionType >::_EvaluationOrder
protected

the order in which data is used for solutions evaluation

Definition at line 186 of file PreemptiveRANSAC.hh.

long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

template<class SolutionType>
RANSACEvaluatorInterface<SolutionType>* BIAS::PreemptiveRANSAC< SolutionType >::_RANSACEvaluator
protected

the helper class for solution computation and sample evaluation

Definition at line 145 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC().

template<class SolutionType>
std::list<SolStruct> BIAS::PreemptiveRANSAC< SolutionType >::_Solutions
protected
std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiDataSize
protected

the number of data for evaluation

Definition at line 151 of file PreemptiveRANSAC.hh.

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiEvaluationBlockSize
protected

after EvaluationBlockSize, bad solutions are removed

Definition at line 161 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetEvaluationBlockSize().

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiMaxSamples
protected
template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiMinNumInitialInliers
protected

the minimum number of inlier from _uiNumInitialChecked

Definition at line 157 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetMinNumInitialInliers().

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiMinSamples
protected

the minimu and maximum number of samples investigated

Definition at line 149 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetMinSamples().

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiNumInitialChecked
protected

the number of datat points that is initially checked

Definition at line 155 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::SetNumInitialChecked().

template<class SolutionType>
unsigned BIAS::PreemptiveRANSAC< SolutionType >::_uiSampleSize
protected

the number of samples needed by GetSampleSolutions

Definition at line 147 of file PreemptiveRANSAC.hh.

Referenced by BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.

template<class SolutionType>
BIAS::Random BIAS::PreemptiveRANSAC< SolutionType >::randomizer_
protected

randomizer instance used for evaluation order computation

Definition at line 143 of file PreemptiveRANSAC.hh.

template<class SolutionType>
int BIAS::PreemptiveRANSAC< SolutionType >::sample_offset
protected

prevents that calls to GenerateSample_() generate the same random sample if sample solution creation fails!

Definition at line 166 of file PreemptiveRANSAC.hh.


The documentation for this class was generated from the following file: