#include <ransac.h>
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 |
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.
| typedef Model dlr::computerVision::RansacProblem< Sample, Model >::ModelType |
| 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 >.
| 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 >.
| 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.
| 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. |
| virtual dlr::computerVision::RansacProblem< Sample, Model >::~RansacProblem | ( | ) | [inline, virtual] |
| 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.
| 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. |
| 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.
| sampleSequence | This argument specifies the sequence of samples. See the documentation for typedef SampleSequenceType, above. |
| RansacInlierStrategy dlr::computerVision::RansacProblem< Sample, Model >::getInlierStrategy | ( | ) | [inline] |
| 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.
| 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().
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.
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().
| sampleSize | This argument specifies how many elements should be in the returned sequence. |
| 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().
| 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.
| 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. |
1.5.8