Basic Image AlgorithmS Library
2.8.0
|
Robust fitting of 3D plane to 3D point set using RANSAC. More...
#include <MathAlgo/Examples/ExampleRANSACPlane.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 HomgPlane3D &solution, bool existing_solution_flag, std::vector< bool > &inlier, int &accept_count, double &evaluate_score, bool &ok_to_terminate_flag) |
The solution denoted by solution needs to be ranked. 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< HomgPlane3D > &solutions) |
takes sample and computes solution for this sample. More... | |
void | Init (std::vector< HomgPoint3D > &data, double inlier_distance_threshold, bool refine_solution, double expected_inlier_fraction, double solution_error_threshold) |
Initializes RANSAC. 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... | |
PlaneRANSAC () | |
void | PrintDebugLevel (std::ostream &os=std::cout) const |
virtual bool | RefineSolution (std::vector< unsigned int > &which_samples, HomgPlane3D &solution, std::vector< bool > &new_inliers) |
RefineSolution is only called, if the RefineSolutionFlag is set to true. 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, HomgPlane3D &solution, std::vector< bool > &inliers) |
Main computation function called by user. More... | |
~PlaneRANSAC () | |
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 |
if a sample yields more than _dExpectedInlierFraction inliers and evaluate_score is lower than _dSolutionErrorThreshold, RANSAC will stop More... | |
double | _dInlierDistanceThreshold |
3D points with max distance _dInlierDistanceThreshold to plane are considered as inliers More... | |
double | _dLastBestSampleEvaluateScore |
double | _dProbabilityOfGoodSolution |
prob. for computing number of samples, set close to 1 More... | |
double | _dSolutionErrorThreshold |
if a sample yields more than _dExpectedInlierFraction inliers and evaluate_score is lower than _dSolutionErrorThreshold, RANSAC will stop More... | |
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< HomgPoint3D > | _vData |
input 3D points to fit 3D plane to More... | |
Static Protected Attributes | |
static std::ostream | _zDebugStream |
static long int | GlobalDebugLevel = 0 |
Robust fitting of 3D plane to 3D point set using RANSAC.
This class implements an example for RANSAC class overloading.
Method PlaneRANSAC::GetSampleSolutions picks three 3D points and computes a 3D plane from them.
Method PlaneRANSAC::EvaluateSolution evaluates how many points are considered as "inliers" with respect to the computed plane, i.e. their distance to the plane does not exceed a certain threshold.
In PlaneRANSAC::RefineSolution, a linear least squares computation of the plane is done using all inliers to refine the plane parameters.
You have to set the inlier threshold (max. distance to plane to accept a point as being on the plane) and the fraction of valid 3D points which defines the number of samples performed by RANSAC.
When you call PlaneRANSAC::SolveMaster then, you will get the best plane according to your input.
Definition at line 64 of file ExampleRANSACPlane.hh.
BIAS::PlaneRANSAC::PlaneRANSAC | ( | ) |
Definition at line 139 of file ExampleRANSACPlane.hh.
BIAS::PlaneRANSAC::~PlaneRANSAC | ( | ) |
Definition at line 142 of file ExampleRANSACPlane.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 |
The solution denoted by solution needs to be ranked.
This is done based on the number of inliers found for this solution and based on the accuracy reached on these inliers. So some kind of measurement is needed. Here it is the absolute distance between the homogeneous 3D points and the plane. If such a distance is below the threshold, and inlier has been found. The average distance over all inliers is the evaluate_score. While the number of inliers is entered in accept_count. For more details refer to documentation of this method in RANSAC.hh.
Reimplemented from BIAS::RANSAC< HomgPlane3D >.
Definition at line 174 of file ExampleRANSACPlane.hh.
References _dExpectedInlierFraction, _dInlierDistanceThreshold, _dSolutionErrorThreshold, BIAS::RANSAC< HomgPlane3D >::_uiDataSize, _vData, and BIAS::HomgPlane3D::DistanceSquared().
|
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 |
|
inlinestaticinherited |
|
virtual |
takes sample and computes solution for this sample.
This is usually done in an easy way, e.g. linearly. Sometimes solutions based on a minimum sample size are not unambiguous as for example in case of the 7 point algorithm for essential matrix estimation. In those cases all possible solutions have to be returned in the solutions vector.
Reimplemented from BIAS::RANSAC< HomgPlane3D >.
Definition at line 160 of file ExampleRANSACPlane.hh.
References _vData.
void BIAS::PlaneRANSAC::Init | ( | std::vector< HomgPoint3D > & | data, |
double | inlier_distance_threshold, | ||
bool | refine_solution, | ||
double | expected_inlier_fraction, | ||
double | solution_error_threshold | ||
) |
Initializes RANSAC.
After calling the base RANSAC::Init method, the other parameters are set.
Definition at line 145 of file ExampleRANSACPlane.hh.
References _dExpectedInlierFraction, _dInlierDistanceThreshold, _dSolutionErrorThreshold, BIAS::RANSAC< HomgPlane3D >::_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 |
RefineSolution is only called, if the RefineSolutionFlag is set to true.
In any case, it is only applied to solutions, that have been found to be good, indicated by the return value of EvaluateSolution.
Reimplemented from BIAS::RANSAC< HomgPlane3D >.
Definition at line 218 of file ExampleRANSACPlane.hh.
References _vData, BIAS::SVD::GetNullvector(), BIAS::SVD::Rank(), and BIAS::Matrix< T >::Transpose().
|
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 |
|
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
|
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 |
if a sample yields more than _dExpectedInlierFraction inliers and evaluate_score is lower than _dSolutionErrorThreshold, RANSAC will stop
Definition at line 132 of file ExampleRANSACPlane.hh.
Referenced by EvaluateSolution(), and Init().
|
protected |
3D points with max distance _dInlierDistanceThreshold to plane are considered as inliers
Definition at line 128 of file ExampleRANSACPlane.hh.
Referenced by EvaluateSolution(), and Init().
|
protectedinherited |
|
protectedinherited |
|
protected |
if a sample yields more than _dExpectedInlierFraction inliers and evaluate_score is lower than _dSolutionErrorThreshold, RANSAC will stop
Definition at line 136 of file ExampleRANSACPlane.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(), and Init().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
input 3D points to fit 3D plane to
Definition at line 124 of file ExampleRANSACPlane.hh.
Referenced by EvaluateSolution(), GetSampleSolutions(), Init(), and RefineSolution().
|
staticprotectedinherited |
Definition at line 511 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |