ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
sprt.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <cmath>
11 #include <cstddef>
12 #include <vector>
13 
14 namespace colmap {
15 
16 // Sequential Probability Ratio Test as proposed in
17 //
18 // "Randomized RANSAC with Sequential Probability Ratio Test",
19 // Matas et al., 2005
20 class SPRT {
21 public:
22  struct Options {
23  // Probability of rejecting a good model.
24  double delta = 0.01;
25 
26  // A priori assumed minimum inlier ratio
27  double epsilon = 0.1;
28 
29  // The ratio of the time it takes to estimate a model from a random
30  // sample over the time it takes to decide whether one data sample is an
31  // inlier or not. Matas et al. propose 200 for the 7-point algorithm.
32  double eval_time_ratio = 200;
33 
34  // Number of models per random sample, that have to be verified. E.g.
35  // 1-3 for the 7-point fundamental matrix algorithm, or 1-10 for the
36  // 5-point essential matrix algorithm.
38  };
39 
40  explicit SPRT(const Options& options);
41 
42  void Update(const Options& options);
43 
44  bool Evaluate(const std::vector<double>& residuals,
45  const double max_residual,
46  size_t* num_inliers,
47  size_t* num_eval_samples);
48 
49 private:
50  void UpdateDecisionThreshold();
51 
52  Options options_;
53  double delta_epsilon_;
54  double delta_1_epsilon_1_;
55  double decision_threshold_;
56 };
57 
58 } // namespace colmap
bool Evaluate(const std::vector< double > &residuals, const double max_residual, size_t *num_inliers, size_t *num_eval_samples)
Definition: sprt.cc:45
void Update(const Options &options)
Definition: sprt.cc:38
SPRT(const Options &options)
Definition: sprt.cc:36
double eval_time_ratio
Definition: sprt.h:32
int num_models_per_sample
Definition: sprt.h:37
double epsilon
Definition: sprt.h:27