dlr::computerVision::RansacProblem< Sample, Model > Class Template Reference

This class template implements the "Problem" interface required by the Ransac class, above. More...

#include <ransac.h>

Inheritance diagram for dlr::computerVision::RansacProblem< Sample, Model >:
[legend]
Collaboration diagram for dlr::computerVision::RansacProblem< Sample, Model >:
[legend]

List of all members.

Public Types

typedef Model ModelType
 This typedef simply mirrors the "Model" template argument described in the documentation for this class.
typedef Sample SampleType
 This typedef simply mirrors the "Sample" template argument described in the documentation for this class.
typedef RandomSampleSelector
< SampleType >
::SampleSequenceType 
SampleSequenceType
 This typedef specifies what type will be used to represent sequences of SampleType.

Public Member Functions

virtual ModelType estimateModel (SampleSequenceType const &sampleSequence)=0
 This member function should take a sequence of samples, and compute the best fit model based on the sample values.
template<class IterType >
void computeError (ModelType const &model, SampleSequenceType const &sampleSequence, IterType ouputIter)
 This function should take a model and a sequence of samples, and fill in the output sequence with error values reflecting how well each member of the sample sequence matches the model.
virtual double getNaiveErrorThreshold ()=0
 This member function should return a threshold against which error values (computed by this->computeError()) should be compared in order to determine whether a particular sample is an inlier or an outlier.
template<class IterType >
 RansacProblem (size_t sampleSize, IterType beginIter, IterType endIter)
 This constructor instantiate the RansacProblem instance using a sequence of samples from which to randomly draw populations and compute models.
virtual ~RansacProblem ()
 The destructor cleans up any system resources and destroys *this.
virtual size_t getSampleSize ()
 This member function returns how many individual samples are required by member function estimateModel() to compute a model, and is used by the Ransac class to control the length of the sample sequence passed to estimateModel().
RansacInlierStrategy getInlierStrategy ()
 This member function controls how the inlier/outlier decision is made during RANSAC operation.
SampleSequenceType getPool ()
 This member function returns a SampleSequenceType instance containing the entire population passed to the constructor.
size_t getPoolSize ()
 This member function returns a the number of samples in the entire population passed to the constructor.
SampleSequenceType getRandomSample (size_t sampleSize)
 This member function returns a SampleSequenceType instance drawn randomly (without replacement) from the sample population.
SampleSequenceType getSubset (IterType beginIter, IterType endIter)
 This member function has very limited usefulness.

Protected Attributes

size_t m_sampleSize


Detailed Description

template<class Sample, class Model>
class dlr::computerVision::RansacProblem< Sample, Model >

This class template implements the "Problem" interface required by the Ransac class, above.

If you derive your Problem class from RansacProblem, you avoid some some of the hassles involved in random sampling, etc. If you like, it's also OK to not derive your Problem class from RansacProblem, in which case you should be sure to provide both the interface shown here, and the RandomSampleSelector interface (RandomSampleSelector is a parent class of RansacProblem).

Template argument Sample specifies what type of sample (2D points, 3D points, etc.) are used to estimate the model. Template argument Model specifies the actual type of a model.

For example, you might set Sample to dlr::numeric::Vector2D (representing 2D points), and Model to std::pair<double, double> (representing the slope and intercept of a line in 2D space). For an example that does exactly this, see the LineFittingProblem class in file test/ransacTest.cpp.

Definition at line 172 of file ransac.h.


Member Typedef Documentation

template<class Sample , class Model >
typedef Model dlr::computerVision::RansacProblem< Sample, Model >::ModelType

This typedef simply mirrors the "Model" template argument described in the documentation for this class.

Definition at line 185 of file ransac.h.

template<class Sample , class Model >
typedef RandomSampleSelector<SampleType>::SampleSequenceType dlr::computerVision::RansacProblem< Sample, Model >::SampleSequenceType

This typedef specifies what type will be used to represent sequences of SampleType.

You can just use the default here, or if you need to implement your own random sample selection, you might use something simple like this:

   typedef std::vector<SampleType> SampleSequenceType;

Or, if you're worried about the cost of copying vectors, you could pass a pair of iterators pointing to a sequence that you know will remain valid until the next call to this->getRandomSample() or this->getSubset(). The default typedef provide below does exactly this:

   typedef std::pair<std::vector<SampleType>::const_iterator,
                     std::vector<SampleType>::const_iterator>
           SampleSequenceType;

Note(xxx): we might want to change this "remain valid" restriction so that RandomSampleSelector is more useful to non-Ransac algorithms.

Reimplemented from dlr::computerVision::RandomSampleSelector< Sample >.

Definition at line 222 of file ransac.h.

template<class Sample , class Model >
typedef Sample dlr::computerVision::RansacProblem< Sample, Model >::SampleType

This typedef simply mirrors the "Sample" template argument described in the documentation for this class.

Reimplemented from dlr::computerVision::RandomSampleSelector< Sample >.

Definition at line 192 of file ransac.h.


Constructor & Destructor Documentation

template<class Sample , class Model >
template<class IterType >
dlr::computerVision::RansacProblem< Sample, Model >::RansacProblem ( size_t  sampleSize,
IterType  beginIter,
IterType  endIter 
) [inline]

This constructor instantiate the RansacProblem instance using a sequence of samples from which to randomly draw populations and compute models.

