21 #ifndef __MeanDoubleRANSACEvaluator_hh__
22 #define __MeanDoubleRANSACEvaluator_hh__
24 #include <MathAlgo/RANSACEvaluatorInterface.hh>
25 #include <Base/Debug/Error.hh>
26 #include <Base/Debug/Exception.hh>
27 #include <Base/Common/CompareFloatingPoint.hh>
48 int Init(
const std::vector<double> &data,
const double &sigma3);
54 inline bool IsInlier(
const double& solution,
const unsigned data_index,
58 std::vector<double> &solutions);
81 Init(
const std::vector<double> &data,
const double &sigma3)
87 BEXCEPTION(
"MeanDoubleRANSACEvaluator::MeanDoubleRANSACEvaluator(): No measurements");
91 BEXCEPTION(
"MeanDoubleRANSACEvaluator::MeanDoubleRANSACEvaluator(): Not enough "
96 BEXCEPTION(
"MeanDoubleRANSACEvaluator::MeanDoubleRANSACEvaluator(): Sigma3 must be "
97 <<
"greater or equal to zero.");
109 IsInlier(
const double &solution,
const unsigned data_index,
double &score)
112 BEXCEPTION(
"MeanDoubleRANSACEvaluator::IsInlier(): Not initialized\n");
114 BIASASSERT(data_index<
Data_.size());
116 double dist = fabs(solution -
Data_[data_index]);
117 const double eps = 1e-13;
118 if (
Equal(dist, 0.0, eps)) {
122 if (isnan(score) || isinf(score)){
123 BEXCEPTION(
"MeanDoubleRANSACEvaluator::IsInlier_(): Cannot compute score, "
124 <<
"maybe expected sigma ("<<
Sigma3_<<
") is invalid? dist = "
125 <<dist<<
"\t"<<solution<<
"\t"<<
Data_[data_index]);
127 bool is_inlier = (dist <
Sigma3_);
134 std::vector<double> &solutions)
137 BEXCEPTION(
"MeanDoubleRANSACEvaluator::IsInlier(): Not initialized\n");
140 if (which_samples.size()>1 && which_samples[0]==which_samples[1]){
144 BIASASSERT(!which_samples.empty());
146 std::vector<unsigned>::const_iterator it;
147 for (it = which_samples.begin(); it!=which_samples.end(); it++){
148 BIASASSERT(*it<
Data_.size());
151 double mean = sum / (double)(which_samples.size());
152 BIASASSERT(!isinf(mean) && !isnan(mean));
156 for (it = which_samples.begin(); it!=which_samples.end(); it++){
163 solutions.push_back(mean);
173 BEXCEPTION(
"MeanDoubleRANSACEvaluator::IsInlier(): Not initialized\n");
177 BIASASSERT(inliers.size()==
Data_.size());
178 for (
unsigned i=0; i<inliers.size(); i++){
184 if (count==0){
return false; }
185 solution = sum / (double)count;
186 BIASASSERT(!isinf(solution) && !isnan(solution));
193 #endif // __MeanDoubleRANSACEvaluator_hh__
Interface for computation of solutions and evaluation of measurements.
helper class for implementation of PreemptievRANSAC and COSAC for robust computation of the mean of a...
virtual ~MeanDoubleRANSACEvaluator()
std::vector< double > Data_
MeanDoubleRANSACEvaluator()
unsigned GetMinNumSamplesForSolutionComputation() const
Returns the minimum required samples for computation of a solution.
int Init(const std::vector< double > &data, const double &sigma3)
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
int GetSampleSolutions(const std::vector< unsigned > &which_samples, std::vector< double > &solutions)
Compute solution(s) for the given set of samples.
bool IsInlier(const double &solution, const unsigned data_index, double &score)
Checks whether a certain sample (i.e.
bool RefineSolution(const std::vector< bool > &inliers, double &solution)
Refine a solution based on the inliers vector.
unsigned GetNumMeasurements() const
Returns the number of available measurements.