43 int* nr_liner,
int* inliers, T* cost, T error_tol),
47 int* inliers, T error_tol,
48 bool re_est_model_w_inliers =
false,
49 bool adaptive_trial_count =
false,
50 double confidence = 0.99,
double inlierprob = 0.5,
51 int min_nr_inliers = s,
52 bool random_shuffle_inputs =
false) {
54 const int kLength = l;
58 T samples_x[kLength * kSize];
59 T samples_xp[kLp * kSize];
61 T cost = std::numeric_limits<T>::max();
62 T best_cost = std::numeric_limits<T>::max();
64 if (n < min_nr_inliers) {
68 double actual_inlierprob = 0.0, tmp_inlierprob;
74 int i, idxl, idxlp, il, ilp;
78 if (random_shuffle_inputs) {
82 while (nr_trials > sample_count) {
86 for (i = 0; i < s; ++i) {
87 idxl = indices[i] * l;
88 idxlp = indices[i] * lp;
91 ICopy(x + idxl, samples_x + il, l);
92 ICopy(xp + idxlp, samples_xp + ilp, lp);
96 HypogenFunc(samples_x, samples_xp, tmp_model);
99 CostFunc(tmp_model, x, xp, n, &nr_inliers, inliers + n, &cost, error_tol);
100 if ((nr_inliers > *consensus_size) ||
101 (nr_inliers == *consensus_size && cost < best_cost)) {
102 *consensus_size = nr_inliers;
104 ICopy(tmp_model, model, k);
105 ICopy(inliers + n, inliers, *consensus_size);
106 if (adaptive_trial_count) {
107 tmp_inlierprob =
IDiv(
static_cast<double>(*consensus_size), n);
108 if (tmp_inlierprob > actual_inlierprob) {
109 actual_inlierprob = tmp_inlierprob;
116 bool succeeded = *consensus_size >= min_nr_inliers;
118 if (succeeded && re_est_model_w_inliers && RefitFunc !=
nullptr) {
119 RefitFunc(x, xp, inliers, model, n, *consensus_size);
bool RobustBinaryFitRansac(T *x, T *xp, int n, T *model, int *consensus_size, int *inliers, T error_tol, bool re_est_model_w_inliers=false, bool adaptive_trial_count=false, double confidence=0.99, double inlierprob=0.5, int min_nr_inliers=s, bool random_shuffle_inputs=false)