ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
reconstruction_options.cpp
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 
9 
10 #include <Logging.h>
11 
12 #include "pipelines/option_utils.h"
13 #include "pybind/docstring.h"
14 
15 namespace cloudViewer {
16 namespace reconstruction {
17 namespace options {
18 
19 void pybind_image_reader_options(py::module& m) {
20  // cloudViewer.reconstruction.options.ImageReaderOptions
21  py::class_<colmap::ImageReaderOptions,
22  std::shared_ptr<colmap::ImageReaderOptions>>
23  image_reader_options(m, "ImageReaderOptions",
24  "Image Reader option class.");
25  image_reader_options.def(py::init<>())
26  .def("check", &colmap::ImageReaderOptions::Check,
27  "Check parameters validation.")
28  .def_readwrite(
29  "database_path", &colmap::ImageReaderOptions::database_path,
30  "str: (Default ``''``) Path to database in which to store "
31  "the extracted data.")
32  .def_readwrite(
33  "image_path", &colmap::ImageReaderOptions::image_path,
34  "str: (Default ``''``) Root path to folder which contains "
35  "the images.")
36  .def_readwrite(
37  "mask_path", &colmap::ImageReaderOptions::mask_path,
38  "str: (Default ``''``) Optional root path to folder which "
39  "contains image masks. For a given image, the "
40  "corresponding mask must have the same sub-path below "
41  "this root as the image has below image_path. The filename "
42  "must be equal, "
43  "aside from the added extension .png. For example, for an "
44  "image "
45  "image_path/abc/012.jpg, the mask would be "
46  "mask_path/abc/012.jpg.png. No features "
47  "will be extracted in regions where the mask image is "
48  "black (pixel intensity "
49  "value 0 in grayscale).")
50  .def_readwrite("image_list",
51  &colmap::ImageReaderOptions::image_list,
52  "List(str, ...): Optional list of images to read. "
53  "The list must contain the relative path "
54  "of the images with respect to the image_path.")
55  .def_readwrite(
56  "camera_model", &colmap::ImageReaderOptions::camera_model,
57  "str: (Default ``SIMPLE_RADIAL``) Name of the camera "
58  "model. Supported camera model:"
59  "(``SIMPLE_PINHOLE``, ``PINHOLE``, ``SIMPLE_RADIAL``, "
60  "``RADIAL``, ``OPENCV``, ``OPENCV_FISHEYE``, "
61  "``FULL_OPENCV``, ``FOV``, ``SIMPLE_RADIAL_FISHEYE``, "
62  "``RADIAL_FISHEYE``, ``THIN_PRISM_FISHEYE``, "
63  "``SIMPLE_RADIAL_FISHEYE``)")
64  .def_readwrite(
65  "single_camera", &colmap::ImageReaderOptions::single_camera,
66  "bool: (Default ``False``) Set to ``True`` to enable the "
67  "same camera for all images.")
68  .def_readwrite(
69  "single_camera_per_folder",
70  &colmap::ImageReaderOptions::single_camera_per_folder,
71  "bool: (Default ``False``) Set to ``True`` to enable the "
72  "same camera for all images in the same sub-folder.")
73  .def_readwrite(
74  "single_camera_per_image",
75  &colmap::ImageReaderOptions::single_camera_per_image,
76  "bool: (Default ``False``) Set to ``True`` to enable a "
77  "different camera for each image.")
78  .def_readwrite(
79  "existing_camera_id",
80  &colmap::ImageReaderOptions::existing_camera_id,
81  "int: (Default "
82  "``kInvalidCameraId=std::numeric_limits<camera_t>::max()``)"
83  " Whether to "
84  "explicitly use an existing camera for all images. "
85  "Note that in this case the specified camera model and "
86  "parameters are ignored.")
87  .def_readwrite(
88  "camera_params", &colmap::ImageReaderOptions::camera_params,
89  "str: (Default ``''``) Manual specification of "
90  "camera parameters. If empty, camera parameters will "
91  "be extracted from EXIF, i.e. principal point and focal "
92  "length.")
93  .def_readwrite(
94  "default_focal_length_factor",
95  &colmap::ImageReaderOptions::default_focal_length_factor,
96  "float: (Default ``1.2``) If camera parameters are not "
97  "specified manually and the image does not have focal "
98  "length EXIF information, the focal length is set to "
99  "the value ``default_focal_length_factor * max(width, "
100  "height)``.")
101  .def_readwrite("camera_mask_path",
102  &colmap::ImageReaderOptions::camera_mask_path,
103  "str: (Default ``''``) Optional path to an image "
104  "file specifying a mask for all images. No features "
105  "will be extracted in regions where the mask is "
106  "black (pixel intensity value 0 in grayscale).");
107 }
108 
109 void pybind_sift_extraction_options(py::module& m) {
110  // cloudViewer.reconstruction.options.SiftExtractionOptions
111  py::class_<colmap::SiftExtractionOptions,
112  std::shared_ptr<colmap::SiftExtractionOptions>>
113  sift_extraction_options(m, "SiftExtractionOptions",
114  "Sift Extraction option class.");
115  sift_extraction_options.def(py::init<>())
116  .def("check", &colmap::SiftExtractionOptions::Check,
117  "Check parameters validation.")
118  .def_readwrite("num_threads",
119  &colmap::SiftExtractionOptions::num_threads,
120  "int (Default ``-1``) Number of threads for feature "
121  "extraction.")
122  .def_readwrite("use_gpu", &colmap::SiftExtractionOptions::use_gpu,
123  "bool: (Default ``True``) Whether to use the GPU "
124  "for feature "
125  "extraction.")
126  .def_readwrite(
127  "gpu_index", &colmap::SiftExtractionOptions::gpu_index,
128  "str: (Default ``-1``) Index of the GPU used for feature "
129  "extraction. For multi-GPU extraction, you should separate "
130  "multiple GPU indices by comma, e.g. ``0,1,2,3``.")
131  .def_readwrite(
132  "max_image_size",
133  &colmap::SiftExtractionOptions::max_image_size,
134  "int: (Default ``3200``) Maximum image size, otherwise "
135  "image will be down-scaled.")
136  .def_readwrite(
137  "max_num_features",
138  &colmap::SiftExtractionOptions::max_num_features,
139  "int: (Default ``8192``) Maximum number of features to "
140  "detect, keeping larger-scale features.")
141  .def_readwrite(
142  "first_octave",
143  &colmap::SiftExtractionOptions::first_octave,
144  "int: (Default ``-1``) First octave in the pyramid, i.e. "
145  "-1 upsamples the image by one level.")
146  .def_readwrite("octave_resolution",
147  &colmap::SiftExtractionOptions::octave_resolution,
148  "int: (Default ``3``) Number of levels per octave.")
149  .def_readwrite("peak_threshold",
150  &colmap::SiftExtractionOptions::peak_threshold,
151  "float: (Default ``0.02 / octave_resolution``) Peak "
152  "threshold for detection.")
153  .def_readwrite(
154  "edge_threshold",
155  &colmap::SiftExtractionOptions::edge_threshold,
156  "float: (Default ``10.0``) Edge threshold for detection.")
157  .def_readwrite(
158  "estimate_affine_shape",
159  &colmap::SiftExtractionOptions::estimate_affine_shape,
160  "bool: (Default ``False``) Estimate affine shape of SIFT "
161  "features "
162  "in the form of oriented ellipses as opposed to original "
163  "SIFT "
164  "which estimates oriented disks.")
165  .def_readwrite(
166  "max_num_orientations",
167  &colmap::SiftExtractionOptions::max_num_orientations,
168  "int: (Default ``2``) Maximum number of orientations per "
169  "keypoint if not estimate_affine_shape.")
170  .def_readwrite(
171  "upright", &colmap::SiftExtractionOptions::upright,
172  "bool: (Default ``False``) Fix the orientation to 0 for "
173  "upright features.")
174  .def_readwrite(
175  "darkness_adaptivity",
176  &colmap::SiftExtractionOptions::darkness_adaptivity,
177  "bool: (Default ``False``) Whether to adapt the feature "
178  "detection depending on the image darkness. "
179  "Note that this feature is only available in the "
180  "OpenGL SiftGPU version.")
181  .def_readwrite(
182  "domain_size_pooling",
183  &colmap::SiftExtractionOptions::domain_size_pooling,
184  "bool: (Default ``False``) Domain-size pooling parameters."
185  " Domain-size pooling computes an average SIFT descriptor "
186  "across multiple scales around the "
187  "detected scale. This was proposed in Domain-Size Pooling "
188  "in Local Descriptors "
189  "and Network Architectures, J. Dong and S. Soatto, CVPR "
190  "2015. This "
191  "has been shown to outperform other SIFT variants and "
192  "learned descriptors "
193  "in Comparative Evaluation of Hand-Crafted and Learned "
194  "Local Features, "
195  "Schönberger, Hardmeier, Sattler, Pollefeys, CVPR 2016.")
196  .def_readwrite("dsp_min_scale",
197  &colmap::SiftExtractionOptions::dsp_min_scale,
198  "float: (Default ``1.0 / 6.0``) min scale.")
199  .def_readwrite("dsp_max_scale",
200  &colmap::SiftExtractionOptions::dsp_max_scale,
201  "float: (Default ``3.0``) max scale.")
202  .def_readwrite("dsp_num_scales",
203  &colmap::SiftExtractionOptions::dsp_num_scales,
204  "int: (Default ``10``) The number of scales.")
205  .def_readwrite(
206  "normalization",
207  &colmap::SiftExtractionOptions::normalization,
208  "Normalization: L1-normalizes each descriptor followed by "
209  "element-wise square rooting. This normalization is "
210  "usually "
211  "better than standard L2-normalization. "
212  "See ``Three things everyone should know to improve object "
213  "retrieval``, "
214  "Relja Arandjelovic and Andrew Zisserman, CVPR 2012.");
215 
216  // cloudViewer.reconstruction.options.NormalizationType
217  py::native_enum<colmap::SiftExtractionOptions::Normalization>(
218  sift_extraction_options, "NormalizationType", "enum.Enum",
219  "Enum class for Reconstruction Normalization types.")
220  .value("L1_ROOT",
221  colmap::SiftExtractionOptions::Normalization::L1_ROOT)
223  .export_values()
224  .finalize();
225 }
226 
227 void pybind_sift_matching_options(py::module& m) {
228  // cloudViewer.reconstruction.options.SiftMatchingOptions
229  py::class_<colmap::SiftMatchingOptions> sift_matching_options(
230  m, "SiftMatchingOptions", "Sift Matching option class.");
231  sift_matching_options.def(py::init<>())
232  .def("check", &colmap::SiftMatchingOptions::Check,
233  "Check parameters validation.")
234  .def_readwrite("num_threads",
235  &colmap::SiftMatchingOptions::num_threads,
236  "(Default ``-1``) Number of threads for feature "
237  "extraction.")
238  .def_readwrite(
239  "use_gpu", &colmap::SiftMatchingOptions::use_gpu,
240  "(Default ``True``) Whether to use the GPU for feature "
241  "extraction.")
242  .def_readwrite(
243  "gpu_index", &colmap::SiftMatchingOptions::gpu_index,
244  "(Default ``-1``) Index of the GPU used for feature "
245  "extraction. For multi-GPU extraction, you should separate "
246  "multiple GPU indices by comma, e.g. ``0,1,2,3``.")
247  .def_readwrite("max_ratio", &colmap::SiftMatchingOptions::max_ratio,
248  "float: (Default ``0.8``) Maximum distance ratio "
249  "between first and second best match.")
250  .def_readwrite(
251  "max_distance", &colmap::SiftMatchingOptions::max_distance,
252  "float: (Default ``0.7``) Maximum distance to best match.")
253  .def_readwrite("cross_check",
254  &colmap::SiftMatchingOptions::cross_check,
255  "bool: (Default ``True``) Whether to enable cross "
256  "checking in matching.")
257  .def_readwrite(
258  "max_num_matches",
259  &colmap::SiftMatchingOptions::max_num_matches,
260  "int: (Default ``32768``) Maximum number of matches.")
261  .def_readwrite("max_error", &colmap::SiftMatchingOptions::max_error,
262  "float: (Default ``4.0``) Maximum epipolar error in "
263  "pixels for geometric verification.")
264  .def_readwrite("confidence",
265  &colmap::SiftMatchingOptions::confidence,
266  "float: (Default ``0.999``) Confidence threshold "
267  "for geometric verification.")
268 
269  .def_readwrite("min_num_trials",
270  &colmap::SiftMatchingOptions::min_num_trials,
271  "int: (Default ``100``) Minimum number of RANSAC "
272  "iterations. Note that this option "
273  "overrules the min_inlier_ratio option.")
274  .def_readwrite("max_num_trials",
275  &colmap::SiftMatchingOptions::max_num_trials,
276  "int: (Default ``10000``) Maximum number of RANSAC "
277  "iterations.")
278  .def_readwrite(
279  "min_inlier_ratio",
280  &colmap::SiftMatchingOptions::min_inlier_ratio,
281  "float: (Default ``0.25``) A priori assumed minimum inlier "
282  "ratio, which determines the maximum number of iterations.")
283  .def_readwrite(
284  "min_num_inliers",
285  &colmap::SiftMatchingOptions::min_num_inliers,
286  "int: (Default ``15``) Minimum number of inliers for an "
287  "image pair to be considered as geometrically verified.")
288  .def_readwrite("multiple_models",
289  &colmap::SiftMatchingOptions::multiple_models,
290  "bool: (Default ``False``) Whether to attempt to "
291  "estimate multiple geometric models per image pair.")
292  .def_readwrite(
293  "guided_matching",
294  &colmap::SiftMatchingOptions::guided_matching,
295  "bool: (Default ``False``) Whether to perform guided "
296  "matching, if geometric verification succeeds.");
297 }
298 
300  // cloudViewer.reconstruction.options.ExhaustiveMatchingOptions
301  py::class_<colmap::ExhaustiveMatchingOptions> exhaustive_matching_options(
302  m, "ExhaustiveMatchingOptions",
303  "Exhaustive Matching option class.");
304  exhaustive_matching_options.def(py::init<>())
305  .def("check", &colmap::ExhaustiveMatchingOptions::Check,
306  "Check parameters validation.")
307  .def_readwrite("block_size",
308  &colmap::ExhaustiveMatchingOptions::block_size,
309  "int: (Default ``50``) Block size, i.e. number of "
310  "images to simultaneously load into memory.");
311 }
312 
314  // cloudViewer.reconstruction.options.SequentialMatchingOptions
315  py::class_<colmap::SequentialMatchingOptions> sequential_matching_options(
316  m, "SequentialMatchingOptions",
317  "Sequential Matching option class.");
318  sequential_matching_options.def(py::init<>())
319  .def("check", &colmap::SequentialMatchingOptions::Check,
320  "Check parameters validation.")
321  .def_readwrite(
322  "overlap", &colmap::SequentialMatchingOptions::overlap,
323  "int: (Default ``10``) Number of overlapping image pairs.")
324  .def_readwrite(
325  "quadratic_overlap",
326  &colmap::SequentialMatchingOptions::quadratic_overlap,
327  "bool: (Default ``True``) Whether to match images against "
328  "their quadratic neighbors.")
329  .def_readwrite("loop_detection",
330  &colmap::SequentialMatchingOptions::loop_detection,
331  "bool: (Default ``False``) Whether to enable "
332  "vocabulary tree based loop detection.")
333  .def_readwrite(
334  "loop_detection_period",
335  &colmap::SequentialMatchingOptions::loop_detection_period,
336  "int: (Default ``10``) Loop detection is invoked every "
337  "`loop_detection_period` images.")
338  .def_readwrite("loop_detection_num_images",
339  &colmap::SequentialMatchingOptions::
340  loop_detection_num_images,
341  "int: (Default ``50``) The number of images to "
342  "retrieve in loop detection. "
343  "This number should be significantly bigger than "
344  "the sequential matching overlap.")
345  .def_readwrite("loop_detection_num_nearest_neighbors",
346  &colmap::SequentialMatchingOptions::
347  loop_detection_num_nearest_neighbors,
348  "int: (Default ``1``) Number of nearest neighbors "
349  "to retrieve per query feature.")
350  .def_readwrite("loop_detection_num_checks",
351  &colmap::SequentialMatchingOptions::
352  loop_detection_num_checks,
353  "int: (Default ``256``) Number of nearest-neighbor "
354  "checks to use in retrieval.")
355  .def_readwrite("loop_detection_num_images_after_verification",
356  &colmap::SequentialMatchingOptions::
357  loop_detection_num_images_after_verification,
358  "int: (Default ``0``) How many images to return "
359  "after spatial verification. "
360  "Set to 0 to turn off spatial verification.")
361  .def_readwrite("loop_detection_max_num_features",
362  &colmap::SequentialMatchingOptions::
363  loop_detection_max_num_features,
364  "int: (Default ``-1``) The maximum number of "
365  "features to use for indexing an image. "
366  "If an image has more features, only the "
367  "largest-scale features will be indexed.")
368  .def_readwrite("vocab_tree_path",
369  &colmap::SequentialMatchingOptions::vocab_tree_path,
370  "str: (Default ``"
371  "``) Path to the vocabulary tree.");
372 }
373 
375  // cloudViewer.reconstruction.options.VocabTreeMatchingOptions
376  py::class_<colmap::VocabTreeMatchingOptions> vocabtree_matching_options(
377  m, "VocabTreeMatchingOptions", "VocabTree Matching option class.");
378  vocabtree_matching_options.def(py::init<>())
379  .def("check", &colmap::VocabTreeMatchingOptions::Check,
380  "Check parameters validation.")
381  .def_readwrite("num_images",
382  &colmap::VocabTreeMatchingOptions::num_images,
383  "int: (Default ``100``) Number of images to "
384  "retrieve for each query image.")
385  .def_readwrite(
386  "num_nearest_neighbors",
387  &colmap::VocabTreeMatchingOptions::num_nearest_neighbors,
388  "int: (Default ``5``) Number of nearest neighbors to "
389  "retrieve per query feature.")
390  .def_readwrite("num_checks",
391  &colmap::VocabTreeMatchingOptions::num_checks,
392  "int: (Default ``256``) Number of nearest-neighbor "
393  "checks to use in retrieval.")
394  .def_readwrite("num_images_after_verification",
395  &colmap::VocabTreeMatchingOptions::
396  num_images_after_verification,
397  "int: (Default ``0``) How many images to return "
398  "after spatial verification. Set to 0 to turn off "
399  "spatial verification.")
400  .def_readwrite(
401  "max_num_features",
402  &colmap::VocabTreeMatchingOptions::max_num_features,
403  "int: (Default ``-1``) The maximum number of features to "
404  "use for indexing an image. If an image has more features, "
405  "only the largest-scale features will be indexed.")
406  .def_readwrite("vocab_tree_path",
407  &colmap::VocabTreeMatchingOptions::vocab_tree_path,
408  "str: (Default ``''``) Path to the vocabulary tree.")
409  .def_readwrite("match_list_path",
410  &colmap::VocabTreeMatchingOptions::match_list_path,
411  "str: (Default ``''``) Optional path to file with "
412  "specific image "
413  "names to match.");
414 }
415 
416 void pybind_spatial_matching_options(py::module& m) {
417  // cloudViewer.reconstruction.options.SpatialMatchingOptions
418  py::class_<colmap::SpatialMatchingOptions> spatial_matching_options(
419  m, "SpatialMatchingOptions", "Spatial Matching option class.");
420  spatial_matching_options.def(py::init<>())
421  .def("check", &colmap::SpatialMatchingOptions::Check,
422  "Check parameters validation.")
423  .def_readwrite(
424  "is_gps", &colmap::SpatialMatchingOptions::is_gps,
425  "bool: (Default ``True``) Whether the location priors in "
426  "the database are GPS coordinates in the form of longitude "
427  "and latitude coordinates in degrees.")
428  .def_readwrite("ignore_z",
429  &colmap::SpatialMatchingOptions::ignore_z,
430  "bool: (Default ``True``) Whether to ignore the "
431  "Z-component of the location prior.")
432  .def_readwrite("max_num_neighbors",
433  &colmap::SpatialMatchingOptions::max_num_neighbors,
434  "int: (Default ``50``) The maximum number of "
435  "nearest neighbors to match.")
436  .def_readwrite(
437  "max_distance",
438  &colmap::SpatialMatchingOptions::max_distance,
439  "int: (Default ``100``) The maximum distance between the "
440  "query and nearest neighbor. For GPS coordinates the unit "
441  "is Euclidean distance in meters.");
442 }
443 
445  // cloudViewer.reconstruction.options.TransitiveMatchingOptions
446  py::class_<colmap::TransitiveMatchingOptions> transitive_matching_options(
447  m, "TransitiveMatchingOptions",
448  "Transitive Matching option class.");
449  transitive_matching_options.def(py::init<>())
450  .def("check", &colmap::TransitiveMatchingOptions::Check,
451  "Check parameters validation.")
452  .def_readwrite("batch_size",
453  &colmap::TransitiveMatchingOptions::batch_size,
454  "int: (Default ``1000``) The maximum number of "
455  "image pairs to process in one batch.")
456  .def_readwrite("num_iterations",
457  &colmap::TransitiveMatchingOptions::num_iterations,
458  "int: (Default ``3``) The number of transitive "
459  "closure iterations.");
460 }
461 
463  // cloudViewer.reconstruction.options.ImagePairsMatchingOptions
464  py::class_<colmap::ImagePairsMatchingOptions> imagepairs_matching_options(
465  m, "ImagePairsMatchingOptions",
466  "ImagePairs Matching option class.");
467  imagepairs_matching_options.def(py::init<>())
468  .def("check", &colmap::ImagePairsMatchingOptions::Check,
469  "Check parameters validation.")
470  .def_readwrite("block_size",
471  &colmap::ImagePairsMatchingOptions::block_size,
472  "int: (Default ``1225``) Number of image pairs to "
473  "match in one batch.")
474  .def_readwrite("match_list_path",
475  &colmap::ImagePairsMatchingOptions::match_list_path,
476  "str: (Default ``''``) Optional path to file with "
477  "specific image names to match.");
478 }
479 
481  // cloudViewer.reconstruction.options.FeaturePairsMatchingOptions
482  py::class_<colmap::FeaturePairsMatchingOptions>
483  featurepairs_matching_options(
484  m, "FeaturePairsMatchingOptions",
485  "FeaturePairs Matching option class.");
486  featurepairs_matching_options.def(py::init<>())
487  .def("check", &colmap::FeaturePairsMatchingOptions::Check,
488  "Check parameters validation.")
489  .def_readwrite("verify_matches",
490  &colmap::FeaturePairsMatchingOptions::verify_matches,
491  "bool: (Default ``True``) Whether to geometrically "
492  "verify the given matches.")
493  .def_readwrite(
494  "match_list_path",
495  &colmap::FeaturePairsMatchingOptions::match_list_path,
496  "str: (Default ``''``) Path to the file with the matches.");
497 }
498 
499 void pybind_bundle_adjustment_options(py::module& m) {
500  // cloudViewer.reconstruction.options.BundleAdjustmentOptions
501  py::class_<colmap::BundleAdjustmentOptions> bundle_adjustment_options(
502  m, "BundleAdjustmentOptions", "Bundle Adjustment option class.");
503  bundle_adjustment_options.def(py::init<>())
504  .def("check", &colmap::BundleAdjustmentOptions::Check,
505  "Check parameters validation.")
506  // .def("create_loss_function",
507  // &colmap::BundleAdjustmentOptions::CreateLossFunction)
508  // .def("create_solver_options",
509  // &colmap::BundleAdjustmentOptions::CreateSolverOptions,
510  // "config"_a, "problem"_a)
511  .def_readwrite(
512  "loss_function_type",
513  &colmap::BundleAdjustmentOptions::loss_function_type,
514  "LossFunctionType: (Default ``LossFunctionType::TRIVIAL``) "
515  "Loss function types: Trivial (non-robust) and Cauchy "
516  "(robust) loss.")
517  .def_readwrite(
518  "loss_function_scale",
519  &colmap::BundleAdjustmentOptions::loss_function_scale,
520  "float: (Default ``1.0``) Scaling factor determines "
521  "residual at which robustification takes place.")
522  .def_readwrite(
523  "refine_focal_length",
524  &colmap::BundleAdjustmentOptions::refine_focal_length,
525  "bool: (Default ``True``) Whether to refine the focal "
526  "length parameter group.")
527  .def_readwrite(
528  "refine_principal_point",
529  &colmap::BundleAdjustmentOptions::refine_principal_point,
530  "bool: (Default ``False``) Whether to refine the principal "
531  "point parameter group.")
532  .def_readwrite(
533  "refine_extra_params",
534  &colmap::BundleAdjustmentOptions::refine_extra_params,
535  "bool: (Default ``True``) Whether to refine the extra "
536  "parameter group.")
537  .def_readwrite("refine_extrinsics",
538  &colmap::BundleAdjustmentOptions::refine_extrinsics,
539  "bool: (Default ``True``) Whether to refine the "
540  "extrinsic parameter group.")
541  .def_readwrite("print_summary",
542  &colmap::BundleAdjustmentOptions::print_summary,
543  "bool: (Default ``True``) Whether to print a final "
544  "summary.")
545  .def_readwrite("use_gpu", &colmap::BundleAdjustmentOptions::use_gpu,
546  "Whether to use Ceres' CUDA linear algebra library, "
547  "if available.")
548  .def_readwrite("gpu_index",
549  &colmap::BundleAdjustmentOptions::gpu_index,
550  "Which GPU to use for solving the problem.")
551  .def_readwrite(
552  "min_num_residuals_for_cpu_multi_threading",
553  &colmap::BundleAdjustmentOptions::
554  min_num_residuals_for_cpu_multi_threading,
555  "int: (Default ``50000``) Minimum number of residuals to "
556  "enable multi-threading. Note that single-threaded is "
557  "typically better for small bundle adjustment problems due "
558  "to the overhead of threading.")
559  .def_readwrite(
560  "min_num_images_gpu_solver",
561  &colmap::BundleAdjustmentOptions::min_num_images_gpu_solver,
562  "Minimum number of images to use the GPU solver.")
563  .def_readwrite("max_num_images_direct_dense_cpu_solver",
564  &colmap::BundleAdjustmentOptions::
565  max_num_images_direct_dense_cpu_solver,
566  "Threshold to switch between direct, sparse, and "
567  "iterative solvers.")
568  .def_readwrite("max_num_images_direct_sparse_cpu_solver",
569  &colmap::BundleAdjustmentOptions::
570  max_num_images_direct_sparse_cpu_solver,
571  "Threshold to switch between direct, sparse, and "
572  "iterative solvers.")
573  .def_readwrite("max_num_images_direct_dense_gpu_solver",
574  &colmap::BundleAdjustmentOptions::
575  max_num_images_direct_dense_gpu_solver,
576  "Threshold to switch between direct, sparse, and "
577  "iterative solvers.")
578  .def_readwrite("max_num_images_direct_sparse_gpu_solver",
579  &colmap::BundleAdjustmentOptions::
580  max_num_images_direct_sparse_gpu_solver,
581  "Threshold to switch between direct, sparse, and "
582  "iterative solvers.");
583 
584  // cloudViewer.reconstruction.options.LossFunctionType
585  py::native_enum<colmap::BundleAdjustmentOptions::LossFunctionType>(
586  bundle_adjustment_options, "LossFunctionType", "enum.Enum",
587  "Enum class for Reconstruction LossFunction types.")
588  .value("TRIVIAL",
589  colmap::BundleAdjustmentOptions::LossFunctionType::TRIVIAL)
590  .value("SOFT_L1",
591  colmap::BundleAdjustmentOptions::LossFunctionType::SOFT_L1)
592  .value("CAUCHY",
593  colmap::BundleAdjustmentOptions::LossFunctionType::CAUCHY)
594  .export_values()
595  .finalize();
596 }
597 
599  // cloudViewer.reconstruction.options.IncrementalTriangulatorOptions
600  py::class_<colmap::IncrementalTriangulator::Options>
601  incremental_triangulator_options(
602  m, "IncrementalTriangulatorOptions",
603  "Incremental Triangulator option class.");
604  incremental_triangulator_options.def(py::init<>())
605  .def("check", &colmap::IncrementalTriangulator::Options::Check,
606  "Check parameters validation.")
607  .def_readwrite(
608  "max_transitivity",
609  &colmap::IncrementalTriangulator::Options::max_transitivity,
610  "int: (Default ``1``) Maximum transitivity to search for "
611  "correspondences.")
612  .def_readwrite("create_max_angle_error",
613  &colmap::IncrementalTriangulator::Options::
614  create_max_angle_error,
615  "float: (Default ``2.0``) Maximum angular error to "
616  "create new triangulations.")
617  .def_readwrite("continue_max_angle_error",
618  &colmap::IncrementalTriangulator::Options::
619  continue_max_angle_error,
620  "float: (Default ``2.0``) Maximum angular error to "
621  "continue existing triangulations.")
622  .def_readwrite("merge_max_reproj_error",
623  &colmap::IncrementalTriangulator::Options::
624  merge_max_reproj_error,
625  "float: (Default ``4.0``) Maximum reprojection "
626  "error in pixels to merge triangulations.")
627  .def_readwrite("complete_max_reproj_error",
628  &colmap::IncrementalTriangulator::Options::
629  complete_max_reproj_error,
630  "float: (Default ``4.0``) Maximum reprojection "
631  "error to complete an existing triangulation.")
632  .def_readwrite("complete_max_transitivity",
633  &colmap::IncrementalTriangulator::Options::
634  complete_max_transitivity,
635  "int: (Default ``5``) Maximum transitivity for "
636  "track completion.")
637  .def_readwrite("re_max_angle_error",
638  &colmap::IncrementalTriangulator::Options::
639  re_max_angle_error,
640  "float: (Default ``5.0``) Maximum angular error to "
641  "re-triangulate under-reconstructed image pairs.")
642  .def_readwrite(
643  "re_min_ratio",
644  &colmap::IncrementalTriangulator::Options::re_min_ratio,
645  "float: (Default ``0.2``) Minimum ratio of common "
646  "triangulations between an image pair over the number of "
647  "correspondences between that image pair to be considered "
648  "as under-reconstructed.")
649  .def_readwrite(
650  "re_max_trials",
651  &colmap::IncrementalTriangulator::Options::re_max_trials,
652  "int: (Default ``1``) Maximum number of trials to "
653  "re-triangulate an image pair.")
654  .def_readwrite("min_angle",
655  &colmap::IncrementalTriangulator::Options::min_angle,
656  "float: (Default ``1.5``) Minimum pairwise "
657  "triangulation angle for a stable triangulation.")
658  .def_readwrite("ignore_two_view_tracks",
659  &colmap::IncrementalTriangulator::Options::
660  ignore_two_view_tracks,
661  "bool: (Default ``True``) Whether to ignore "
662  "two-view tracks.")
663  .def_readwrite("min_focal_length_ratio",
664  &colmap::IncrementalTriangulator::Options::
665  min_focal_length_ratio,
666  "float: (Default ``0.1``) Thresholds for bogus "
667  "camera parameters. Images with bogus camera "
668  "parameters are ignored in triangulation.")
669  .def_readwrite("max_focal_length_ratio",
670  &colmap::IncrementalTriangulator::Options::
671  max_focal_length_ratio,
672  "float: (Default ``10.0``) Thresholds for bogus "
673  "camera parameters. Images with bogus camera "
674  "parameters are ignored in triangulation.")
675  .def_readwrite(
676  "max_extra_param",
677  &colmap::IncrementalTriangulator::Options::max_extra_param,
678  "float: (Default ``1.0``) Thresholds for bogus camera "
679  "parameters. Images with bogus camera parameters are "
680  "ignored in triangulation.");
681 }
682 
683 #ifdef PBA_ENABLED
684 void pybind_parallel_bundle_adjustment_options(py::module& m) {
685  // cloudViewer.reconstruction.options.ParallelBundleAdjustmentOptions
686  py::class_<colmap::ParallelBundleAdjuster::Options>
687  parallel_bundle_adjustment_options(
688  m, "ParallelBundleAdjustmentOptions",
689  "Parallel Bundle-Adjustment option class.");
690  parallel_bundle_adjustment_options.def(py::init<>())
691  .def("check", &colmap::ParallelBundleAdjuster::Options::Check,
692  "Check parameters validation.")
693  .def_readwrite(
694  "print_summary",
695  &colmap::ParallelBundleAdjuster::Options::print_summary,
696  "bool: (Default ``True``) Whether to print a final "
697  "summary.")
698  .def_readwrite(
699  "max_num_iterations",
700  &colmap::ParallelBundleAdjuster::Options::
701  max_num_iterations,
702  "int: (Default ``50``) Maximum number of iterations.")
703  .def_readwrite("gpu_index",
704  &colmap::ParallelBundleAdjuster::Options::gpu_index,
705  "int: (Default ``-1``) Index of the GPU used for "
706  "bundle adjustment.")
707  .def_readwrite(
708  "num_threads",
709  &colmap::ParallelBundleAdjuster::Options::num_threads,
710  "int: (Default ``-1``) Number of threads for CPU based "
711  "bundle adjustment.")
712  .def_readwrite("min_num_residuals_for_cpu_multi_threading",
713  &colmap::ParallelBundleAdjuster::Options::
714  min_num_residuals_for_cpu_multi_threading,
715  "int: (Default ``50000``) Minimum number of "
716  "residuals to enable multi-threading."
717  " Note that single-threaded is typically better for "
718  "small bundle adjustment problems due to the "
719  "overhead of threading.");
720 }
721 #endif
722 
724  // cloudViewer.reconstruction.options.IncrementalMapperSubOptions
725  py::class_<colmap::IncrementalMapper::Options>
726  incremental_mapper_sub_options(
727  m, "IncrementalMapperSubOptions",
728  "Incremental Mapper sub option class.");
729  incremental_mapper_sub_options.def(py::init<>())
730  .def("check", &colmap::IncrementalMapper::Options::Check,
731  "Check parameters validation.")
732  .def_readwrite(
733  "init_min_num_inliers",
734  &colmap::IncrementalMapper::Options::init_min_num_inliers,
735  "int: (Default ``100``) Minimum number of inliers for "
736  "initial image pair.")
737  .def_readwrite(
738  "init_max_error",
739  &colmap::IncrementalMapper::Options::init_max_error,
740  "float: (Default ``4.0``) Maximum error in pixels for "
741  "two-view geometry estimation for initial image pair.")
742  .def_readwrite("init_max_forward_motion",
743  &colmap::IncrementalMapper::Options::
744  init_max_forward_motion,
745  "float: (Default ``0.95``) Maximum forward motion "
746  "for initial image pair.")
747  .def_readwrite(
748  "init_min_tri_angle",
749  &colmap::IncrementalMapper::Options::init_min_tri_angle,
750  "float: (Default ``16.0``) Minimum triangulation angle for "
751  "initial image pair.")
752  .def_readwrite(
753  "init_max_reg_trials",
754  &colmap::IncrementalMapper::Options::init_max_reg_trials,
755  "int: (Default ``2``) Maximum number of trials to use an "
756  "image for initialization.")
757  .def_readwrite(
758  "abs_pose_max_error",
759  &colmap::IncrementalMapper::Options::abs_pose_max_error,
760  "float: (Default ``12.0``) Maximum reprojection error in "
761  "absolute pose estimation.")
762  .def_readwrite("abs_pose_min_num_inliers",
763  &colmap::IncrementalMapper::Options::
764  abs_pose_min_num_inliers,
765  "int: (Default ``30``) Minimum number of inliers in "
766  "absolute pose estimation.")
767  .def_readwrite("abs_pose_min_inlier_ratio",
768  &colmap::IncrementalMapper::Options::
769  abs_pose_min_inlier_ratio,
770  "float: (Default ``0.25``) Minimum inlier ratio in "
771  "absolute pose estimation.")
772  .def_readwrite("abs_pose_refine_focal_length",
773  &colmap::IncrementalMapper::Options::
774  abs_pose_refine_focal_length,
775  "bool: (Default ``True``) Whether to estimate the "
776  "focal length in absolute pose estimation.")
777  .def_readwrite("abs_pose_refine_extra_params",
778  &colmap::IncrementalMapper::Options::
779  abs_pose_refine_extra_params,
780  "bool: (Default ``True``) Whether to estimate the "
781  "extra parameters in absolute pose estimation.")
782  .def_readwrite(
783  "local_ba_num_images",
784  &colmap::IncrementalMapper::Options::local_ba_num_images,
785  "int: (Default ``6``) Number of images to optimize in "
786  "local bundle adjustment.")
787  .def_readwrite(
788  "local_ba_min_tri_angle",
789  &colmap::IncrementalMapper::Options::local_ba_min_tri_angle,
790  "float: (Default ``6.0``) Minimum triangulation for images "
791  "to be chosen in local bundle adjustment.")
792  .def_readwrite(
793  "min_focal_length_ratio",
794  &colmap::IncrementalMapper::Options::min_focal_length_ratio,
795  "float: (Default ``0.1``) Opening angle of ~130deg. "
796  "Thresholds for bogus camera parameters. "
797  "Images with bogus camera parameters are filtered and "
798  "ignored in triangulation.")
799  .def_readwrite(
800  "max_focal_length_ratio",
801  &colmap::IncrementalMapper::Options::max_focal_length_ratio,
802  "float: (Default ``10.0``) Opening angle of ~5deg. "
803  "Thresholds for bogus camera parameters. "
804  "Images with bogus camera parameters are filtered and "
805  "ignored in triangulation.")
806  .def_readwrite("max_extra_param",
807  &colmap::IncrementalMapper::Options::max_extra_param,
808  "float: (Default ``1.0``) Thresholds for bogus "
809  "camera parameters. "
810  "Images with bogus camera parameters are filtered "
811  "and ignored in triangulation.")
812  .def_readwrite("filter_max_reproj_error",
813  &colmap::IncrementalMapper::Options::
814  filter_max_reproj_error,
815  "float: (Default ``4.0``) Maximum reprojection "
816  "error in pixels for observations.")
817  .def_readwrite(
818  "filter_min_tri_angle",
819  &colmap::IncrementalMapper::Options::filter_min_tri_angle,
820  "float: (Default ``1.5``) Minimum triangulation angle in "
821  "degrees for stable 3D points.")
822  .def_readwrite("max_reg_trials",
823  &colmap::IncrementalMapper::Options::max_reg_trials,
824  "int: (Default ``3``) Maximum number of trials to "
825  "register an image.")
826  .def_readwrite(
827  "fix_existing_images",
828  &colmap::IncrementalMapper::Options::fix_existing_images,
829  "bool: (Default ``False``) If reconstruction is provided "
830  "as input, fix the existing image poses.")
831  .def_readwrite("num_threads",
832  &colmap::IncrementalMapper::Options::num_threads,
833  "int: (Default ``-1``) Number of threads.")
834  .def_readwrite(
835  "image_selection_method",
836  &colmap::IncrementalMapper::Options::image_selection_method,
837  "ImageSelectionMethod: (Default "
838  "``ImageSelectionMethod::MIN_UNCERTAINTY``) Method to find "
839  "and select next best image to register.");
840 
841  // cloudViewer.reconstruction.options.ImageSelectionMethod
842  py::native_enum<colmap::IncrementalMapper::Options::ImageSelectionMethod>(
843  incremental_mapper_sub_options, "ImageSelectionMethod", "enum.Enum",
844  "Enum class for Reconstruction ImageSelection Method.")
845  .value("MAX_VISIBLE_POINTS_NUM",
846  colmap::IncrementalMapper::Options::ImageSelectionMethod::
847  MAX_VISIBLE_POINTS_NUM)
848  .value("MAX_VISIBLE_POINTS_RATIO",
849  colmap::IncrementalMapper::Options::ImageSelectionMethod::
850  MAX_VISIBLE_POINTS_RATIO)
851  .value("MIN_UNCERTAINTY",
852  colmap::IncrementalMapper::Options::ImageSelectionMethod::
853  MIN_UNCERTAINTY)
854  .export_values()
855  .finalize();
856 
857  // cloudViewer.reconstruction.options.IncrementalMapperOptions
858  py::class_<colmap::IncrementalMapperOptions> incremental_mapper_options(
859  m, "IncrementalMapperOptions", "Incremental Mapper option class.");
860  incremental_mapper_options.def(py::init<>())
861  .def("check", &colmap::IncrementalMapperOptions::Check,
862  "Check parameters validation.")
863  .def("get_mapper", &colmap::IncrementalMapperOptions::Mapper,
864  "Get Incremental Mapper sub options.")
865  .def("get_incremental_triangulator_options",
866  &colmap::IncrementalMapperOptions::Triangulation,
867  "Get Incremental triangulator options.")
868  .def("get_local_ba_options",
869  &colmap::IncrementalMapperOptions::LocalBundleAdjustment,
870  "Get local BundleAdjustment options.")
871  .def("get_global_ba_options",
872  &colmap::IncrementalMapperOptions::GlobalBundleAdjustment,
873  "Get global BundleAdjustment options.")
874 #ifdef PBA_ENABLED
875  .def("get_parallel_global_ba_options",
877  ParallelGlobalBundleAdjustment,
878  "Get parallel global BundleAdjustment options.")
879 #endif
880  .def_readwrite("min_num_matches",
881  &colmap::IncrementalMapperOptions::min_num_matches,
882  "int: (Default ``15``) The minimum number of "
883  "matches for inlier matches to be considered.")
884  .def_readwrite("ignore_watermarks",
885  &colmap::IncrementalMapperOptions::ignore_watermarks,
886  "bool: (Default ``False``) Whether to ignore the "
887  "inlier matches of watermark image pairs.")
888  .def_readwrite("multiple_models",
889  &colmap::IncrementalMapperOptions::multiple_models,
890  "bool: (Default ``True``) Whether to reconstruct "
891  "multiple sub-models.")
892  .def_readwrite("max_num_models",
893  &colmap::IncrementalMapperOptions::max_num_models,
894  "int: (Default ``50``) The number of sub-models to "
895  "reconstruct.")
896  .def_readwrite(
897  "max_model_overlap",
898  &colmap::IncrementalMapperOptions::max_model_overlap,
899  "int: (Default ``20``) The maximum number of overlapping "
900  "images between sub-models. If the current sub-models "
901  "shares more than this number of images with another "
902  "model, then the reconstruction is stopped.")
903  .def_readwrite("min_model_size",
904  &colmap::IncrementalMapperOptions::min_model_size,
905  "int: (Default ``10``) The minimum number of "
906  "registered images of a sub-model, otherwise the "
907  "sub-model is discarded.")
908  .def_readwrite("init_image_id1",
909  &colmap::IncrementalMapperOptions::init_image_id1,
910  "int: (Default ``-1``) The image identifiers used "
911  "to initialize the reconstruction. "
912  "Note that only one or both image identifiers can "
913  "be specified. In the former case, the second image "
914  "is automatically determined.")
915  .def_readwrite("init_image_id2",
916  &colmap::IncrementalMapperOptions::init_image_id2,
917  "int: (Default ``-1``) The image identifiers used "
918  "to initialize the reconstruction. "
919  "Note that only one or both image identifiers can "
920  "be specified. In the former case, the second image "
921  "is automatically determined.")
922  .def_readwrite("init_num_trials",
923  &colmap::IncrementalMapperOptions::init_num_trials,
924  "int: (Default ``200``) The number of trials to "
925  "initialize the reconstruction.")
926  .def_readwrite("extract_colors",
927  &colmap::IncrementalMapperOptions::extract_colors,
928  "bool: (Default ``True``) Whether to extract colors "
929  "for reconstructed points.")
930  .def_readwrite("num_threads",
931  &colmap::IncrementalMapperOptions::num_threads,
932  "int: (Default ``-1``) The number of threads to use "
933  "during reconstruction.")
934  .def_readwrite(
935  "min_focal_length_ratio",
936  &colmap::IncrementalMapperOptions::min_focal_length_ratio,
937  "float: (Default ``0.1``) Thresholds for filtering images "
938  "with degenerate intrinsics.")
939  .def_readwrite(
940  "max_focal_length_ratio",
941  &colmap::IncrementalMapperOptions::max_focal_length_ratio,
942  "float: (Default ``10.0``) Thresholds for filtering images "
943  "with degenerate intrinsics.")
944  .def_readwrite("max_extra_param",
945  &colmap::IncrementalMapperOptions::max_extra_param,
946  "float: (Default ``1.0``) Thresholds for filtering "
947  "images with degenerate intrinsics.")
948  .def_readwrite(
949  "ba_refine_focal_length",
950  &colmap::IncrementalMapperOptions::ba_refine_focal_length,
951  "bool: (Default ``True``) Which intrinsic parameters to "
952  "optimize during the reconstruction.")
953  .def_readwrite("ba_refine_principal_point",
955  ba_refine_principal_point,
956  "bool: (Default ``False``) Which intrinsic "
957  "parameters to optimize during the reconstruction.")
958  .def_readwrite(
959  "ba_refine_extra_params",
960  &colmap::IncrementalMapperOptions::ba_refine_extra_params,
961  "bool: (Default ``True``) Which intrinsic parameters to "
962  "optimize during the reconstruction.")
963  .def_readwrite("ba_min_num_residuals_for_cpu_multi_threading",
965  ba_min_num_residuals_for_cpu_multi_threading,
966  "int: (Default ``50000``) The minimum number of "
967  "residuals per bundle adjustment problem to enable "
968  "multi-threading solving of the problems.")
969  .def_readwrite(
970  "ba_local_num_images",
971  &colmap::IncrementalMapperOptions::ba_local_num_images,
972  "int: (Default ``6``) The number of images to optimize in "
973  "local bundle adjustment.")
974  .def_readwrite("ba_local_function_tolerance",
976  ba_local_function_tolerance,
977  "float: (Default ``0.0``) Ceres solver function "
978  "tolerance for local bundle adjustment.")
979  .def_readwrite("ba_local_max_num_iterations",
981  ba_local_max_num_iterations,
982  "int: (Default ``25``) The maximum number of local "
983  "bundle adjustment iterations.")
984 #ifdef PBA_ENABLED
985  .def_readwrite("ba_global_use_pba",
986  &colmap::IncrementalMapperOptions::ba_global_use_pba,
987  "bool: (Default ``False``) Whether to use PBA in "
988  "global bundle adjustment.")
989  .def_readwrite(
990  "ba_global_pba_gpu_index",
991  &colmap::IncrementalMapperOptions::ba_global_pba_gpu_index,
992  "int: (Default ``-1``) The GPU index for PBA bundle "
993  "adjustment.")
994 #endif
995  .def_readwrite(
996  "ba_global_images_ratio",
997  &colmap::IncrementalMapperOptions::ba_global_images_ratio,
998  "float: (Default ``1.1``) The growth rates after which to "
999  "perform global bundle adjustment.")
1000  .def_readwrite(
1001  "ba_global_points_ratio",
1002  &colmap::IncrementalMapperOptions::ba_global_points_ratio,
1003  "float: (Default ``1.1``) The growth rates after which to "
1004  "perform global bundle adjustment.")
1005  .def_readwrite(
1006  "ba_global_images_freq",
1007  &colmap::IncrementalMapperOptions::ba_global_images_freq,
1008  "int: (Default ``500``) The growth rates after which to "
1009  "perform global bundle adjustment.")
1010  .def_readwrite(
1011  "ba_global_points_freq",
1012  &colmap::IncrementalMapperOptions::ba_global_points_freq,
1013  "int: (Default ``250000``) The growth rates after which to "
1014  "perform global bundle adjustment.")
1015  .def_readwrite("ba_global_function_tolerance",
1017  ba_global_function_tolerance,
1018  "float: (Default ``0.0``) Ceres solver function "
1019  "tolerance for global bundle adjustment")
1020  .def_readwrite("ba_global_max_num_iterations",
1022  ba_global_max_num_iterations,
1023  "int: (Default ``50``) The maximum number of global "
1024  "bundle adjustment iterations.")
1025  .def_readwrite(
1026  "ba_local_max_refinements",
1027  &colmap::IncrementalMapperOptions::ba_local_max_refinements,
1028  "int: (Default ``2``) The thresholds for iterative bundle "
1029  "adjustment refinements.")
1030  .def_readwrite("ba_local_max_refinement_change",
1032  ba_local_max_refinement_change,
1033  "float: (Default ``0.001``) The thresholds for "
1034  "iterative bundle adjustment refinements.")
1035  .def_readwrite("ba_global_max_refinements",
1037  ba_global_max_refinements,
1038  "int: (Default ``5``) The thresholds for iterative "
1039  "bundle adjustment refinements.")
1040  .def_readwrite("ba_global_max_refinement_change",
1042  ba_global_max_refinement_change,
1043  "float: (Default ``0.0005``) The thresholds for "
1044  "iterative bundle adjustment refinements.")
1045  .def_readwrite("ba_use_gpu",
1046  &colmap::IncrementalMapperOptions::ba_use_gpu,
1047  "Whether to use Ceres' CUDA sparse linear algebra "
1048  "library, if available.")
1049  .def_readwrite("ba_gpu_index",
1050  &colmap::IncrementalMapperOptions::ba_gpu_index,
1051  "Index of CUDA GPU to use for BA, if available.")
1052  .def_readwrite("snapshot_path",
1053  &colmap::IncrementalMapperOptions::snapshot_path,
1054  "str: (Default ``''``) Path to a folder with "
1055  "reconstruction snapshots during incremental "
1056  "reconstruction. Snapshots will be saved according "
1057  "to the specified frequency of registered images.")
1058  .def_readwrite(
1059  "snapshot_images_freq",
1060  &colmap::IncrementalMapperOptions::snapshot_images_freq,
1061  "int: (Default ``0``) The frequency of registered images.")
1062  .def_readwrite("image_names",
1063  &colmap::IncrementalMapperOptions::image_names,
1064  "set(str, ...): Which images to reconstruct. If no "
1065  "images are specified, all images will be "
1066  "reconstructed by default.")
1067  .def_readwrite(
1068  "fix_existing_images",
1069  &colmap::IncrementalMapperOptions::fix_existing_images,
1070  "bool: (Default ``False``) If reconstruction is provided "
1071  "as input, fix the existing image poses.")
1072  .def_readwrite("mapper", &colmap::IncrementalMapperOptions::mapper,
1073  "IncrementalMapperSubOptions: Incremental mapper "
1074  "sub options.")
1075  .def_readwrite("triangulation",
1076  &colmap::IncrementalMapperOptions::triangulation,
1077  "IncrementalTriangulatorOptions: Incremental "
1078  "triangulator options.");
1079 }
1080 
1081 void pybind_patch_match_options(py::module& m) {
1082  // cloudViewer.reconstruction.options.PatchMatchOptions
1083  py::class_<colmap::mvs::PatchMatchOptions> patch_match_options(
1084  m, "PatchMatchOptions", "PatchMatch option class.");
1085  patch_match_options.def(py::init<>())
1086  .def("check", &colmap::mvs::PatchMatchOptions::Check,
1087  "Check parameters validation.")
1088  .def_readwrite("max_image_size",
1089  &colmap::mvs::PatchMatchOptions::max_image_size,
1090  "int: (Default ``-1``) Maximum image size in either "
1091  "dimension.")
1092  .def_readwrite(
1093  "gpu_index", &colmap::mvs::PatchMatchOptions::gpu_index,
1094  "str: (Default ``'-1'``) Index of the GPU used for patch "
1095  "match. For multi-GPU usage, you should separate multiple "
1096  "GPU indices by comma, e.g., ``0,1,2,3``.");
1097 }
1098 
1099 void pybind_stereo_fusion_options(py::module& m) {
1100  // cloudViewer.reconstruction.options.StereoFusionOptions
1101  py::class_<colmap::mvs::StereoFusionOptions> stereo_fusion_options(
1102  m, "StereoFusionOptions", "Stereo fusion option class.");
1103  stereo_fusion_options.def(py::init<>())
1104  .def("check", &colmap::mvs::StereoFusionOptions::Check,
1105  "Check parameters validation.")
1106  .def("print", &colmap::mvs::StereoFusionOptions::Print,
1107  "Print the options to stdout..")
1108  .def_readwrite("mask_path",
1109  &colmap::mvs::StereoFusionOptions::mask_path,
1110  "str: (Default ``''``) Path for PNG masks. Same "
1111  "format expected as ImageReaderOptions.")
1112  .def_readwrite("num_threads",
1113  &colmap::mvs::StereoFusionOptions::num_threads,
1114  "int: (Default ``-1``) The number of threads to use "
1115  "during fusion.")
1116  .def_readwrite("max_image_size",
1117  &colmap::mvs::StereoFusionOptions::max_image_size,
1118  "int: (Default ``-1``) Maximum image size in either "
1119  "dimension.")
1120  .def_readwrite("min_num_pixels",
1121  &colmap::mvs::StereoFusionOptions::min_num_pixels,
1122  "int: (Default ``5``) Minimum number of fused "
1123  "pixels to produce a point.")
1124  .def_readwrite("max_num_pixels",
1125  &colmap::mvs::StereoFusionOptions::max_num_pixels,
1126  "int: (Default ``10000``) Maximum number of pixels "
1127  "to fuse into a single point.")
1128  .def_readwrite(
1129  "max_traversal_depth",
1130  &colmap::mvs::StereoFusionOptions::max_traversal_depth,
1131  "int: (Default ``100``) Maximum depth in consistency graph "
1132  "traversal.")
1133  .def_readwrite("max_reproj_error",
1134  &colmap::mvs::StereoFusionOptions::max_reproj_error,
1135  "float: (Default ``2.0``) Maximum relative "
1136  "difference between measured and projected pixel.")
1137  .def_readwrite("max_depth_error",
1138  &colmap::mvs::StereoFusionOptions::max_depth_error,
1139  "float: (Default ``0.01``) Maximum relative "
1140  "difference between measured and projected depth.")
1141  .def_readwrite(
1142  "max_normal_error",
1143  &colmap::mvs::StereoFusionOptions::max_normal_error,
1144  "float: (Default ``10.0``) Maximum angular difference in "
1145  "degrees of normals of pixels to be fused.")
1146  .def_readwrite("check_num_images",
1147  &colmap::mvs::StereoFusionOptions::check_num_images,
1148  "int: (Default ``50``) Number of overlapping "
1149  "images to transitively check for fusing points.")
1150  .def_readwrite("use_cache",
1151  &colmap::mvs::StereoFusionOptions::use_cache,
1152  "bool: (Default ``False``) Flag indicating whether "
1153  "to use LRU cache or pre-load all data.")
1154  .def_readwrite(
1155  "cache_size", &colmap::mvs::StereoFusionOptions::cache_size,
1156  "float: (Default ``32.0``) Cache size in gigabytes for "
1157  "fusion. The fusion keeps the bitmaps, depth maps, normal "
1158  "maps, and consistency graphs of this number of images in "
1159  "memory. A higher value leads to less disk access and "
1160  "faster fusion, while a lower value leads to reduced "
1161  "memory usage. Note that a single image can consume a lot "
1162  "of memory, if the consistency graph is dense.")
1163  .def_readwrite("bounding_box",
1164  &colmap::mvs::StereoFusionOptions::bounding_box,
1165  "List((), ()): The bounding box size.");
1166 }
1167 
1168 void pybind_poisson_meshing_options(py::module& m) {
1169  // cloudViewer.reconstruction.options.PoissonMeshingOptions
1170  py::class_<colmap::mvs::PoissonMeshingOptions> poisson_meshing_options(
1171  m, "PoissonMeshingOptions", "Poisson meshing option class.");
1172  poisson_meshing_options.def(py::init<>())
1173  .def("check", &colmap::mvs::PoissonMeshingOptions::Check,
1174  "Check parameters validation.")
1175  .def_readwrite("point_weight",
1176  &colmap::mvs::PoissonMeshingOptions::point_weight,
1177  "float: (Default ``1.0``) This floating point value "
1178  "specifies the importance that interpolation of the "
1179  "point samples is given in the formulation of the "
1180  "screened Poisson equation. The results of the "
1181  "original (unscreened) Poisson Reconstruction can "
1182  "be obtained by setting this value to 0.")
1183  .def_readwrite(
1184  "depth", &colmap::mvs::PoissonMeshingOptions::depth,
1185  "int: (Default ``'13'``) This integer is the maximum "
1186  "depth of the tree that will be used for surface "
1187  "reconstruction. Running at depth d corresponds to solving "
1188  "on a voxel grid whose resolution is no larger than 2^d x "
1189  "2^d x 2^d. Note that since the reconstructor adapts the "
1190  "octree to the sampling density, the specified "
1191  "reconstruction depth is only an upper bound.")
1192  .def_readwrite(
1194  "float: (Default ``'32.0'``) If specified, the "
1195  "reconstruction code assumes that the input is equipped "
1196  "with colors and will extrapolate the color values to the "
1197  "vertices of the reconstructed mesh. The floating point "
1198  "value specifies the relative importance of finer color "
1199  "estimates over lower ones.")
1200  .def_readwrite("trim", &colmap::mvs::PoissonMeshingOptions::trim,
1201  "float: (Default ``'10.0'``) This floating point "
1202  "values specifies the value for mesh trimming. The "
1203  "subset of the mesh with signal value less than the "
1204  "trim value is discarded.")
1205  .def_readwrite("num_threads",
1206  &colmap::mvs::PoissonMeshingOptions::num_threads,
1207  "int: (Default ``'-1'``) The number of threads used "
1208  "for the Poisson reconstruction.");
1209 }
1210 
1211 void pybind_delaunay_meshing_options(py::module& m) {
1212  // cloudViewer.reconstruction.options.DelaunayMeshingOptions
1213  py::class_<colmap::mvs::DelaunayMeshingOptions> delaunay_meshing_options(
1214  m, "DelaunayMeshingOptions", "Delaunay meshing option class.");
1215  delaunay_meshing_options.def(py::init<>())
1216  .def("check", &colmap::mvs::DelaunayMeshingOptions::Check,
1217  "Check parameters validation.")
1218  .def_readwrite("max_proj_dist",
1219  &colmap::mvs::DelaunayMeshingOptions::max_proj_dist,
1220  "float: (Default ``20.0``) Unify input points into "
1221  "one cell in the Delaunay triangulation that fall "
1222  "within a reprojected radius of the given pixels.")
1223  .def_readwrite(
1224  "max_depth_dist",
1225  &colmap::mvs::DelaunayMeshingOptions::max_depth_dist,
1226  "float: (Default ``'0.05'``) Maximum relative depth "
1227  "difference between input point and a vertex of an "
1228  "existing cell in the Delaunay triangulation, otherwise a "
1229  "new vertex is created in the triangulation.")
1230  .def_readwrite(
1231  "visibility_sigma",
1232  &colmap::mvs::DelaunayMeshingOptions::visibility_sigma,
1233  "float: (Default ``'3.0'``) The standard deviation of wrt. "
1234  "the number of images seen by each point. Increasing this "
1235  "value decreases the influence of points seen in few "
1236  "images.")
1237  .def_readwrite(
1238  "distance_sigma_factor",
1239  &colmap::mvs::DelaunayMeshingOptions::distance_sigma_factor,
1240  "float: (Default ``'1.0'``) The factor that is applied to "
1241  "the computed distance sigma, which is automatically "
1242  "computed as the 25th percentile of edge lengths. A higher "
1243  "value will increase the smoothness of the surface.")
1244  .def_readwrite("quality_regularization",
1245  &colmap::mvs::DelaunayMeshingOptions::
1246  quality_regularization,
1247  "float: (Default ``'1.0'``) A higher quality "
1248  "regularization leads to a smoother surface.")
1249  .def_readwrite(
1250  "max_side_length_factor",
1251  &colmap::mvs::DelaunayMeshingOptions::
1252  max_side_length_factor,
1253  "float: (Default ``'25.0'``) Filtering thresholds for "
1254  "outlier surface mesh faces. If the longest side of a mesh "
1255  "face (longest out of 3) exceeds the side lengths of all "
1256  "faces at a certain percentile by the given factor, then "
1257  "it is considered an outlier mesh face and discarded.")
1258  .def_readwrite(
1259  "max_side_length_percentile",
1260  &colmap::mvs::DelaunayMeshingOptions::
1261  max_side_length_percentile,
1262  "float: (Default ``'95.0'``) Filtering thresholds for "
1263  "outlier surface mesh faces. If the longest side of a mesh "
1264  "face (longest out of 3) exceeds the side lengths of all "
1265  "faces at a certain percentile by the given factor, then "
1266  "it is considered an outlier mesh face and discarded.")
1267  .def_readwrite("num_threads",
1268  &colmap::mvs::DelaunayMeshingOptions::num_threads,
1269  "int: (Default ``'-1'``) The number of threads to "
1270  "use for reconstruction. Default is all threads.");
1271 }
1272 
1273 void pybind_reconstruction_options(py::module& m) {
1274  py::module m_submodule =
1275  m.def_submodule("options", "Reconstruction options");
1276  pybind_image_reader_options(m_submodule);
1277  pybind_sift_extraction_options(m_submodule);
1278  pybind_sift_matching_options(m_submodule);
1281  pybind_vocabtree_matching_options(m_submodule);
1282  pybind_spatial_matching_options(m_submodule);
1286  pybind_bundle_adjustment_options(m_submodule);
1288 #ifdef PBA_ENABLED
1289  pybind_parallel_bundle_adjustment_options(m_submodule);
1290 #endif
1291  pybind_incremental_mapper_options(m_submodule);
1292  pybind_patch_match_options(m_submodule);
1293  pybind_stereo_fusion_options(m_submodule);
1294  pybind_poisson_meshing_options(m_submodule);
1295  pybind_delaunay_meshing_options(m_submodule);
1296 }
1297 
1298 } // namespace options
1299 } // namespace reconstruction
1300 } // namespace cloudViewer
math::float4 color
@ L2
Definition: Common.h:27
Generic file read and write utility for python interface.
colmap::IncrementalMapperOptions IncrementalMapperOptions