ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
incremental_mapper.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 
11 #include "sfm/incremental_mapper.h"
12 #include "util/threading.h"
13 
14 namespace colmap {
15 
17 public:
18  // The minimum number of matches for inlier matches to be considered.
19  int min_num_matches = 15;
20 
21  // Whether to ignore the inlier matches of watermark image pairs.
22  bool ignore_watermarks = false;
23 
24  // Whether to reconstruct multiple sub-models.
25  bool multiple_models = true;
26 
27  // The number of sub-models to reconstruct.
28  int max_num_models = 50;
29 
30  // The maximum number of overlapping images between sub-models. If the
31  // current sub-models shares more than this number of images with another
32  // model, then the reconstruction is stopped.
34 
35  // The minimum number of registered images of a sub-model, otherwise the
36  // sub-model is discarded.
37  int min_model_size = 10;
38 
39  // The image identifiers used to initialize the reconstruction. Note that
40  // only one or both image identifiers can be specified. In the former case,
41  // the second image is automatically determined.
42  int init_image_id1 = -1;
43  int init_image_id2 = -1;
44 
45  // The number of trials to initialize the reconstruction.
46  int init_num_trials = 200;
47 
48  // Whether to extract colors for reconstructed points.
49  bool extract_colors = true;
50 
51  // The number of threads to use during reconstruction.
52  int num_threads = -1;
53 
54  // Thresholds for filtering images with degenerate intrinsics.
55  double min_focal_length_ratio = 0.1;
56  double max_focal_length_ratio = 10.0;
57  double max_extra_param = 1.0;
58 
59  // Which intrinsic parameters to optimize during the reconstruction.
63 
64  // The minimum number of residuals per bundle adjustment problem to
65  // enable multi-threading solving of the problems.
67 
68  // The number of images to optimize in local bundle adjustment.
70 
71  // Ceres solver function tolerance for local bundle adjustment
73 
74  // The maximum number of local bundle adjustment iterations.
76 
77 #ifdef PBA_ENABLED
78  // Whether to use PBA in global bundle adjustment.
79  bool ba_global_use_pba = false;
80 
81  // The GPU index for PBA bundle adjustment.
82  int ba_global_pba_gpu_index = -1;
83 #endif
84  // The growth rates after which to perform global bundle adjustment.
85  double ba_global_images_ratio = 1.1;
86  double ba_global_points_ratio = 1.1;
88  int ba_global_points_freq = 250000;
89 
90  // Ceres solver function tolerance for global bundle adjustment
92 
93  // The maximum number of global bundle adjustment iterations.
95 
96  // The thresholds for iterative bundle adjustment refinements.
101 
102  // Whether to use Ceres' CUDA sparse linear algebra library, if available.
103  bool ba_use_gpu = false;
104  std::string ba_gpu_index = "-1";
105 
106  // Path to a folder with reconstruction snapshots during incremental
107  // reconstruction. Snapshots will be saved according to the specified
108  // frequency of registered images.
109  std::string snapshot_path = "";
111 
112  // Which images to reconstruct. If no images are specified, all images will
113  // be reconstructed by default.
114  std::unordered_set<std::string> image_names;
115 
116  // If reconstruction is provided as input, fix the existing image poses.
117  bool fix_existing_images = false;
118 
121 
126 #ifdef PBA_ENABLED
127  ParallelBundleAdjuster::Options ParallelGlobalBundleAdjustment() const;
128 #endif
129 
130  bool Check() const;
131 };
132 
133 // Class that controls the incremental mapping procedure by iteratively
134 // initializing reconstructions from the same scene graph.
136 public:
137  enum {
141  };
142 
144  const std::string& image_path,
145  const std::string& database_path,
146  ReconstructionManager* reconstruction_manager);
147 
148 private:
149  void Run();
150  bool LoadDatabase();
151  void Reconstruct(const IncrementalMapper::Options& init_mapper_options);
152 
153  const IncrementalMapperOptions* options_;
154  const std::string image_path_;
155  const std::string database_path_;
156  ReconstructionManager* reconstruction_manager_;
157  DatabaseCache database_cache_;
158 };
159 
160 // Globally filter points and images in mapper.
161 size_t FilterPoints(const IncrementalMapperOptions& options,
162  IncrementalMapper* mapper);
163 size_t FilterImages(const IncrementalMapperOptions& options,
164  IncrementalMapper* mapper);
165 
166 // Globally complete and merge tracks in mapper.
168  IncrementalMapper* mapper);
169 
170 } // namespace colmap
IncrementalMapperController(const IncrementalMapperOptions *options, const std::string &image_path, const std::string &database_path, ReconstructionManager *reconstruction_manager)
colmap::IncrementalMapperOptions IncrementalMapperOptions
size_t FilterImages(const IncrementalMapperOptions &options, IncrementalMapper *mapper)
size_t CompleteAndMergeTracks(const IncrementalMapperOptions &options, IncrementalMapper *mapper)
size_t FilterPoints(const IncrementalMapperOptions &options, IncrementalMapper *mapper)
IncrementalTriangulator::Options triangulation
IncrementalTriangulator::Options Triangulation() const
IncrementalMapper::Options mapper
BundleAdjustmentOptions LocalBundleAdjustment() const
IncrementalMapper::Options Mapper() const
BundleAdjustmentOptions GlobalBundleAdjustment() const
std::unordered_set< std::string > image_names