Parameters:
sampleSize This argument specifies how many individual samples are required by member function estimateModel() to compute a model, and is used to control the length of the sample sequence passed to estimateModel().
beginIter This argument is an iterator pointing to the first element of a sequence of samples against which the RANSAC algorithm will be run.
endIter This argument points, in the normal STL way, one element past the end of the sequence started by argument beginIter.

Definition at line 313 of file ransac.h.

template<class Sample , class Model >
virtual dlr::computerVision::RansacProblem< Sample, Model >::~RansacProblem (  )  [inline, virtual]

The destructor cleans up any system resources and destroys *this.

Definition at line 322 of file ransac.h.


Member Function Documentation

template<class Sample , class Model >
template<class IterType >
void dlr::computerVision::RansacProblem< Sample, Model >::computeError ( ModelType const &  model,
SampleSequenceType const &  sampleSequence,
IterType  ouputIter 
) [inline]

This function should take a model and a sequence of samples, and fill in the output sequence with error values reflecting how well each member of the sample sequence matches the model.

Parameters:
model This argument specifies the model against which to test.
sampleSequence This argument specifies the sequence of samples to be tested.
ouputIter This argument is an iterator pointing to the first element of the sequence of doubles that should be filled with error values. The sequence will have at least this->getPoolSize() valid elements whenever this function is called by Ransac.

Definition at line 266 of file ransac.h.

template<class Sample , class Model >
virtual ModelType dlr::computerVision::RansacProblem< Sample, Model >::estimateModel ( SampleSequenceType const &  sampleSequence  )  [pure virtual]

This member function should take a sequence of samples, and compute the best fit model based on the sample values.

The number of sample values contained in argument sampleSequence will be equal to the value of constructor argument sampleSize.

Parameters:
sampleSequence This argument specifies the sequence of samples. See the documentation for typedef SampleSequenceType, above.
Returns:
The return value is a model instance based on the input data.

template<class Sample , class Model >
RansacInlierStrategy dlr::computerVision::RansacProblem< Sample, Model >::getInlierStrategy (  )  [inline]

This member function controls how the inlier/outlier decision is made during RANSAC operation.

For now, the only thing you can return is Ransac::DLR_CV_NAIVE_ERROR_THRESHOLD.

Returns:
The return value

Definition at line 346 of file ransac.h.

template<class Sample , class Model >
virtual double dlr::computerVision::RansacProblem< Sample, Model >::getNaiveErrorThreshold (  )  [pure virtual]

This member function should return a threshold against which error values (computed by this->computeError()) should be compared in order to determine whether a particular sample is an inlier or an outlier.

Sophisticated RANSAC implementations sometimes compute thresholds for the inlier/outlier decision based on the sensitivity of the model estimation algorithm to noise, but we haven't implemented this. For now, your only real option is to return a single threshold that will be applied to each sample error value. Samples with error larger than this threshold will be considered to be outliers.

Returns:
The return value is the inlier/outlier threshold.

SampleSequenceType dlr::computerVision::RandomSampleSelector< Sample >::getPool (  )  [inline, inherited]

This member function returns a SampleSequenceType instance containing the entire population passed to the constructor.

This sequence will remain valid at least until the next call to getRandomSample() or getSubset().

Returns:
The return value is a sequence containing the entire population.

Definition at line 83 of file randomSampleSelector.h.

size_t dlr::computerVision::RandomSampleSelector< Sample >::getPoolSize (  )  [inline, inherited]

This member function returns a the number of samples in the entire population passed to the constructor.

Returns:
The return value is the size of the entire population.

Definition at line 96 of file randomSampleSelector.h.

SampleSequenceType dlr::computerVision::RandomSampleSelector< Sample >::getRandomSample ( size_t  sampleSize  )  [inherited]

This member function returns a SampleSequenceType instance drawn randomly (without replacement) from the sample population.

This sequence will remain valid at least until the next call to getRandomSample() or getSubset().

Parameters:
sampleSize This argument specifies how many elements should be in the returned sequence.
Returns:
The return value is a sequence containing the the requested number of randomly selected samples.

template<class Sample , class Model >
virtual size_t dlr::computerVision::RansacProblem< Sample, Model >::getSampleSize (  )  [inline, virtual]

This member function returns how many individual samples are required by member function estimateModel() to compute a model, and is used by the Ransac class to control the length of the sample sequence passed to estimateModel().

Returns:
The return value specifies the required length of the sample sequence.

Definition at line 335 of file ransac.h.

SampleSequenceType dlr::computerVision::RandomSampleSelector< Sample >::getSubset ( IterType  beginIter,
IterType  endIter 
) [inline, inherited]

This member function has very limited usefulness.

Following a call to getPool(), you can compute a sequence of bools (or values that will implicitly cast to bools) indicating which samples you like, pass this sequence to getSubset(), and get back a SampleSequenceType instance containing just the samples you requested. In the current implementation, the (internal) ordering of the sample population changes with each call to getRandomSample() or getSubset(), so if there's been a call to either getRandomSample() or getSubset() more recently than your last call to getPool(), then this function will return unexpected results.

Parameters:
beginIter This argument and the next specify the sequenc of indicators specifying which elements should be in the output sequence. Elements for which the indicator is true will be included in the sequence, while elements for which the indicator is false will not.
endIter This argument and the next specify the sequenc of indicators specifying which elements should be in the output sequence.
Returns:
The return value is a sequence containing the requested samples.


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

Generated on Wed Nov 25 12:15:09 2009 for dlrComputerVision Utility Library by  doxygen 1.5.8