25 #ifndef __ExampleRANSAC_double_hh__
26 #define __ExampleRANSAC_double_hh__
28 #include "MathAlgo/RANSAC.hh"
61 void Init(std::vector<double>& data,
unsigned int sample_size,
62 double inlier_distance_threshold,
bool refine_solution,
63 double expected_inlier_fraction,
64 double solution_error_threshold);
67 std::vector<double> &solutions);
70 bool existing_solution_flag,
71 std::vector<bool>& inlier,
73 double& evaluate_score,
74 bool& ok_to_terminate_flag);
76 virtual bool RefineSolution(std::vector<unsigned int>& which_samples,
78 std::vector<bool>& new_inliers);
101 unsigned int sample_size,
102 double inlier_distance_threshold,
103 bool refine_solution,
104 double expected_inlier_fraction,
105 double solution_error_threshold)
117 std::vector<double> &solutions)
120 for (
unsigned int i = 0; i < which_samples.size(); i++)
121 mean +=
_vData[which_samples[i]];
122 mean /= which_samples.size();
124 solutions.push_back(mean);
125 return solutions.size();
130 bool existing_solution_flag,
131 std::vector<bool>& inlier,
133 double& evaluate_score,
134 bool& ok_to_terminate_flag)
136 bool good_flag =
true;
140 int my_accept_count = 0;
141 evaluate_score = 0.0;
147 evaluate_score += fabs(solution-
_vData[i]);
148 if (existing_solution_flag && my_accept_count > accept_count)
break;
151 if (my_accept_count!=0) {
152 evaluate_score /= my_accept_count;
154 evaluate_score = DBL_MAX;
157 accept_count = my_accept_count;
159 ok_to_terminate_flag =
168 double& solution, std::vector<bool>& new_inliers)
171 for (
unsigned int i = 0; i < which_samples.size(); i++)
172 solution +=
_vData[which_samples[i]];
173 solution /= which_samples.size();
185 #endif // __ExampleRANSAC_double_hh__
virtual bool RefineSolution(std::vector< unsigned int > &which_samples, double &solution, std::vector< bool > &new_inliers)
refine previously computed solution based on its inliers
virtual int GetSampleSolutions(std::vector< unsigned int > &which_samples, std::vector< double > &solutions)
Compute solution(s) for the given set of samples.
double _dInlierDistanceThreshold
double _dExpectedInlierFraction
Robust mean computation for double values using RANSAC.
std::vector< double > _vData
void Init(unsigned int sample_size, unsigned int max_solutions_per_sample=1, bool refine_solution=false, bool greedy=false)
virtual bool EvaluateSolution(const double &solution, bool existing_solution_flag, std::vector< bool > &inlier, int &accept_count, double &evaluate_score, bool &ok_to_terminate_flag)
evaluate the goodness of a solution
double _dSolutionErrorThreshold
void Init(std::vector< double > &data, unsigned int sample_size, double inlier_distance_threshold, bool refine_solution, double expected_inlier_fraction, double solution_error_threshold)
Generic abstract base class for RANSAC (RANdom SAmple Consensus) estimators.
unsigned _uiDataSize
number of data elements needed to compute a solution