ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
progressive_sampler.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 "optim/sampler.h"
11 
12 namespace colmap {
13 
14 // Random sampler for PROSAC (Progressive Sample Consensus), as described in:
15 //
16 // "Matching with PROSAC - Progressive Sample Consensus".
17 // Ondrej Chum and Matas, CVPR 2005.
18 //
19 // Note that a separate sampler should be instantiated per thread and that the
20 // data to be sampled from is assumed to be sorted according to the quality
21 // function in descending order, i.e., higher quality data is closer to the
22 // front of the list.
23 class ProgressiveSampler : public Sampler {
24 public:
25  explicit ProgressiveSampler(const size_t num_samples);
26 
27  void Initialize(const size_t total_num_samples) override;
28 
29  size_t MaxNumSamples() override;
30 
31  std::vector<size_t> Sample() override;
32 
33 private:
34  const size_t num_samples_;
35  size_t total_num_samples_;
36 
37  // The number of generated samples, i.e. the number of calls to `Sample`.
38  size_t t_;
39  size_t n_;
40 
41  // Variables defined in equation 3.
42  double T_n_;
43  double T_n_p_;
44 };
45 
46 } // namespace colmap
void Initialize(const size_t total_num_samples) override
std::vector< size_t > Sample() override
ProgressiveSampler(const size_t num_samples)