From d7c6144a8f696d8ad509731cae8058229456f400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 18:35:08 +0300 Subject: [PATCH 1/7] Add bugprone-* clang-tidy checks --- .clang-tidy | 7 ++ src/colmap/base/reconstruction.cc | 10 +-- src/colmap/exe/model.cc | 2 +- src/colmap/geometry/similarity_transform.cc | 2 +- src/colmap/image/bitmap.cc | 6 +- src/colmap/mvs/fusion.cc | 2 +- src/colmap/mvs/model.cc | 4 +- src/colmap/optim/bundle_adjustment_test.cc | 86 ++++++++++----------- src/colmap/util/cache.h | 2 +- src/colmap/util/cache_test.cc | 3 +- src/colmap/util/types.h | 2 + 11 files changed, 65 insertions(+), 61 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 59263132a6..8dbd4e1a97 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,13 @@ Checks: > performance-*, concurrency-*, + bugprone-*, + -bugprone-narrowing-conversions, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-unchecked-optional-access, + -bugprone-exception-escape, + -bugprone-reserved-identifier, cppcoreguidelines-virtual-class-destructor, google-explicit-constructor, google-build-using-namespace, diff --git a/src/colmap/base/reconstruction.cc b/src/colmap/base/reconstruction.cc index 9e63f8fd87..5dbc4d11ce 100644 --- a/src/colmap/base/reconstruction.cc +++ b/src/colmap/base/reconstruction.cc @@ -680,12 +680,10 @@ std::vector Reconstruction::FilterImages( std::vector filtered_image_ids; for (const image_t image_id : RegImageIds()) { const class Image& image = Image(image_id); - const class Camera& camera = Camera(image.CameraId()); - if (image.NumPoints3D() == 0) { - filtered_image_ids.push_back(image_id); - } else if (camera.HasBogusParams(min_focal_length_ratio, - max_focal_length_ratio, - max_extra_param)) { + if (image.NumPoints3D() == 0 || Camera(image.CameraId()) + .HasBogusParams(min_focal_length_ratio, + max_focal_length_ratio, + max_extra_param)) { filtered_image_ids.push_back(image_id); } } diff --git a/src/colmap/exe/model.cc b/src/colmap/exe/model.cc index ba9ad1e833..1c2ff06378 100644 --- a/src/colmap/exe/model.cc +++ b/src/colmap/exe/model.cc @@ -564,7 +564,7 @@ int RunModelComparer(int argc, char** argv) { success = ComputeAlignmentBetweenReconstructions( reconstruction1, reconstruction2, - /*max_error=*/max_proj_center_error, + /*max_proj_center_error=*/max_proj_center_error, &alignment); } else { std::cout << "ERROR: Invalid alignment_error specified." << std::endl; diff --git a/src/colmap/geometry/similarity_transform.cc b/src/colmap/geometry/similarity_transform.cc index abb6a5b757..75b060fb97 100644 --- a/src/colmap/geometry/similarity_transform.cc +++ b/src/colmap/geometry/similarity_transform.cc @@ -335,7 +335,7 @@ bool ComputeAlignmentBetweenReconstructions( ransac_options.max_error = max_proj_center_error; if (!aligned_src_reconstruction.AlignRobust(ref_image_names, ref_proj_centers, - /*min_num_images=*/3, + /*min_common_images=*/3, ransac_options, &tform)) { return false; diff --git a/src/colmap/image/bitmap.cc b/src/colmap/image/bitmap.cc index bb930aec09..9a5a2e3ac3 100644 --- a/src/colmap/image/bitmap.cc +++ b/src/colmap/image/bitmap.cc @@ -321,9 +321,8 @@ bool Bitmap::ExifCameraModel(std::string* camera_model) const { *camera_model = ""; return false; } - if (ReadExifTag(FIMD_EXIF_EXIF, "FocalLengthIn35mmFilm", &focal_length)) { - *camera_model += (focal_length + "-"); - } else if (ReadExifTag(FIMD_EXIF_EXIF, "FocalLength", &focal_length)) { + if (ReadExifTag(FIMD_EXIF_EXIF, "FocalLengthIn35mmFilm", &focal_length) || + ReadExifTag(FIMD_EXIF_EXIF, "FocalLength", &focal_length)) { *camera_model += (focal_length + "-"); } else { *camera_model = ""; @@ -668,6 +667,7 @@ float JetColormap::Green(const float gray) { return Base(gray); } float JetColormap::Blue(const float gray) { return Base(gray + 0.25f); } float JetColormap::Base(const float val) { + // NOLINTNEXTLINE(bugprone-branch-clone) if (val <= 0.125f) { return 0.0f; } else if (val <= 0.375f) { diff --git a/src/colmap/mvs/fusion.cc b/src/colmap/mvs/fusion.cc index 77d2a5a18d..7ef226c994 100644 --- a/src/colmap/mvs/fusion.cc +++ b/src/colmap/mvs/fusion.cc @@ -83,7 +83,7 @@ int FindNextImage(const std::vector>& overlapping_images, } // namespace internal void StereoFusionOptions::Print() const { -#define PrintOption(option) std::cout << #option ": " << option << std::endl +#define PrintOption(option) std::cout << #option ": " << (option) << std::endl PrintHeading2("StereoFusion::Options"); PrintOption(mask_path); PrintOption(max_image_size); diff --git a/src/colmap/mvs/model.cc b/src/colmap/mvs/model.cc index 1177f03f79..05dc93fccb 100644 --- a/src/colmap/mvs/model.cc +++ b/src/colmap/mvs/model.cc @@ -99,9 +99,7 @@ void Model::ReadFromCOLMAP(const std::string& path, } void Model::ReadFromPMVS(const std::string& path) { - if (ReadFromBundlerPMVS(path)) { - return; - } else if (ReadFromRawPMVS(path)) { + if (ReadFromBundlerPMVS(path) || ReadFromRawPMVS(path)) { return; } else { LOG(FATAL) << "Invalid PMVS format"; diff --git a/src/colmap/optim/bundle_adjustment_test.cc b/src/colmap/optim/bundle_adjustment_test.cc index 73326b98df..3941b4ced6 100644 --- a/src/colmap/optim/bundle_adjustment_test.cc +++ b/src/colmap/optim/bundle_adjustment_test.cc @@ -38,73 +38,73 @@ #include "colmap/util/random.h" #include "colmap/util/testing.h" -#define CheckVariableCamera(camera, orig_camera) \ - { \ - const size_t focal_length_idx = \ - SimpleRadialCameraModel::focal_length_idxs[0]; \ - const size_t extra_param_idx = \ - SimpleRadialCameraModel::extra_params_idxs[0]; \ - BOOST_CHECK_NE(camera.Params(focal_length_idx), \ - orig_camera.Params(focal_length_idx)); \ - BOOST_CHECK_NE(camera.Params(extra_param_idx), \ - orig_camera.Params(extra_param_idx)); \ +#define CheckVariableCamera(camera, orig_camera) \ + { \ + const size_t focal_length_idx = \ + SimpleRadialCameraModel::focal_length_idxs[0]; \ + const size_t extra_param_idx = \ + SimpleRadialCameraModel::extra_params_idxs[0]; \ + BOOST_CHECK_NE((camera).Params(focal_length_idx), \ + (orig_camera).Params(focal_length_idx)); \ + BOOST_CHECK_NE((camera).Params(extra_param_idx), \ + (orig_camera).Params(extra_param_idx)); \ } -#define CheckConstantCamera(camera, orig_camera) \ - { \ - const size_t focal_length_idx = \ - SimpleRadialCameraModel::focal_length_idxs[0]; \ - const size_t extra_param_idx = \ - SimpleRadialCameraModel::extra_params_idxs[0]; \ - BOOST_CHECK_EQUAL(camera.Params(focal_length_idx), \ - orig_camera.Params(focal_length_idx)); \ - BOOST_CHECK_EQUAL(camera.Params(extra_param_idx), \ - orig_camera.Params(extra_param_idx)); \ +#define CheckConstantCamera(camera, orig_camera) \ + { \ + const size_t focal_length_idx = \ + SimpleRadialCameraModel::focal_length_idxs[0]; \ + const size_t extra_param_idx = \ + SimpleRadialCameraModel::extra_params_idxs[0]; \ + BOOST_CHECK_EQUAL((camera).Params(focal_length_idx), \ + (orig_camera).Params(focal_length_idx)); \ + BOOST_CHECK_EQUAL((camera).Params(extra_param_idx), \ + (orig_camera).Params(extra_param_idx)); \ } -#define CheckVariableImage(image, orig_image) \ - { \ - BOOST_CHECK_NE(image.Qvec(), orig_image.Qvec()); \ - BOOST_CHECK_NE(image.Tvec(), orig_image.Tvec()); \ +#define CheckVariableImage(image, orig_image) \ + { \ + BOOST_CHECK_NE((image).Qvec(), (orig_image).Qvec()); \ + BOOST_CHECK_NE((image).Tvec(), (orig_image).Tvec()); \ } -#define CheckConstantImage(image, orig_image) \ - { \ - BOOST_CHECK_EQUAL(image.Qvec(), orig_image.Qvec()); \ - BOOST_CHECK_EQUAL(image.Tvec(), orig_image.Tvec()); \ +#define CheckConstantImage(image, orig_image) \ + { \ + BOOST_CHECK_EQUAL((image).Qvec(), (orig_image).Qvec()); \ + BOOST_CHECK_EQUAL((image).Tvec(), (orig_image).Tvec()); \ } -#define CheckConstantXImage(image, orig_image) \ - { \ - CheckVariableImage(image, orig_image); \ - BOOST_CHECK_EQUAL(image.Tvec(0), orig_image.Tvec(0)); \ +#define CheckConstantXImage(image, orig_image) \ + { \ + CheckVariableImage(image, orig_image); \ + BOOST_CHECK_EQUAL((image).Tvec(0), (orig_image).Tvec(0)); \ } #define CheckConstantCameraRig(camera_rig, orig_camera_rig, camera_id) \ { \ - BOOST_CHECK_EQUAL(camera_rig.RelativeQvec(camera_id), \ - orig_camera_rig.RelativeQvec(camera_id)); \ - BOOST_CHECK_EQUAL(camera_rig.RelativeTvec(camera_id), \ - orig_camera_rig.RelativeTvec(camera_id)); \ + BOOST_CHECK_EQUAL((camera_rig).RelativeQvec(camera_id), \ + (orig_camera_rig).RelativeQvec(camera_id)); \ + BOOST_CHECK_EQUAL((camera_rig).RelativeTvec(camera_id), \ + (orig_camera_rig).RelativeTvec(camera_id)); \ } #define CheckVariableCameraRig(camera_rig, orig_camera_rig, camera_id) \ { \ - if (camera_rig.RefCameraId() == camera_id) { \ + if ((camera_rig).RefCameraId() == (camera_id)) { \ CheckConstantCameraRig(camera_rig, orig_camera_rig, camera_id); \ } else { \ - BOOST_CHECK_NE(camera_rig.RelativeQvec(camera_id), \ - orig_camera_rig.RelativeQvec(camera_id)); \ - BOOST_CHECK_NE(camera_rig.RelativeTvec(camera_id), \ - orig_camera_rig.RelativeTvec(camera_id)); \ + BOOST_CHECK_NE((camera_rig).RelativeQvec(camera_id), \ + (orig_camera_rig).RelativeQvec(camera_id)); \ + BOOST_CHECK_NE((camera_rig).RelativeTvec(camera_id), \ + (orig_camera_rig).RelativeTvec(camera_id)); \ } \ } #define CheckVariablePoint(point, orig_point) \ - { BOOST_CHECK_NE(point.XYZ(), orig_point.XYZ()); } + { BOOST_CHECK_NE((point).XYZ(), (orig_point).XYZ()); } #define CheckConstantPoint(point, orig_point) \ - { BOOST_CHECK_EQUAL(point.XYZ(), orig_point.XYZ()); } + { BOOST_CHECK_EQUAL((point).XYZ(), (orig_point).XYZ()); } namespace colmap { diff --git a/src/colmap/util/cache.h b/src/colmap/util/cache.h index bfdd896c13..94cc51606a 100644 --- a/src/colmap/util/cache.h +++ b/src/colmap/util/cache.h @@ -218,6 +218,7 @@ size_t MemoryConstrainedLRUCache::MaxNumBytes() const { template void MemoryConstrainedLRUCache::Set(const key_t& key, value_t&& value) { + const size_t num_bytes = value.NumBytes(); auto it = elems_map_.find(key); elems_list_.push_front(key_value_pair_t(key, std::move(value))); if (it != elems_map_.end()) { @@ -226,7 +227,6 @@ void MemoryConstrainedLRUCache::Set(const key_t& key, } elems_map_[key] = elems_list_.begin(); - const size_t num_bytes = value.NumBytes(); num_bytes_ += num_bytes; elems_num_bytes_.emplace(key, num_bytes); diff --git a/src/colmap/util/cache_test.cc b/src/colmap/util/cache_test.cc index 7ad826011e..4b13c0ca5a 100644 --- a/src/colmap/util/cache_test.cc +++ b/src/colmap/util/cache_test.cc @@ -105,8 +105,7 @@ BOOST_AUTO_TEST_CASE(TestLRUCacheSet) { LRUCache cache(5, [](const int key) { return -1; }); BOOST_CHECK_EQUAL(cache.NumElems(), 0); for (int i = 0; i < 5; ++i) { - // NOLINTNEXTLINE(performance-move-const-arg) - cache.Set(i, std::move(i)); + cache.Set(i, int(i)); BOOST_CHECK_EQUAL(cache.NumElems(), i + 1); BOOST_CHECK(cache.Exists(i)); } diff --git a/src/colmap/util/types.h b/src/colmap/util/types.h index 73b728c464..19545a2a47 100644 --- a/src/colmap/util/types.h +++ b/src/colmap/util/types.h @@ -49,9 +49,11 @@ typedef unsigned __int64 uint64_t; #endif // Define non-copyable or non-movable classes. +// NOLINTNEXTLINE(bugprone-macro-parentheses) #define NON_COPYABLE(class_name) \ class_name(class_name const&) = delete; \ void operator=(class_name const& obj) = delete; +// NOLINTNEXTLINE(bugprone-macro-parentheses) #define NON_MOVABLE(class_name) class_name(class_name&&) = delete; #include From 44740190dc1b956a3f0192162cc57198b4d27979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 18:35:32 +0300 Subject: [PATCH 2/7] s --- .clang-tidy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 8dbd4e1a97..85930e8085 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,12 +2,12 @@ Checks: > performance-*, concurrency-*, bugprone-*, - -bugprone-narrowing-conversions, -bugprone-easily-swappable-parameters, - -bugprone-implicit-widening-of-multiplication-result, - -bugprone-unchecked-optional-access, -bugprone-exception-escape, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-narrowing-conversions, -bugprone-reserved-identifier, + -bugprone-unchecked-optional-access, cppcoreguidelines-virtual-class-destructor, google-explicit-constructor, google-build-using-namespace, From 6d82da919372fd53b96740ef36b5d21db536bc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 19:52:53 +0300 Subject: [PATCH 3/7] f --- src/colmap/util/cache.h | 2 +- src/colmap/util/cache_test.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/colmap/util/cache.h b/src/colmap/util/cache.h index 94cc51606a..3cfeaf0a4d 100644 --- a/src/colmap/util/cache.h +++ b/src/colmap/util/cache.h @@ -217,7 +217,7 @@ size_t MemoryConstrainedLRUCache::MaxNumBytes() const { template void MemoryConstrainedLRUCache::Set(const key_t& key, - value_t&& value) { + value_t value) { const size_t num_bytes = value.NumBytes(); auto it = elems_map_.find(key); elems_list_.push_front(key_value_pair_t(key, std::move(value))); diff --git a/src/colmap/util/cache_test.cc b/src/colmap/util/cache_test.cc index 4b13c0ca5a..4e4171b483 100644 --- a/src/colmap/util/cache_test.cc +++ b/src/colmap/util/cache_test.cc @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(TestLRUCacheSet) { LRUCache cache(5, [](const int key) { return -1; }); BOOST_CHECK_EQUAL(cache.NumElems(), 0); for (int i = 0; i < 5; ++i) { - cache.Set(i, int(i)); + cache.Set(i, i); BOOST_CHECK_EQUAL(cache.NumElems(), i + 1); BOOST_CHECK(cache.Exists(i)); } From b54d9df68a4af0e1303acac28bd4eff008782293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 19:58:39 +0300 Subject: [PATCH 4/7] f --- src/colmap/util/cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colmap/util/cache.h b/src/colmap/util/cache.h index 3cfeaf0a4d..473e741cfa 100644 --- a/src/colmap/util/cache.h +++ b/src/colmap/util/cache.h @@ -63,7 +63,7 @@ class LRUCache { // Manually set the value of an element. Note that the ownership of the value // is moved to the cache, which invalidates the object on the caller side. - virtual void Set(const key_t& key, value_t&& value); + virtual void Set(const key_t& key, value_t value); // Pop least recently used element from cache. virtual void Pop(); From 131ce2df5f80425534e9ddada10aa1676d0e2fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 20:02:37 +0300 Subject: [PATCH 5/7] f --- src/colmap/util/cache.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/colmap/util/cache.h b/src/colmap/util/cache.h index 473e741cfa..da42328ff9 100644 --- a/src/colmap/util/cache.h +++ b/src/colmap/util/cache.h @@ -46,7 +46,7 @@ namespace colmap { template class LRUCache { public: - LRUCache(const size_t max_num_elems, + LRUCache(size_t max_num_elems, const std::function& getter_func); virtual ~LRUCache() = default; @@ -96,14 +96,14 @@ template class MemoryConstrainedLRUCache : public LRUCache { public: MemoryConstrainedLRUCache( - const size_t max_num_bytes, + size_t max_num_bytes, const std::function& getter_func); size_t NumBytes() const; size_t MaxNumBytes() const; void UpdateNumBytes(const key_t& key); - void Set(const key_t& key, value_t&& value) override; + void Set(const key_t& key, value_t value) override; void Pop() override; void Clear() override; @@ -166,9 +166,9 @@ value_t& LRUCache::GetMutable(const key_t& key) { } template -void LRUCache::Set(const key_t& key, value_t&& value) { +void LRUCache::Set(const key_t& key, value_t value) { auto it = elems_map_.find(key); - elems_list_.push_front(key_value_pair_t(key, std::move(value))); + elems_list_.emplace_front(key, std::move(value)); if (it != elems_map_.end()) { elems_list_.erase(it->second); elems_map_.erase(it); @@ -220,7 +220,7 @@ void MemoryConstrainedLRUCache::Set(const key_t& key, value_t value) { const size_t num_bytes = value.NumBytes(); auto it = elems_map_.find(key); - elems_list_.push_front(key_value_pair_t(key, std::move(value))); + elems_list_.emplace_front(key, std::move(value)); if (it != elems_map_.end()) { elems_list_.erase(it->second); elems_map_.erase(it); From c47ac45ce04a8b5b5c943a7259b6a81f748024e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 20:42:23 +0300 Subject: [PATCH 6/7] Avoid const params in declaration --- .clang-tidy | 1 + cmake/CMakeHelper.cmake | 10 +- src/colmap/base/camera.h | 50 ++--- src/colmap/base/camera_rig.h | 16 +- src/colmap/base/correspondence_graph.h | 34 ++-- src/colmap/base/database.h | 68 ++++--- src/colmap/base/database_cache.h | 16 +- src/colmap/base/graph_cut.h | 20 +- src/colmap/base/image.h | 43 +++-- src/colmap/base/point2d.h | 2 +- src/colmap/base/point3d.h | 10 +- src/colmap/base/reconstruction.h | 108 +++++------ src/colmap/base/reconstruction_manager.h | 6 +- src/colmap/base/track.h | 16 +- src/colmap/base/visibility_pyramid.h | 13 +- src/colmap/camera/models.h | 172 ++++++++---------- src/colmap/estimators/coordinate_frame.h | 3 +- src/colmap/estimators/triangulation.h | 4 +- src/colmap/estimators/two_view_geometry.h | 2 +- src/colmap/exe/sfm.h | 2 +- src/colmap/feature/extraction.h | 4 +- src/colmap/feature/matching.h | 42 ++--- src/colmap/feature/types.h | 32 ++-- src/colmap/feature/utils.h | 2 +- src/colmap/geometry/essential_matrix.h | 2 +- src/colmap/geometry/gps.h | 22 +-- src/colmap/geometry/homography_matrix.h | 2 +- src/colmap/geometry/pose.h | 6 +- src/colmap/geometry/similarity_transform.h | 8 +- src/colmap/image/bitmap.h | 50 +++-- src/colmap/image/line.h | 4 +- src/colmap/image/undistortion.h | 20 +- src/colmap/image/warp.h | 24 +-- src/colmap/mvs/consistency_graph.h | 10 +- src/colmap/mvs/depth_map.h | 15 +- src/colmap/mvs/fusion.h | 5 +- src/colmap/mvs/image.h | 10 +- src/colmap/mvs/mat.h | 15 +- src/colmap/mvs/model.h | 6 +- src/colmap/mvs/normal_map.h | 6 +- src/colmap/mvs/patch_match.h | 3 +- src/colmap/mvs/workspace.h | 26 +-- src/colmap/optim/bundle_adjustment.h | 48 ++--- src/colmap/optim/combination_sampler.h | 4 +- src/colmap/optim/progressive_sampler.h | 4 +- src/colmap/optim/random_sampler.h | 4 +- src/colmap/optim/ransac.h | 8 +- src/colmap/optim/sampler.h | 4 +- src/colmap/optim/sprt.h | 2 +- src/colmap/optim/support_measurement.h | 6 +- src/colmap/retrieval/inverted_file.h | 4 +- src/colmap/retrieval/inverted_index.h | 12 +- src/colmap/retrieval/visual_index.h | 10 +- src/colmap/sfm/incremental_mapper.h | 24 +-- src/colmap/sfm/incremental_triangulator.h | 16 +- src/colmap/ui/colormaps.h | 12 +- src/colmap/ui/database_management_widget.h | 6 +- src/colmap/ui/feature_extraction_widget.h | 2 +- src/colmap/ui/image_viewer_widget.h | 2 +- src/colmap/ui/line_painter.h | 6 +- src/colmap/ui/log_widget.h | 2 +- src/colmap/ui/main_window.h | 2 +- src/colmap/ui/model_viewer_widget.h | 40 ++-- src/colmap/ui/options_widget.h | 20 +- src/colmap/ui/point_painter.h | 2 +- src/colmap/ui/point_viewer_widget.h | 2 +- src/colmap/ui/reconstruction_manager_widget.h | 2 +- src/colmap/ui/render_options_widget.h | 4 +- src/colmap/ui/thread_control_widget.h | 2 +- src/colmap/util/cache.h | 3 +- src/colmap/util/cuda.h | 2 +- src/colmap/util/endian.h | 8 +- src/colmap/util/logging.h | 4 +- src/colmap/util/math.h | 28 +-- src/colmap/util/misc.h | 2 +- src/colmap/util/opengl_utils.h | 2 +- src/colmap/util/option_manager.h | 4 +- src/colmap/util/ply.h | 8 +- src/colmap/util/random.h | 8 +- src/colmap/util/threading.h | 14 +- src/lib/SiftGPU/SiftGPU.h | 4 +- 81 files changed, 585 insertions(+), 662 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 85930e8085..cfa9dab923 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,6 +11,7 @@ Checks: > cppcoreguidelines-virtual-class-destructor, google-explicit-constructor, google-build-using-namespace, + readability-avoid-const-params-in-decls, WarningsAsErrors: '*' FormatStyle: 'file' User: 'user' diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index 1820447801..47c2e9d9d0 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -115,7 +115,7 @@ macro(COLMAP_ADD_LIBRARY TARGET_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") endif() install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap) endmacro(COLMAP_ADD_LIBRARY) @@ -130,7 +130,7 @@ macro(COLMAP_ADD_CUDA_LIBRARY TARGET_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") endif() install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap/) endmacro(COLMAP_ADD_CUDA_LIBRARY) @@ -150,7 +150,7 @@ macro(COLMAP_ADD_EXECUTABLE TARGET_NAME) install(TARGETS ${TARGET_NAME} DESTINATION bin/) endif() if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") endif() endmacro(COLMAP_ADD_EXECUTABLE) @@ -163,7 +163,7 @@ macro(COLMAP_ADD_TEST TEST_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") endif() target_link_libraries(${TARGET_NAME} colmap ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) @@ -183,7 +183,7 @@ macro(COLMAP_ADD_CUDA_TEST TEST_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") endif() target_link_libraries(${TARGET_NAME} colmap ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) diff --git a/src/colmap/base/camera.h b/src/colmap/base/camera.h index fee161f656..06fd7e79a7 100644 --- a/src/colmap/base/camera.h +++ b/src/colmap/base/camera.h @@ -47,39 +47,39 @@ class Camera { // Access the unique identifier of the camera. inline camera_t CameraId() const; - inline void SetCameraId(const camera_t camera_id); + inline void SetCameraId(camera_t camera_id); // Access the camera model. inline int ModelId() const; std::string ModelName() const; - void SetModelId(const int model_id); + void SetModelId(int model_id); void SetModelIdFromName(const std::string& model_name); // Access dimensions of the camera sensor. inline size_t Width() const; inline size_t Height() const; - inline void SetWidth(const size_t width); - inline void SetHeight(const size_t height); + inline void SetWidth(size_t width); + inline void SetHeight(size_t height); // Access focal length parameters. double MeanFocalLength() const; double FocalLength() const; double FocalLengthX() const; double FocalLengthY() const; - void SetFocalLength(const double focal_length); - void SetFocalLengthX(const double focal_length_x); - void SetFocalLengthY(const double focal_length_y); + void SetFocalLength(double focal_length); + void SetFocalLengthX(double focal_length_x); + void SetFocalLengthY(double focal_length_y); // Check if camera has prior focal length. inline bool HasPriorFocalLength() const; - inline void SetPriorFocalLength(const bool prior); + inline void SetPriorFocalLength(bool prior); // Access principal point parameters. Only works if there are two // principal point parameters. double PrincipalPointX() const; double PrincipalPointY() const; - void SetPrincipalPointX(const double ppx); - void SetPrincipalPointY(const double ppy); + void SetPrincipalPointX(double ppx); + void SetPrincipalPointY(double ppy); // Get the indices of the parameter groups in the parameter vector. const std::vector& FocalLengthIdxs() const; @@ -97,8 +97,8 @@ class Camera { inline size_t NumParams() const; inline const std::vector& Params() const; inline std::vector& Params(); - inline double Params(const size_t idx) const; - inline double& Params(const size_t idx); + inline double Params(size_t idx) const; + inline double& Params(size_t idx); inline const double* ParamsData() const; inline double* ParamsData(); inline void SetParams(const std::vector& params); @@ -117,34 +117,34 @@ class Camera { bool IsUndistorted() const; // Check whether camera has bogus parameters. - bool HasBogusParams(const double min_focal_length_ratio, - const double max_focal_length_ratio, - const double max_extra_param) const; + bool HasBogusParams(double min_focal_length_ratio, + double max_focal_length_ratio, + double max_extra_param) const; // Initialize parameters for given camera model and focal length, and set // the principal point to be the image center. - void InitializeWithId(const int model_id, - const double focal_length, - const size_t width, - const size_t height); + void InitializeWithId(int model_id, + double focal_length, + size_t width, + size_t height); void InitializeWithName(const std::string& model_name, - const double focal_length, - const size_t width, - const size_t height); + double focal_length, + size_t width, + size_t height); // Project point in image plane to world / infinity. Eigen::Vector2d ImageToWorld(const Eigen::Vector2d& image_point) const; // Convert pixel threshold in image plane to world space. - double ImageToWorldThreshold(const double threshold) const; + double ImageToWorldThreshold(double threshold) const; // Project point from world / infinity to image plane. Eigen::Vector2d WorldToImage(const Eigen::Vector2d& world_point) const; // Rescale camera dimensions and accordingly the focal length and // and the principal point. - void Rescale(const double scale); - void Rescale(const size_t width, const size_t height); + void Rescale(double scale); + void Rescale(size_t width, size_t height); private: // The unique identifier of the camera. If the identifier is not specified diff --git a/src/colmap/base/camera_rig.h b/src/colmap/base/camera_rig.h index 36031198ca..3800cae6fd 100644 --- a/src/colmap/base/camera_rig.h +++ b/src/colmap/base/camera_rig.h @@ -56,11 +56,11 @@ class CameraRig { size_t NumSnapshots() const; // Check whether the given camera is part of the rig. - bool HasCamera(const camera_t camera_id) const; + bool HasCamera(camera_t camera_id) const; // Access the reference camera. camera_t RefCameraId() const; - void SetRefCameraId(const camera_t camera_id); + void SetRefCameraId(camera_t camera_id); // Get the identifiers of the cameras in the rig. std::vector GetCameraIds() const; @@ -71,7 +71,7 @@ class CameraRig { // Add a new camera to the rig. The relative pose may contain dummy values and // can then be computed automatically from a given reconstruction using the // method `ComputeRelativePoses`. - void AddCamera(const camera_t camera_id, + void AddCamera(camera_t camera_id, const Eigen::Vector4d& rel_qvec, const Eigen::Vector3d& rel_tvec); @@ -85,10 +85,10 @@ class CameraRig { void Check(const Reconstruction& reconstruction) const; // Get the relative poses of the cameras in the rig. - Eigen::Vector4d& RelativeQvec(const camera_t camera_id); - const Eigen::Vector4d& RelativeQvec(const camera_t camera_id) const; - Eigen::Vector3d& RelativeTvec(const camera_t camera_id); - const Eigen::Vector3d& RelativeTvec(const camera_t camera_id) const; + Eigen::Vector4d& RelativeQvec(camera_t camera_id); + const Eigen::Vector4d& RelativeQvec(camera_t camera_id) const; + Eigen::Vector3d& RelativeTvec(camera_t camera_id); + const Eigen::Vector3d& RelativeTvec(camera_t camera_id) const; // Compute the scaling factor from the reconstruction to the camera rig // dimensions by averaging over the distances between the projection centers. @@ -105,7 +105,7 @@ class CameraRig { // Compute the absolute camera pose of the rig. The absolute camera pose of // the rig is computed as the average of all relative camera poses in the rig // and their corresponding image poses in the reconstruction. - void ComputeAbsolutePose(const size_t snapshot_idx, + void ComputeAbsolutePose(size_t snapshot_idx, const Reconstruction& reconstruction, Eigen::Vector4d* abs_qvec, Eigen::Vector3d* abs_tvec) const; diff --git a/src/colmap/base/correspondence_graph.h b/src/colmap/base/correspondence_graph.h index 750a394102..2e6af57c34 100644 --- a/src/colmap/base/correspondence_graph.h +++ b/src/colmap/base/correspondence_graph.h @@ -65,18 +65,18 @@ class CorrespondenceGraph { inline size_t NumImagePairs() const; // Check whether image exists. - inline bool ExistsImage(const image_t image_id) const; + inline bool ExistsImage(image_t image_id) const; // Get the number of observations in an image. An observation is an image // point that has at least one correspondence. - inline point2D_t NumObservationsForImage(const image_t image_id) const; + inline point2D_t NumObservationsForImage(image_t image_id) const; // Get the number of correspondences per image. - inline point2D_t NumCorrespondencesForImage(const image_t image_id) const; + inline point2D_t NumCorrespondencesForImage(image_t image_id) const; // Get the number of correspondences between a pair of images. - inline point2D_t NumCorrespondencesBetweenImages( - const image_t image_id1, const image_t image_id2) const; + inline point2D_t NumCorrespondencesBetweenImages(image_t image_id1, + image_t image_id2) const; // Get the number of correspondences between all images. std::unordered_map NumCorrespondencesBetweenImages() @@ -91,19 +91,19 @@ class CorrespondenceGraph { void Finalize(); // Add new image to the correspondence graph. - void AddImage(const image_t image_id, const size_t num_points2D); + void AddImage(image_t image_id, size_t num_points2D); // Add correspondences between images. This function ignores invalid // correspondences where the point indices are out of bounds or duplicate // correspondences between the same image points. Whenever either of the two // cases occur this function prints a warning to the standard output. - void AddCorrespondences(const image_t image_id1, - const image_t image_id2, + void AddCorrespondences(image_t image_id1, + image_t image_id2, const FeatureMatches& matches); // Find the correspondence of an image observation to all other images. inline const std::vector& FindCorrespondences( - const image_t image_id, const point2D_t point2D_idx) const; + image_t image_id, point2D_t point2D_idx) const; // Find correspondences to the given observation. // @@ -114,24 +114,22 @@ class CorrespondenceGraph { // found. The returned list does not contain duplicates and contains // the given observation. void FindTransitiveCorrespondences( - const image_t image_id, - const point2D_t point2D_idx, - const size_t transitivity, + image_t image_id, + point2D_t point2D_idx, + size_t transitivity, std::vector* found_corrs) const; // Find all correspondences between two images. - FeatureMatches FindCorrespondencesBetweenImages( - const image_t image_id1, const image_t image_id2) const; + FeatureMatches FindCorrespondencesBetweenImages(image_t image_id1, + image_t image_id2) const; // Check whether the image point has correspondences. - inline bool HasCorrespondences(const image_t image_id, - const point2D_t point2D_idx) const; + inline bool HasCorrespondences(image_t image_id, point2D_t point2D_idx) const; // Check whether the given observation is part of a two-view track, i.e. // it only has one correspondence and that correspondence has the given // observation as its only correspondence. - bool IsTwoViewObservation(const image_t image_id, - const point2D_t point2D_idx) const; + bool IsTwoViewObservation(image_t image_id, point2D_t point2D_idx) const; private: struct Image { diff --git a/src/colmap/base/database.h b/src/colmap/base/database.h index 056e7f3d7c..501202d26b 100644 --- a/src/colmap/base/database.h +++ b/src/colmap/base/database.h @@ -72,14 +72,13 @@ class Database { // Check if entry already exists in database. For image pairs, the order of // `image_id1` and `image_id2` does not matter. - bool ExistsCamera(const camera_t camera_id) const; - bool ExistsImage(const image_t image_id) const; + bool ExistsCamera(camera_t camera_id) const; + bool ExistsImage(image_t image_id) const; bool ExistsImageWithName(const std::string& name) const; - bool ExistsKeypoints(const image_t image_id) const; - bool ExistsDescriptors(const image_t image_id) const; - bool ExistsMatches(const image_t image_id1, const image_t image_id2) const; - bool ExistsInlierMatches(const image_t image_id1, - const image_t image_id2) const; + bool ExistsKeypoints(image_t image_id) const; + bool ExistsDescriptors(image_t image_id) const; + bool ExistsMatches(image_t image_id1, image_t image_id2) const; + bool ExistsInlierMatches(image_t image_id1, image_t image_id2) const; // Number of rows in `cameras` table. size_t NumCameras() const; @@ -94,7 +93,7 @@ class Database { size_t MaxNumKeypoints() const; // Number of descriptors for specific image. - size_t NumKeypointsForImage(const image_t image_id) const; + size_t NumKeypointsForImage(image_t image_id) const; // Sum of `rows` column in `descriptors` table, // i.e. number of total descriptors. @@ -104,7 +103,7 @@ class Database { size_t MaxNumDescriptors() const; // Number of descriptors for specific image. - size_t NumDescriptorsForImage(const image_t image_id) const; + size_t NumDescriptorsForImage(image_t image_id) const; // Sum of `rows` column in `matches` table, i.e. number of total matches. size_t NumMatches() const; @@ -123,38 +122,36 @@ class Database { // `two_view_geometries` table. We intentionally avoid to store the pairs in a // separate table by using e.g. AUTOINCREMENT, since the overhead of querying // the unique pair ID is significant. - inline static image_pair_t ImagePairToPairId(const image_t image_id1, - const image_t image_id2); + inline static image_pair_t ImagePairToPairId(image_t image_id1, + image_t image_id2); - inline static void PairIdToImagePair(const image_pair_t pair_id, + inline static void PairIdToImagePair(image_pair_t pair_id, image_t* image_id1, image_t* image_id2); // Return true if image pairs should be swapped. Used to enforce a specific // image order to generate unique image pair identifiers independent of the // order in which the image identifiers are used. - inline static bool SwapImagePair(const image_t image_id1, - const image_t image_id2); + inline static bool SwapImagePair(image_t image_id1, image_t image_id2); // Read an existing entry in the database. The user is responsible for making // sure that the entry actually exists. For image pairs, the order of // `image_id1` and `image_id2` does not matter. - Camera ReadCamera(const camera_t camera_id) const; + Camera ReadCamera(camera_t camera_id) const; std::vector ReadAllCameras() const; - Image ReadImage(const image_t image_id) const; + Image ReadImage(image_t image_id) const; Image ReadImageWithName(const std::string& name) const; std::vector ReadAllImages() const; - FeatureKeypoints ReadKeypoints(const image_t image_id) const; - FeatureDescriptors ReadDescriptors(const image_t image_id) const; + FeatureKeypoints ReadKeypoints(image_t image_id) const; + FeatureDescriptors ReadDescriptors(image_t image_id) const; - FeatureMatches ReadMatches(const image_t image_id1, - const image_t image_id2) const; + FeatureMatches ReadMatches(image_t image_id1, image_t image_id2) const; std::vector> ReadAllMatches() const; - TwoViewGeometry ReadTwoViewGeometry(const image_t image_id1, - const image_t image_id2) const; + TwoViewGeometry ReadTwoViewGeometry(image_t image_id1, + image_t image_id2) const; void ReadTwoViewGeometries( std::vector* image_pair_ids, std::vector* two_view_geometries) const; @@ -167,25 +164,24 @@ class Database { // Add new camera and return its database identifier. If `use_camera_id` // is false a new identifier is automatically generated. - camera_t WriteCamera(const Camera& camera, - const bool use_camera_id = false) const; + camera_t WriteCamera(const Camera& camera, bool use_camera_id = false) const; // Add new image and return its database identifier. If `use_image_id` // is false a new identifier is automatically generated. - image_t WriteImage(const Image& image, const bool use_image_id = false) const; + image_t WriteImage(const Image& image, bool use_image_id = false) const; // Write a new entry in the database. The user is responsible for making sure // that the entry does not yet exist. For image pairs, the order of // `image_id1` and `image_id2` does not matter. - void WriteKeypoints(const image_t image_id, + void WriteKeypoints(image_t image_id, const FeatureKeypoints& keypoints) const; - void WriteDescriptors(const image_t image_id, + void WriteDescriptors(image_t image_id, const FeatureDescriptors& descriptors) const; - void WriteMatches(const image_t image_id1, - const image_t image_id2, + void WriteMatches(image_t image_id1, + image_t image_id2, const FeatureMatches& matches) const; - void WriteTwoViewGeometry(const image_t image_id1, - const image_t image_id2, + void WriteTwoViewGeometry(image_t image_id1, + image_t image_id2, const TwoViewGeometry& two_view_geometry) const; // Update an existing camera in the database. The user is responsible for @@ -197,11 +193,10 @@ class Database { void UpdateImage(const Image& image) const; // Delete matches of an image pair. - void DeleteMatches(const image_t image_id1, const image_t image_id2) const; + void DeleteMatches(image_t image_id1, image_t image_id2) const; // Delete inlier matches of an image pair. - void DeleteInlierMatches(const image_t image_id1, - const image_t image_id2) const; + void DeleteInlierMatches(image_t image_id1, image_t image_id2) const; // Clear all database tables void ClearAllTables() const; @@ -260,13 +255,12 @@ class Database { bool ExistsColumn(const std::string& table_name, const std::string& column_name) const; - bool ExistsRowId(sqlite3_stmt* sql_stmt, const sqlite3_int64 row_id) const; + bool ExistsRowId(sqlite3_stmt* sql_stmt, sqlite3_int64 row_id) const; bool ExistsRowString(sqlite3_stmt* sql_stmt, const std::string& row_entry) const; size_t CountRows(const std::string& table) const; - size_t CountRowsForEntry(sqlite3_stmt* sql_stmt, - const sqlite3_int64 row_id) const; + size_t CountRowsForEntry(sqlite3_stmt* sql_stmt, sqlite3_int64 row_id) const; size_t SumColumn(const std::string& column, const std::string& table) const; size_t MaxColumn(const std::string& column, const std::string& table) const; diff --git a/src/colmap/base/database_cache.h b/src/colmap/base/database_cache.h index 11cfe2024d..d90d6d8008 100644 --- a/src/colmap/base/database_cache.h +++ b/src/colmap/base/database_cache.h @@ -58,18 +58,18 @@ class DatabaseCache { inline size_t NumImages() const; // Get specific objects. - inline class Camera& Camera(const camera_t camera_id); - inline const class Camera& Camera(const camera_t camera_id) const; - inline class Image& Image(const image_t image_id); - inline const class Image& Image(const image_t image_id) const; + inline class Camera& Camera(camera_t camera_id); + inline const class Camera& Camera(camera_t camera_id) const; + inline class Image& Image(image_t image_id); + inline const class Image& Image(image_t image_id) const; // Get all objects. inline const std::unordered_map& Cameras() const; inline const std::unordered_map& Images() const; // Check whether specific object exists. - inline bool ExistsCamera(const camera_t camera_id) const; - inline bool ExistsImage(const image_t image_id) const; + inline bool ExistsCamera(camera_t camera_id) const; + inline bool ExistsImage(image_t image_id) const; // Get reference to correspondence graph. inline const class CorrespondenceGraph& CorrespondenceGraph() const; @@ -87,8 +87,8 @@ class DatabaseCache { // @param image_names Whether to use only load the data for a subset // of the images. All images are used if empty. void Load(const Database& database, - const size_t min_num_matches, - const bool ignore_watermarks, + size_t min_num_matches, + bool ignore_watermarks, const std::unordered_set& image_names); // Find specific image by name. Note that this uses linear search. diff --git a/src/colmap/base/graph_cut.h b/src/colmap/base/graph_cut.h index 365383c702..2f9aaade86 100644 --- a/src/colmap/base/graph_cut.h +++ b/src/colmap/base/graph_cut.h @@ -55,7 +55,7 @@ void ComputeMinGraphCutStoerWagner( std::unordered_map ComputeNormalizedMinGraphCut( const std::vector>& edges, const std::vector& weights, - const int num_parts); + int num_parts); // Compute the minimum graph cut of a directed S-T graph using the // Boykov-Kolmogorov max-flow min-cut algorithm, as descibed in: @@ -80,29 +80,27 @@ class MinSTGraphCut { adjacency_list graph_t; - explicit MinSTGraphCut(const size_t num_nodes); + explicit MinSTGraphCut(size_t num_nodes); // Count the number of nodes and edges in the graph. size_t NumNodes() const; size_t NumEdges() const; // Add node to the graph. - void AddNode(const node_t node_idx, - const value_t source_capacity, - const value_t sink_capacity); + void AddNode(node_t node_idx, value_t source_capacity, value_t sink_capacity); // Add edge to the graph. - void AddEdge(const node_t node_idx1, - const node_t node_idx2, - const value_t capacity, - const value_t reverse_capacity); + void AddEdge(node_t node_idx1, + node_t node_idx2, + value_t capacity, + value_t reverse_capacity); // Compute the min-cut using the max-flow algorithm. Returns the flow. value_t Compute(); // Check whether node is connected to source or sink after computing the cut. - bool IsConnectedToSource(const node_t node_idx) const; - bool IsConnectedToSink(const node_t node_idx) const; + bool IsConnectedToSource(node_t node_idx) const; + bool IsConnectedToSink(node_t node_idx) const; private: const node_t S_node_; diff --git a/src/colmap/base/image.h b/src/colmap/base/image.h index fcb3f008e4..d5c6f50cd0 100644 --- a/src/colmap/base/image.h +++ b/src/colmap/base/image.h @@ -59,7 +59,7 @@ class Image { // Access the unique identifier of the image. inline image_t ImageId() const; - inline void SetImageId(const image_t image_id); + inline void SetImageId(image_t image_id); // Access the name of the image. inline const std::string& Name() const; @@ -69,13 +69,13 @@ class Image { // Access the unique identifier of the camera. Note that multiple images // might share the same camera. inline camera_t CameraId() const; - inline void SetCameraId(const camera_t camera_id); + inline void SetCameraId(camera_t camera_id); // Check whether identifier of camera has been set. inline bool HasCamera() const; // Check if image is registered. inline bool IsRegistered() const; - inline void SetRegistered(const bool registered); + inline void SetRegistered(bool registered); // Get the number of image points. inline point2D_t NumPoints2D() const; @@ -87,11 +87,11 @@ class Image { // Get the number of observations, i.e. the number of image points that // have at least one correspondence to another image. inline point2D_t NumObservations() const; - inline void SetNumObservations(const point2D_t num_observations); + inline void SetNumObservations(point2D_t num_observations); // Get the number of correspondences for all image points. inline point2D_t NumCorrespondences() const; - inline void SetNumCorrespondences(const point2D_t num_observations); + inline void SetNumCorrespondences(point2D_t num_observations); // Get the number of observations that see a triangulated point, i.e. the // number of image points that have at least one correspondence to a @@ -109,15 +109,15 @@ class Image { // pose which is defined as the transformation from world to image space. inline const Eigen::Vector4d& Qvec() const; inline Eigen::Vector4d& Qvec(); - inline double Qvec(const size_t idx) const; - inline double& Qvec(const size_t idx); + inline double Qvec(size_t idx) const; + inline double& Qvec(size_t idx); inline void SetQvec(const Eigen::Vector4d& qvec); // Quaternion prior, e.g. given by EXIF gyroscope tag. inline const Eigen::Vector4d& QvecPrior() const; inline Eigen::Vector4d& QvecPrior(); - inline double QvecPrior(const size_t idx) const; - inline double& QvecPrior(const size_t idx); + inline double QvecPrior(size_t idx) const; + inline double& QvecPrior(size_t idx); inline bool HasQvecPrior() const; inline void SetQvecPrior(const Eigen::Vector4d& qvec); @@ -125,50 +125,49 @@ class Image { // pose which is defined as the transformation from world to image space. inline const Eigen::Vector3d& Tvec() const; inline Eigen::Vector3d& Tvec(); - inline double Tvec(const size_t idx) const; - inline double& Tvec(const size_t idx); + inline double Tvec(size_t idx) const; + inline double& Tvec(size_t idx); inline void SetTvec(const Eigen::Vector3d& tvec); // Translation prior, e.g. given by EXIF GPS tag. inline const Eigen::Vector3d& TvecPrior() const; inline Eigen::Vector3d& TvecPrior(); - inline double TvecPrior(const size_t idx) const; - inline double& TvecPrior(const size_t idx); + inline double TvecPrior(size_t idx) const; + inline double& TvecPrior(size_t idx); inline bool HasTvecPrior() const; inline void SetTvecPrior(const Eigen::Vector3d& tvec); // Access the coordinates of image points. - inline const class Point2D& Point2D(const point2D_t point2D_idx) const; - inline class Point2D& Point2D(const point2D_t point2D_idx); + inline const class Point2D& Point2D(point2D_t point2D_idx) const; + inline class Point2D& Point2D(point2D_t point2D_idx); inline const std::vector& Points2D() const; void SetPoints2D(const std::vector& points); void SetPoints2D(const std::vector& points); // Set the point as triangulated, i.e. it is part of a 3D point track. - void SetPoint3DForPoint2D(const point2D_t point2D_idx, - const point3D_t point3D_id); + void SetPoint3DForPoint2D(point2D_t point2D_idx, point3D_t point3D_id); // Set the point as not triangulated, i.e. it is not part of a 3D point track. - void ResetPoint3DForPoint2D(const point2D_t point2D_idx); + void ResetPoint3DForPoint2D(point2D_t point2D_idx); // Check whether an image point has a correspondence to an image point in // another image that has a 3D point. - inline bool IsPoint3DVisible(const point2D_t point2D_idx) const; + inline bool IsPoint3DVisible(point2D_t point2D_idx) const; // Check whether one of the image points is part of the 3D point track. - bool HasPoint3D(const point3D_t point3D_id) const; + bool HasPoint3D(point3D_t point3D_id) const; // Indicate that another image has a point that is triangulated and has // a correspondence to this image point. Note that this must only be called // after calling `SetUp`. - void IncrementCorrespondenceHasPoint3D(const point2D_t point2D_idx); + void IncrementCorrespondenceHasPoint3D(point2D_t point2D_idx); // Indicate that another image has a point that is not triangulated any more // and has a correspondence to this image point. This assumes that // `IncrementCorrespondenceHasPoint3D` was called for the same image point // and correspondence before. Note that this must only be called // after calling `SetUp`. - void DecrementCorrespondenceHasPoint3D(const point2D_t point2D_idx); + void DecrementCorrespondenceHasPoint3D(point2D_t point2D_idx); // Normalize the quaternion vector. void NormalizeQvec(); diff --git a/src/colmap/base/point2d.h b/src/colmap/base/point2d.h index 67a8a21944..080932f9cf 100644 --- a/src/colmap/base/point2d.h +++ b/src/colmap/base/point2d.h @@ -54,7 +54,7 @@ class Point2D { // observe a 3D point, the identifier is `kInvalidPoint3Did`. inline point3D_t Point3DId() const; inline bool HasPoint3D() const; - inline void SetPoint3DId(const point3D_t point3D_id); + inline void SetPoint3DId(point3D_t point3D_id); private: // The image coordinates in pixels, starting at upper left corner with 0. diff --git a/src/colmap/base/point3d.h b/src/colmap/base/point3d.h index f39877cf6a..db00d6cd51 100644 --- a/src/colmap/base/point3d.h +++ b/src/colmap/base/point3d.h @@ -49,8 +49,8 @@ class Point3D { // The point coordinate in world space. inline const Eigen::Vector3d& XYZ() const; inline Eigen::Vector3d& XYZ(); - inline double XYZ(const size_t idx) const; - inline double& XYZ(const size_t idx); + inline double XYZ(size_t idx) const; + inline double& XYZ(size_t idx); inline double X() const; inline double Y() const; inline double Z() const; @@ -59,14 +59,14 @@ class Point3D { // The RGB color of the point. inline const Eigen::Vector3ub& Color() const; inline Eigen::Vector3ub& Color(); - inline uint8_t Color(const size_t idx) const; - inline uint8_t& Color(const size_t idx); + inline uint8_t Color(size_t idx) const; + inline uint8_t& Color(size_t idx); inline void SetColor(const Eigen::Vector3ub& color); // The mean reprojection error in image space. inline double Error() const; inline bool HasError() const; - inline void SetError(const double error); + inline void SetError(double error); inline const class Track& Track() const; inline class Track& Track(); diff --git a/src/colmap/base/reconstruction.h b/src/colmap/base/reconstruction.h index 98903756e3..466640a9fb 100644 --- a/src/colmap/base/reconstruction.h +++ b/src/colmap/base/reconstruction.h @@ -78,20 +78,19 @@ class Reconstruction { inline size_t NumImagePairs() const; // Get const objects. - inline const class Camera& Camera(const camera_t camera_id) const; - inline const class Image& Image(const image_t image_id) const; - inline const class Point3D& Point3D(const point3D_t point3D_id) const; - inline const ImagePairStat& ImagePair(const image_pair_t pair_id) const; - inline ImagePairStat& ImagePair(const image_t image_id1, - const image_t image_id2); + inline const class Camera& Camera(camera_t camera_id) const; + inline const class Image& Image(image_t image_id) const; + inline const class Point3D& Point3D(point3D_t point3D_id) const; + inline const ImagePairStat& ImagePair(image_pair_t pair_id) const; + inline ImagePairStat& ImagePair(image_t image_id1, image_t image_id2); // Get mutable objects. - inline class Camera& Camera(const camera_t camera_id); - inline class Image& Image(const image_t image_id); - inline class Point3D& Point3D(const point3D_t point3D_id); - inline ImagePairStat& ImagePair(const image_pair_t pair_id); - inline const ImagePairStat& ImagePair(const image_t image_id1, - const image_t image_id2) const; + inline class Camera& Camera(camera_t camera_id); + inline class Image& Image(image_t image_id); + inline class Point3D& Point3D(point3D_t point3D_id); + inline ImagePairStat& ImagePair(image_pair_t pair_id); + inline const ImagePairStat& ImagePair(image_t image_id1, + image_t image_id2) const; // Get reference to all objects. inline const std::unordered_map& Cameras() const; @@ -105,10 +104,10 @@ class Reconstruction { std::unordered_set Point3DIds() const; // Check whether specific object exists. - inline bool ExistsCamera(const camera_t camera_id) const; - inline bool ExistsImage(const image_t image_id) const; - inline bool ExistsPoint3D(const point3D_t point3D_id) const; - inline bool ExistsImagePair(const image_pair_t pair_id) const; + inline bool ExistsCamera(camera_t camera_id) const; + inline bool ExistsImage(image_t image_id) const; + inline bool ExistsPoint3D(point3D_t point3D_id) const; + inline bool ExistsImagePair(image_pair_t pair_id) const; // Load data from given `DatabaseCache`. void Load(const DatabaseCache& database_cache); @@ -139,33 +138,32 @@ class Reconstruction { const Eigen::Vector3ub& color = Eigen::Vector3ub::Zero()); // Add observation to existing 3D point. - void AddObservation(const point3D_t point3D_id, const TrackElement& track_el); + void AddObservation(point3D_t point3D_id, const TrackElement& track_el); // Merge two 3D points and return new identifier of new 3D point. // The location of the merged 3D point is a weighted average of the two // original 3D point's locations according to their track lengths. - point3D_t MergePoints3D(const point3D_t point3D_id1, - const point3D_t point3D_id2); + point3D_t MergePoints3D(point3D_t point3D_id1, point3D_t point3D_id2); // Delete a 3D point, and all its references in the observed images. - void DeletePoint3D(const point3D_t point3D_id); + void DeletePoint3D(point3D_t point3D_id); // Delete one observation from an image and the corresponding 3D point. // Note that this deletes the entire 3D point, if the track has two elements // prior to calling this method. - void DeleteObservation(const image_t image_id, const point2D_t point2D_idx); + void DeleteObservation(image_t image_id, point2D_t point2D_idx); // Delete all 2D points of all images and all 3D points. void DeleteAllPoints2DAndPoints3D(); // Register an existing image. - void RegisterImage(const image_t image_id); + void RegisterImage(image_t image_id); // De-register an existing image, and all its references. - void DeRegisterImage(const image_t image_id); + void DeRegisterImage(image_t image_id); // Check if image is registered. - inline bool IsImageRegistered(const image_t image_id) const; + inline bool IsImageRegistered(image_t image_id) const; // Normalize scene by scaling and translation to avoid degenerate // visualization after bundle adjustment and to improve numerical @@ -177,18 +175,17 @@ class Reconstruction { // Scales scene such that the minimum and maximum camera centers are at the // given `extent`, whereas `p0` and `p1` determine the minimum and // maximum percentiles of the camera centers considered. - void Normalize(const double extent = 10.0, - const double p0 = 0.1, - const double p1 = 0.9, - const bool use_images = true); + void Normalize(double extent = 10.0, + double p0 = 0.1, + double p1 = 0.9, + bool use_images = true); // Compute the centroid of the 3D points - Eigen::Vector3d ComputeCentroid(const double p0 = 0.1, - const double p1 = 0.9) const; + Eigen::Vector3d ComputeCentroid(double p0 = 0.1, double p1 = 0.9) const; // Compute the bounding box corners of the 3D points std::pair ComputeBoundingBox( - const double p0 = 0.0, const double p1 = 1.0) const; + double p0 = 0.0, double p1 = 1.0) const; // Apply the 3D similarity transformation to all images and points. void Transform(const SimilarityTransform3& tform); @@ -205,8 +202,7 @@ class Reconstruction { // merging the two clouds and their tracks. The coordinate frames of the two // reconstructions are aligned using the projection centers of common // registered images. Return true if the two reconstructions could be merged. - bool Merge(const Reconstruction& reconstruction, - const double max_reproj_error); + bool Merge(const Reconstruction& reconstruction, double max_reproj_error); // Align the given reconstruction with a set of pre-defined camera positions. // Assuming that locations[i] gives the 3D coordinates of the center @@ -214,14 +210,14 @@ class Reconstruction { template bool Align(const std::vector& image_names, const std::vector& locations, - const int min_common_images, + int min_common_images, SimilarityTransform3* tform = nullptr); // Robust alignment using RANSAC. template bool AlignRobust(const std::vector& image_names, const std::vector& locations, - const int min_common_images, + int min_common_images, const RANSACOptions& ransac_options, SimilarityTransform3* tform = nullptr); @@ -244,14 +240,13 @@ class Reconstruction { // @param point3D_ids The points to be filtered. // // @return The number of filtered observations. - size_t FilterPoints3D(const double max_reproj_error, - const double min_tri_angle, + size_t FilterPoints3D(double max_reproj_error, + double min_tri_angle, const std::unordered_set& point3D_ids); - size_t FilterPoints3DInImages(const double max_reproj_error, - const double min_tri_angle, + size_t FilterPoints3DInImages(double max_reproj_error, + double min_tri_angle, const std::unordered_set& image_ids); - size_t FilterAllPoints3D(const double max_reproj_error, - const double min_tri_angle); + size_t FilterAllPoints3D(double max_reproj_error, double min_tri_angle); // Filter observations that have negative depth. // @@ -261,9 +256,9 @@ class Reconstruction { // Filter images without observations or bogus camera parameters. // // @return The identifiers of the filtered images. - std::vector FilterImages(const double min_focal_length_ratio, - const double max_focal_length_ratio, - const double max_extra_param); + std::vector FilterImages(double min_focal_length_ratio, + double max_focal_length_ratio, + double max_extra_param); // Compute statistics for scene. size_t ComputeNumObservations() const; @@ -364,7 +359,7 @@ class Reconstruction { // Exports in VRML format https://en.wikipedia.org/wiki/VRML. void ExportVRML(const std::string& images_path, const std::string& points3D_path, - const double image_scale, + double image_scale, const Eigen::Vector3d& image_rgb) const; // Extract colors for 3D points of given image. Colors will be extracted @@ -376,7 +371,7 @@ class Reconstruction { // root path and the name of the image. // // @return True if image could be read at given path. - bool ExtractColorsForImage(const image_t image_id, const std::string& path); + bool ExtractColorsForImage(image_t image_id, const std::string& path); // Extract colors for all 3D points by computing the mean color of all images. // @@ -390,16 +385,13 @@ class Reconstruction { private: size_t FilterPoints3DWithSmallTriangulationAngle( - const double min_tri_angle, - const std::unordered_set& point3D_ids); + double min_tri_angle, const std::unordered_set& point3D_ids); size_t FilterPoints3DWithLargeReprojectionError( - const double max_reproj_error, + double max_reproj_error, const std::unordered_set& point3D_ids); std::tuple - ComputeBoundsAndCentroid(const double p0, - const double p1, - const bool use_images) const; + ComputeBoundsAndCentroid(double p0, double p1, bool use_images) const; void ReadCamerasText(const std::string& path); void ReadImagesText(const std::string& path); @@ -415,12 +407,12 @@ class Reconstruction { void WriteImagesBinary(const std::string& path) const; void WritePoints3DBinary(const std::string& path) const; - void SetObservationAsTriangulated(const image_t image_id, - const point2D_t point2D_idx, - const bool is_continued_point3D); - void ResetTriObservations(const image_t image_id, - const point2D_t point2D_idx, - const bool is_deleted_point3D); + void SetObservationAsTriangulated(image_t image_id, + point2D_t point2D_idx, + bool is_continued_point3D); + void ResetTriObservations(image_t image_id, + point2D_t point2D_idx, + bool is_deleted_point3D); const CorrespondenceGraph* correspondence_graph_; diff --git a/src/colmap/base/reconstruction_manager.h b/src/colmap/base/reconstruction_manager.h index c8d2128bba..71968d110e 100644 --- a/src/colmap/base/reconstruction_manager.h +++ b/src/colmap/base/reconstruction_manager.h @@ -51,14 +51,14 @@ class ReconstructionManager { size_t Size() const; // Get a reference to a specific reconstruction. - const Reconstruction& Get(const size_t idx) const; - Reconstruction& Get(const size_t idx); + const Reconstruction& Get(size_t idx) const; + Reconstruction& Get(size_t idx); // Add a new empty reconstruction and return its index. size_t Add(); // Delete a specific reconstruction. - void Delete(const size_t idx); + void Delete(size_t idx); // Delete all reconstructions. void Clear(); diff --git a/src/colmap/base/track.h b/src/colmap/base/track.h index 737224fcbd..a6d2700cbc 100644 --- a/src/colmap/base/track.h +++ b/src/colmap/base/track.h @@ -41,7 +41,7 @@ namespace colmap { // Track class stores all observations of a 3D point. struct TrackElement { TrackElement(); - TrackElement(const image_t image_id, const point2D_t point2D_idx); + TrackElement(image_t image_id, point2D_t point2D_idx); // The image in which the track element is observed. image_t image_id; // The point in the image that the track element is observed. @@ -61,22 +61,22 @@ class Track { inline void SetElements(std::vector elements); // Access specific elements. - inline const TrackElement& Element(const size_t idx) const; - inline TrackElement& Element(const size_t idx); - inline void SetElement(const size_t idx, const TrackElement& element); + inline const TrackElement& Element(size_t idx) const; + inline TrackElement& Element(size_t idx); + inline void SetElement(size_t idx, const TrackElement& element); // Append new elements. inline void AddElement(const TrackElement& element); - inline void AddElement(const image_t image_id, const point2D_t point2D_idx); + inline void AddElement(image_t image_id, point2D_t point2D_idx); inline void AddElements(const std::vector& elements); // Delete existing element. - inline void DeleteElement(const size_t idx); - void DeleteElement(const image_t image_id, const point2D_t point2D_idx); + inline void DeleteElement(size_t idx); + void DeleteElement(image_t image_id, point2D_t point2D_idx); // Requests that the track capacity be at least enough to contain the // specified number of elements. - inline void Reserve(const size_t num_elements); + inline void Reserve(size_t num_elements); // Shrink the capacity of track vector to fit its size to save memory. inline void Compress(); diff --git a/src/colmap/base/visibility_pyramid.h b/src/colmap/base/visibility_pyramid.h index 7751278380..7b25d26923 100644 --- a/src/colmap/base/visibility_pyramid.h +++ b/src/colmap/base/visibility_pyramid.h @@ -51,12 +51,10 @@ namespace colmap { class VisibilityPyramid { public: VisibilityPyramid(); - VisibilityPyramid(const size_t num_levels, - const size_t width, - const size_t height); + VisibilityPyramid(size_t num_levels, size_t width, size_t height); - void SetPoint(const double x, const double y); - void ResetPoint(const double x, const double y); + void SetPoint(double x, double y); + void ResetPoint(double x, double y); inline size_t NumLevels() const; inline size_t Width() const; @@ -66,10 +64,7 @@ class VisibilityPyramid { inline size_t MaxScore() const; private: - void CellForPoint(const double x, - const double y, - size_t* cx, - size_t* cy) const; + void CellForPoint(double x, double y, size_t* cx, size_t* cy) const; // Range of the input points. size_t width_; diff --git a/src/colmap/camera/models.h b/src/colmap/camera/models.h index c59ed3570c..b4ec6df282 100644 --- a/src/colmap/camera/models.h +++ b/src/colmap/camera/models.h @@ -79,37 +79,36 @@ namespace colmap { static const int kInvalidCameraModelId = -1; #ifndef CAMERA_MODEL_DEFINITIONS -#define CAMERA_MODEL_DEFINITIONS( \ - model_id_value, model_name_value, num_params_value) \ - static const int kModelId = model_id_value; \ - static const size_t kNumParams = num_params_value; \ - static const int model_id; \ - static const std::string model_name; \ - static const size_t num_params; \ - static const std::string params_info; \ - static const std::vector focal_length_idxs; \ - static const std::vector principal_point_idxs; \ - static const std::vector extra_params_idxs; \ - \ - static inline int InitializeModelId() { return model_id_value; }; \ - static inline std::string InitializeModelName() { \ - return model_name_value; \ - }; \ - static inline size_t InitializeNumParams() { return num_params_value; }; \ - static inline std::string InitializeParamsInfo(); \ - static inline std::vector InitializeFocalLengthIdxs(); \ - static inline std::vector InitializePrincipalPointIdxs(); \ - static inline std::vector InitializeExtraParamsIdxs(); \ - static inline std::vector InitializeParams( \ - const double focal_length, const size_t width, const size_t height); \ - \ - template \ - static void WorldToImage(const T* params, const T u, const T v, T* x, T* y); \ - template \ - static void ImageToWorld(const T* params, const T x, const T y, T* u, T* v); \ - template \ - static void Distortion( \ - const T* extra_params, const T u, const T v, T* du, T* dv); +#define CAMERA_MODEL_DEFINITIONS( \ + model_id_value, model_name_value, num_params_value) \ + static const int kModelId = model_id_value; \ + static const size_t kNumParams = num_params_value; \ + static const int model_id; \ + static const std::string model_name; \ + static const size_t num_params; \ + static const std::string params_info; \ + static const std::vector focal_length_idxs; \ + static const std::vector principal_point_idxs; \ + static const std::vector extra_params_idxs; \ + \ + static inline int InitializeModelId() { return model_id_value; }; \ + static inline std::string InitializeModelName() { \ + return model_name_value; \ + }; \ + static inline size_t InitializeNumParams() { return num_params_value; }; \ + static inline std::string InitializeParamsInfo(); \ + static inline std::vector InitializeFocalLengthIdxs(); \ + static inline std::vector InitializePrincipalPointIdxs(); \ + static inline std::vector InitializeExtraParamsIdxs(); \ + static inline std::vector InitializeParams( \ + double focal_length, size_t width, size_t height); \ + \ + template \ + static void WorldToImage(const T* params, T u, T v, T* x, T* y); \ + template \ + static void ImageToWorld(const T* params, T x, T y, T* u, T* v); \ + template \ + static void Distortion(const T* extra_params, T u, T v, T* du, T* dv); #endif #ifndef CAMERA_MODEL_CASES @@ -145,30 +144,30 @@ template struct BaseCameraModel { template static inline bool HasBogusParams(const std::vector& params, - const size_t width, - const size_t height, - const T min_focal_length_ratio, - const T max_focal_length_ratio, - const T max_extra_param); + size_t width, + size_t height, + T min_focal_length_ratio, + T max_focal_length_ratio, + T max_extra_param); template static inline bool HasBogusFocalLength(const std::vector& params, - const size_t width, - const size_t height, - const T min_focal_length_ratio, - const T max_focal_length_ratio); + size_t width, + size_t height, + T min_focal_length_ratio, + T max_focal_length_ratio); template static inline bool HasBogusPrincipalPoint(const std::vector& params, - const size_t width, - const size_t height); + size_t width, + size_t height); template static inline bool HasBogusExtraParams(const std::vector& params, - const T max_extra_param); + T max_extra_param); template - static inline T ImageToWorldThreshold(const T* params, const T threshold); + static inline T ImageToWorldThreshold(const T* params, T threshold); template static inline void IterativeUndistortion(const T* params, T* u, T* v); @@ -297,8 +296,7 @@ struct FOVCameraModel : public BaseCameraModel { CAMERA_MODEL_DEFINITIONS(7, "FOV", 5) template - static void Undistortion( - const T* extra_params, const T u, const T v, T* du, T* dv); + static void Undistortion(const T* extra_params, T u, T v, T* du, T* dv); }; // Simple camera model with one focal length and one radial distortion @@ -350,7 +348,7 @@ struct ThinPrismFisheyeCameraModel // Check whether camera model with given name or identifier exists. bool ExistsCameraModelWithName(const std::string& model_name); -bool ExistsCameraModelWithId(const int model_id); +bool ExistsCameraModelWithId(int model_id); // Convert camera name to unique camera model identifier. // @@ -364,7 +362,7 @@ int CameraModelNameToId(const std::string& model_name); // @param model_id Unique identifier of camera model. // // @return Unique name of camera model. -std::string CameraModelIdToName(const int model_id); +std::string CameraModelIdToName(int model_id); // Initialize camera parameters using given image properties. // @@ -375,33 +373,32 @@ std::string CameraModelIdToName(const int model_id); // @param focal_length Focal length, equal for all focal length parameters. // @param width Sensor width of the camera. // @param height Sensor height of the camera. -std::vector CameraModelInitializeParams(const int model_id, - const double focal_length, - const size_t width, - const size_t height); +std::vector CameraModelInitializeParams(int model_id, + double focal_length, + size_t width, + size_t height); // Get human-readable information about the parameter vector order. // // @param model_id Unique identifier of camera model. -std::string CameraModelParamsInfo(const int model_id); +std::string CameraModelParamsInfo(int model_id); // Get the indices of the parameter groups in the parameter vector. // // @param model_id Unique identifier of camera model. -const std::vector& CameraModelFocalLengthIdxs(const int model_id); -const std::vector& CameraModelPrincipalPointIdxs(const int model_id); -const std::vector& CameraModelExtraParamsIdxs(const int model_id); +const std::vector& CameraModelFocalLengthIdxs(int model_id); +const std::vector& CameraModelPrincipalPointIdxs(int model_id); +const std::vector& CameraModelExtraParamsIdxs(int model_id); // Get the total number of parameters of a camera model. -size_t CameraModelNumParams(const int model_id); +size_t CameraModelNumParams(int model_id); // Check whether parameters are valid, i.e. the parameter vector has // the correct dimensions that match the specified camera model. // // @param model_id Unique identifier of camera model. // @param params Array of camera parameters. -bool CameraModelVerifyParams(const int model_id, - const std::vector& params); +bool CameraModelVerifyParams(int model_id, const std::vector& params); // Check whether camera has bogus parameters. // @@ -414,13 +411,13 @@ bool CameraModelVerifyParams(const int model_id, // @param min_focal_length_ratio Maximum ratio of focal length over // maximum sensor dimension. // @param max_extra_param Maximum magnitude of each extra parameter. -bool CameraModelHasBogusParams(const int model_id, +bool CameraModelHasBogusParams(int model_id, const std::vector& params, - const size_t width, - const size_t height, - const double min_focal_length_ratio, - const double max_focal_length_ratio, - const double max_extra_param); + size_t width, + size_t height, + double min_focal_length_ratio, + double max_focal_length_ratio, + double max_extra_param); // Transform world coordinates in camera coordinate system to image coordinates. // @@ -431,10 +428,10 @@ bool CameraModelHasBogusParams(const int model_id, // @param params Array of camera parameters. // @param u, v Coordinates in camera system as (u, v, 1). // @param x, y Output image coordinates in pixels. -inline void CameraModelWorldToImage(const int model_id, +inline void CameraModelWorldToImage(int model_id, const std::vector& params, - const double u, - const double v, + double u, + double v, double* x, double* y); @@ -446,10 +443,10 @@ inline void CameraModelWorldToImage(const int model_id, // @param params Array of camera parameters. // @param x, y Image coordinates in pixels. // @param v, u Output Coordinates in camera system as (u, v, 1). -inline void CameraModelImageToWorld(const int model_id, +inline void CameraModelImageToWorld(int model_id, const std::vector& params, - const double x, - const double y, + double x, + double y, double* u, double* v); @@ -462,9 +459,7 @@ inline void CameraModelImageToWorld(const int model_id, // // @ return World space threshold. inline double CameraModelImageToWorldThreshold( - const int model_id, - const std::vector& params, - const double threshold); + int model_id, const std::vector& params, double threshold); //////////////////////////////////////////////////////////////////////////////// // Implementation @@ -482,23 +477,13 @@ bool BaseCameraModel::HasBogusParams( const T min_focal_length_ratio, const T max_focal_length_ratio, const T max_extra_param) { - if (HasBogusPrincipalPoint(params, width, height)) { - return true; - } - - if (HasBogusFocalLength(params, - width, - height, - min_focal_length_ratio, - max_focal_length_ratio)) { - return true; - } - - if (HasBogusExtraParams(params, max_extra_param)) { - return true; - } - - return false; + return HasBogusPrincipalPoint(params, width, height) || + HasBogusFocalLength(params, + width, + height, + min_focal_length_ratio, + max_focal_length_ratio) || + HasBogusExtraParams(params, max_extra_param); } template @@ -509,10 +494,9 @@ bool BaseCameraModel::HasBogusFocalLength( const size_t height, const T min_focal_length_ratio, const T max_focal_length_ratio) { - const size_t max_size = std::max(width, height); - + const T inv_max_size = 1.0 / std::max(width, height); for (const auto& idx : CameraModel::focal_length_idxs) { - const T focal_length_ratio = params[idx] / max_size; + const T focal_length_ratio = params[idx] * inv_max_size; if (focal_length_ratio < min_focal_length_ratio || focal_length_ratio > max_focal_length_ratio) { return true; diff --git a/src/colmap/estimators/coordinate_frame.h b/src/colmap/estimators/coordinate_frame.h index b02e7949a7..9d1566eeef 100644 --- a/src/colmap/estimators/coordinate_frame.h +++ b/src/colmap/estimators/coordinate_frame.h @@ -54,8 +54,7 @@ struct ManhattanWorldFrameEstimationOptions { // the majority of images is assumed to have the gravity vector aligned with an // upright image plane. Eigen::Vector3d EstimateGravityVectorFromImageOrientation( - const Reconstruction& reconstruction, - const double max_axis_distance = 0.05); + const Reconstruction& reconstruction, double max_axis_distance = 0.05); // Estimate the coordinate frame of the reconstruction assuming a Manhattan // world by finding the major vanishing points in each image. This function diff --git a/src/colmap/estimators/triangulation.h b/src/colmap/estimators/triangulation.h index 05ad517824..f8852e1414 100644 --- a/src/colmap/estimators/triangulation.h +++ b/src/colmap/estimators/triangulation.h @@ -85,8 +85,8 @@ class TriangulationEstimator { typedef Eigen::Vector3d M_t; // Specify settings for triangulation estimator. - void SetMinTriAngle(const double min_tri_angle); - void SetResidualType(const ResidualType residual_type); + void SetMinTriAngle(double min_tri_angle); + void SetResidualType(ResidualType residual_type); // The minimum number of samples needed to estimate a model. static const int kMinNumSamples = 2; diff --git a/src/colmap/estimators/two_view_geometry.h b/src/colmap/estimators/two_view_geometry.h index ceb4ac985e..055797fe20 100644 --- a/src/colmap/estimators/two_view_geometry.h +++ b/src/colmap/estimators/two_view_geometry.h @@ -241,7 +241,7 @@ struct TwoViewGeometry { const std::vector& points1, const Camera& camera2, const std::vector& points2, - const size_t num_inliers, + size_t num_inliers, const std::vector& inlier_mask, const Options& options); diff --git a/src/colmap/exe/sfm.h b/src/colmap/exe/sfm.h index 82d023d36c..c61738534a 100644 --- a/src/colmap/exe/sfm.h +++ b/src/colmap/exe/sfm.h @@ -41,7 +41,7 @@ int RunPointTriangulatorImpl(Reconstruction& reconstruction, const std::string& image_path, const std::string& output_path, const IncrementalMapperOptions& mapper_options, - const bool clear_points); + bool clear_points); int RunAutomaticReconstructor(int argc, char** argv); int RunBundleAdjuster(int argc, char** argv); diff --git a/src/colmap/feature/extraction.h b/src/colmap/feature/extraction.h index 4a55a37433..09df675798 100644 --- a/src/colmap/feature/extraction.h +++ b/src/colmap/feature/extraction.h @@ -103,7 +103,7 @@ struct ImageData { class ImageResizerThread : public Thread { public: - ImageResizerThread(const int max_image_size, + ImageResizerThread(int max_image_size, JobQueue* input_queue, JobQueue* output_queue); @@ -137,7 +137,7 @@ class SiftFeatureExtractorThread : public Thread { class FeatureWriterThread : public Thread { public: - FeatureWriterThread(const size_t num_images, + FeatureWriterThread(size_t num_images, Database* database, JobQueue* input_queue); diff --git a/src/colmap/feature/matching.h b/src/colmap/feature/matching.h index 25b81b509a..81429356a1 100644 --- a/src/colmap/feature/matching.h +++ b/src/colmap/feature/matching.h @@ -180,32 +180,32 @@ using FeatureDescriptorsPtr = std::shared_ptr; // Cache for feature matching to minimize database access during matching. class FeatureMatcherCache { public: - FeatureMatcherCache(const size_t cache_size, const Database* database); + FeatureMatcherCache(size_t cache_size, const Database* database); void Setup(); - const Camera& GetCamera(const camera_t camera_id) const; - const Image& GetImage(const image_t image_id) const; - FeatureKeypointsPtr GetKeypoints(const image_t image_id); - FeatureDescriptorsPtr GetDescriptors(const image_t image_id); - FeatureMatches GetMatches(const image_t image_id1, const image_t image_id2); + const Camera& GetCamera(camera_t camera_id) const; + const Image& GetImage(image_t image_id) const; + FeatureKeypointsPtr GetKeypoints(image_t image_id); + FeatureDescriptorsPtr GetDescriptors(image_t image_id); + FeatureMatches GetMatches(image_t image_id1, image_t image_id2); std::vector GetImageIds() const; - bool ExistsKeypoints(const image_t image_id); - bool ExistsDescriptors(const image_t image_id); + bool ExistsKeypoints(image_t image_id); + bool ExistsDescriptors(image_t image_id); - bool ExistsMatches(const image_t image_id1, const image_t image_id2); - bool ExistsInlierMatches(const image_t image_id1, const image_t image_id2); + bool ExistsMatches(image_t image_id1, image_t image_id2); + bool ExistsInlierMatches(image_t image_id1, image_t image_id2); - void WriteMatches(const image_t image_id1, - const image_t image_id2, + void WriteMatches(image_t image_id1, + image_t image_id2, const FeatureMatches& matches); - void WriteTwoViewGeometry(const image_t image_id1, - const image_t image_id2, + void WriteTwoViewGeometry(image_t image_id1, + image_t image_id2, const TwoViewGeometry& two_view_geometry); - void DeleteMatches(const image_t image_id1, const image_t image_id2); - void DeleteInlierMatches(const image_t image_id1, const image_t image_id2); + void DeleteMatches(image_t image_id1, image_t image_id2); + void DeleteInlierMatches(image_t image_id1, image_t image_id2); private: const size_t cache_size_; @@ -224,7 +224,7 @@ class FeatureMatcherThread : public Thread { FeatureMatcherThread(const SiftMatchingOptions& options, FeatureMatcherCache* cache); - void SetMaxNumMatches(const int max_num_matches); + void SetMaxNumMatches(int max_num_matches); protected: SiftMatchingOptions options_; @@ -261,8 +261,8 @@ class SiftGPUFeatureMatcher : public FeatureMatcherThread { protected: void Run() override; - void GetDescriptorData(const int index, - const image_t image_id, + void GetDescriptorData(int index, + image_t image_id, const FeatureDescriptors** descriptors_ptr); JobQueue* input_queue_; @@ -305,8 +305,8 @@ class GuidedSiftGPUFeatureMatcher : public FeatureMatcherThread { private: void Run() override; - void GetFeatureData(const int index, - const image_t image_id, + void GetFeatureData(int index, + image_t image_id, const FeatureKeypoints** keypoints_ptr, const FeatureDescriptors** descriptors_ptr); diff --git a/src/colmap/feature/types.h b/src/colmap/feature/types.h index 26d582a8f4..8d01c21c03 100644 --- a/src/colmap/feature/types.h +++ b/src/colmap/feature/types.h @@ -41,28 +41,20 @@ namespace colmap { struct FeatureKeypoint { FeatureKeypoint(); - FeatureKeypoint(const float x, const float y); - FeatureKeypoint(const float x, - const float y, - const float scale, - const float orientation); - FeatureKeypoint(const float x, - const float y, - const float a11, - const float a12, - const float a21, - const float a22); - - static FeatureKeypoint FromParameters(const float x, - const float y, - const float scale_x, - const float scale_y, - const float orientation, - const float shear); + FeatureKeypoint(float x, float y); + FeatureKeypoint(float x, float y, float scale, float orientation); + FeatureKeypoint(float x, float y, float a11, float a12, float a21, float a22); + + static FeatureKeypoint FromParameters(float x, + float y, + float scale_x, + float scale_y, + float orientation, + float shear); // Rescale the feature location and shape size by the given scale factor. - void Rescale(const float scale); - void Rescale(const float scale_x, const float scale_y); + void Rescale(float scale); + void Rescale(float scale_x, float scale_y); // Compute similarity shape parameters from affine shape. float ComputeScale() const; diff --git a/src/colmap/feature/utils.h b/src/colmap/feature/utils.h index fa82d1e66c..99b652ed26 100644 --- a/src/colmap/feature/utils.h +++ b/src/colmap/feature/utils.h @@ -59,6 +59,6 @@ FeatureDescriptors FeatureDescriptorsToUnsignedByte( // Extract the descriptors corresponding to the largest-scale features. void ExtractTopScaleFeatures(FeatureKeypoints* keypoints, FeatureDescriptors* descriptors, - const size_t num_features); + size_t num_features); } // namespace colmap diff --git a/src/colmap/geometry/essential_matrix.h b/src/colmap/geometry/essential_matrix.h index df5c193db8..500299ee42 100644 --- a/src/colmap/geometry/essential_matrix.h +++ b/src/colmap/geometry/essential_matrix.h @@ -126,7 +126,7 @@ void FindOptimalImageObservations(const Eigen::Matrix3d& E, // // @return Epipole in homogeneous coordinates. Eigen::Vector3d EpipoleFromEssentialMatrix(const Eigen::Matrix3d& E, - const bool left_image); + bool left_image); // Invert the essential matrix, i.e. if the essential matrix E describes the // transformation from camera A to B, the inverted essential matrix E' describes diff --git a/src/colmap/geometry/gps.h b/src/colmap/geometry/gps.h index 1ddcd29f75..1f03e40206 100644 --- a/src/colmap/geometry/gps.h +++ b/src/colmap/geometry/gps.h @@ -45,7 +45,7 @@ class GPSTransform { public: enum ELLIPSOID { GRS80, WGS84 }; - explicit GPSTransform(const int ellipsoid = GRS80); + explicit GPSTransform(int ellipsoid = GRS80); std::vector EllToXYZ( const std::vector& ell) const; @@ -56,22 +56,22 @@ class GPSTransform { // Convert GPS (lat / lon / alt) to ENU coords. with lat0 and lon0 // defining the origin of the ENU frame std::vector EllToENU(const std::vector& ell, - const double lat0, - const double lon0) const; + double lat0, + double lon0) const; std::vector XYZToENU(const std::vector& xyz, - const double lat0, - const double lon0) const; + double lat0, + double lon0) const; std::vector ENUToEll(const std::vector& enu, - const double lat0, - const double lon0, - const double alt0) const; + double lat0, + double lon0, + double alt0) const; std::vector ENUToXYZ(const std::vector& enu, - const double lat0, - const double lon0, - const double alt0) const; + double lat0, + double lon0, + double alt0) const; private: // Semimajor axis. diff --git a/src/colmap/geometry/homography_matrix.h b/src/colmap/geometry/homography_matrix.h index 9e8f4dedaa..078e08b46a 100644 --- a/src/colmap/geometry/homography_matrix.h +++ b/src/colmap/geometry/homography_matrix.h @@ -103,6 +103,6 @@ Eigen::Matrix3d HomographyMatrixFromPose(const Eigen::Matrix3d& K1, const Eigen::Matrix3d& R, const Eigen::Vector3d& t, const Eigen::Vector3d& n, - const double d); + double d); } // namespace colmap diff --git a/src/colmap/geometry/pose.h b/src/colmap/geometry/pose.h index 71d1fcc8d7..428ad3c715 100644 --- a/src/colmap/geometry/pose.h +++ b/src/colmap/geometry/pose.h @@ -62,9 +62,7 @@ void RotationMatrixToEulerAngles(const Eigen::Matrix3d& R, // @param rx, ry, rz Euler angles in radians. // // @return 3x3 rotation matrix. -Eigen::Matrix3d EulerAnglesToRotationMatrix(const double rx, - const double ry, - const double rz); +Eigen::Matrix3d EulerAnglesToRotationMatrix(double rx, double ry, double rz); // Convert 3D rotation matrix to Quaternion representation. // @@ -190,7 +188,7 @@ void InterpolatePose(const Eigen::Vector4d& qvec1, const Eigen::Vector3d& tvec1, const Eigen::Vector4d& qvec2, const Eigen::Vector3d& tvec2, - const double t, + double t, Eigen::Vector4d* qveci, Eigen::Vector3d* tveci); diff --git a/src/colmap/geometry/similarity_transform.h b/src/colmap/geometry/similarity_transform.h index 52cc0f5890..4bda50248e 100644 --- a/src/colmap/geometry/similarity_transform.h +++ b/src/colmap/geometry/similarity_transform.h @@ -54,7 +54,7 @@ class SimilarityTransform3 { explicit SimilarityTransform3( const Eigen::Transform& transform); - SimilarityTransform3(const double scale, + SimilarityTransform3(double scale, const Eigen::Vector4d& qvec, const Eigen::Vector3d& tvec); @@ -89,8 +89,8 @@ class SimilarityTransform3 { bool ComputeAlignmentBetweenReconstructions( const Reconstruction& src_reconstruction, const Reconstruction& ref_reconstruction, - const double min_inlier_observations, - const double max_reproj_error, + double min_inlier_observations, + double max_reproj_error, Eigen::Matrix3x4d* alignment); // Robustly compute alignment between reconstructions by finding images that @@ -100,7 +100,7 @@ bool ComputeAlignmentBetweenReconstructions( bool ComputeAlignmentBetweenReconstructions( const Reconstruction& src_reconstruction, const Reconstruction& ref_reconstruction, - const double max_proj_center_error, + double max_proj_center_error, Eigen::Matrix3x4d* alignment); //////////////////////////////////////////////////////////////////////////////// diff --git a/src/colmap/image/bitmap.h b/src/colmap/image/bitmap.h index a2d5d7c51e..39061268f5 100644 --- a/src/colmap/image/bitmap.h +++ b/src/colmap/image/bitmap.h @@ -53,8 +53,8 @@ namespace colmap { template struct BitmapColor { BitmapColor(); - explicit BitmapColor(const T gray); - BitmapColor(const T r, const T g, const T b); + explicit BitmapColor(T gray); + BitmapColor(T r, T g, T b); template BitmapColor Cast() const; @@ -91,7 +91,7 @@ class Bitmap { Bitmap& operator=(Bitmap&& other) noexcept; // Allocate bitmap by overwriting the existing data. - bool Allocate(const int width, const int height, const bool as_rgb); + bool Allocate(int width, int height, bool as_rgb); // Deallocate the bitmap by releasing the existing data. void Deallocate(); @@ -126,23 +126,21 @@ class Bitmap { // Manipulate individual pixels. For grayscale images, only the red element // of the RGB color is used. - bool GetPixel(const int x, const int y, BitmapColor* color) const; - bool SetPixel(const int x, const int y, const BitmapColor& color); + bool GetPixel(int x, int y, BitmapColor* color) const; + bool SetPixel(int x, int y, const BitmapColor& color); // Get pointer to y-th scanline, where the 0-th scanline is at the top. - const uint8_t* GetScanline(const int y) const; + const uint8_t* GetScanline(int y) const; // Fill entire bitmap with uniform color. For grayscale images, the first // element of the vector is used. void Fill(const BitmapColor& color); // Interpolate color at given floating point position. - bool InterpolateNearestNeighbor(const double x, - const double y, + bool InterpolateNearestNeighbor(double x, + double y, BitmapColor* color) const; - bool InterpolateBilinear(const double x, - const double y, - BitmapColor* color) const; + bool InterpolateBilinear(double x, double y, BitmapColor* color) const; // Extract EXIF information from bitmap. Returns false if no EXIF information // is embedded in the bitmap. @@ -153,21 +151,21 @@ class Bitmap { bool ExifAltitude(double* altitude) const; // Read bitmap at given path and convert to grey- or colorscale. - bool Read(const std::string& path, const bool as_rgb = true); + bool Read(const std::string& path, bool as_rgb = true); // Write image to file. Flags can be used to set e.g. the JPEG quality. // Consult the FreeImage documentation for all available flags. bool Write(const std::string& path, - const FREE_IMAGE_FORMAT format = FIF_UNKNOWN, - const int flags = 0) const; + FREE_IMAGE_FORMAT format = FIF_UNKNOWN, + int flags = 0) const; // Smooth the image using a Gaussian kernel. - void Smooth(const float sigma_x, const float sigma_y); + void Smooth(float sigma_x, float sigma_y); // Rescale image to the new dimensions. - void Rescale(const int new_width, - const int new_height, - const FREE_IMAGE_FILTER filter = FILTER_BILINEAR); + void Rescale(int new_width, + int new_height, + FREE_IMAGE_FILTER filter = FILTER_BILINEAR); // Clone the image to a new bitmap object. Bitmap Clone() const; @@ -178,7 +176,7 @@ class Bitmap { void CloneMetadata(Bitmap* target) const; // Read specific EXIF tag. - bool ReadExifTag(const FREE_IMAGE_MDMODEL model, + bool ReadExifTag(FREE_IMAGE_MDMODEL model, const std::string& tag_name, std::string* result) const; @@ -201,17 +199,13 @@ class Bitmap { // and are converted to RGB values in the same range. class JetColormap { public: - static float Red(const float gray); - static float Green(const float gray); - static float Blue(const float gray); + static float Red(float gray); + static float Green(float gray); + static float Blue(float gray); private: - static float Interpolate(const float val, - const float y0, - const float x0, - const float y1, - const float x1); - static float Base(const float val); + static float Interpolate(float val, float y0, float x0, float y1, float x1); + static float Base(float val); }; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/colmap/image/line.h b/src/colmap/image/line.h index 745ab3e132..86ee27699f 100644 --- a/src/colmap/image/line.h +++ b/src/colmap/image/line.h @@ -50,10 +50,10 @@ enum class LineSegmentOrientation { // Detect line segments in the given bitmap image. std::vector DetectLineSegments(const Bitmap& bitmap, - const double min_length = 3); + double min_length = 3); // Classify line segments into horizontal/vertical. std::vector ClassifyLineSegmentOrientations( - const std::vector& segments, const double tolerance = 0.25); + const std::vector& segments, double tolerance = 0.25); } // namespace colmap diff --git a/src/colmap/image/undistortion.h b/src/colmap/image/undistortion.h index 3f6bb5870d..648e471272 100644 --- a/src/colmap/image/undistortion.h +++ b/src/colmap/image/undistortion.h @@ -69,17 +69,17 @@ class COLMAPUndistorter : public Thread { const Reconstruction& reconstruction, const std::string& image_path, const std::string& output_path, - const int num_related_images = 20, - const CopyType copy_type = CopyType::COPY, + int num_related_images = 20, + CopyType copy_type = CopyType::COPY, const std::vector& image_ids = std::vector()); private: void Run(); - bool Undistort(const image_t image_id) const; + bool Undistort(image_t image_id) const; void WritePatchMatchConfig() const; void WriteFusionConfig() const; - void WriteScript(const bool geometric) const; + void WriteScript(bool geometric) const; UndistortCameraOptions options_; const std::string image_path_; @@ -102,13 +102,13 @@ class PMVSUndistorter : public Thread { private: void Run(); - bool Undistort(const size_t reg_image_idx) const; + bool Undistort(size_t reg_image_idx) const; void WriteVisibilityData() const; void WriteOptionFile() const; void WritePMVSScript() const; void WriteCMVSPMVSScript() const; - void WriteCOLMAPScript(const bool geometric) const; - void WriteCMVSCOLMAPScript(const bool geometric) const; + void WriteCOLMAPScript(bool geometric) const; + void WriteCMVSCOLMAPScript(bool geometric) const; UndistortCameraOptions options_; std::string image_path_; @@ -127,7 +127,7 @@ class CMPMVSUndistorter : public Thread { private: void Run(); - bool Undistort(const size_t reg_image_idx) const; + bool Undistort(size_t reg_image_idx) const; UndistortCameraOptions options_; std::string image_path_; @@ -149,7 +149,7 @@ class PureImageUndistorter : public Thread { private: void Run(); - bool Undistort(const size_t reg_image_idx) const; + bool Undistort(size_t reg_image_idx) const; UndistortCameraOptions options_; std::string image_path_; @@ -170,7 +170,7 @@ class StereoImageRectifier : public Thread { private: void Run(); - void Rectify(const image_t image_id1, const image_t image_id2) const; + void Rectify(image_t image_id1, image_t image_id2) const; UndistortCameraOptions options_; std::string image_path_; diff --git a/src/colmap/image/warp.h b/src/colmap/image/warp.h index e8c6d22e52..0b65ed4b20 100644 --- a/src/colmap/image/warp.h +++ b/src/colmap/image/warp.h @@ -63,26 +63,26 @@ void WarpImageWithHomographyBetweenCameras(const Eigen::Matrix3d& H, // Resample row-major image using bilinear interpolation. void ResampleImageBilinear(const float* data, - const int rows, - const int cols, - const int new_rows, - const int new_cols, + int rows, + int cols, + int new_rows, + int new_cols, float* resampled); // Smooth row-major image using a Gaussian filter kernel. void SmoothImage(const float* data, - const int rows, - const int cols, - const float sigma_r, - const float sigma_c, + int rows, + int cols, + float sigma_r, + float sigma_c, float* smoothed); // Downsample row-major image by first smoothing and then resampling. void DownsampleImage(const float* data, - const int rows, - const int cols, - const int new_rows, - const int new_cols, + int rows, + int cols, + int new_rows, + int new_cols, float* downsampled); } // namespace colmap diff --git a/src/colmap/mvs/consistency_graph.h b/src/colmap/mvs/consistency_graph.h index b896fbedec..49b0f23958 100644 --- a/src/colmap/mvs/consistency_graph.h +++ b/src/colmap/mvs/consistency_graph.h @@ -53,14 +53,12 @@ namespace mvs { class ConsistencyGraph { public: ConsistencyGraph(); - ConsistencyGraph(const size_t width, - const size_t height, - const std::vector& data); + ConsistencyGraph(size_t width, size_t height, const std::vector& data); size_t GetNumBytes() const; - void GetImageIdxs(const int row, - const int col, + void GetImageIdxs(int row, + int col, int* num_images, const int** image_idxs) const; @@ -68,7 +66,7 @@ class ConsistencyGraph { void Write(const std::string& path) const; private: - void InitializeMap(const size_t width, const size_t height); + void InitializeMap(size_t width, size_t height); const static int kNoConsistentImageIds; std::vector data_; diff --git a/src/colmap/mvs/depth_map.h b/src/colmap/mvs/depth_map.h index bef92c120a..91de7d8775 100644 --- a/src/colmap/mvs/depth_map.h +++ b/src/colmap/mvs/depth_map.h @@ -43,21 +43,18 @@ namespace mvs { class DepthMap : public Mat { public: DepthMap(); - DepthMap(const size_t width, - const size_t height, - const float depth_min, - const float depth_max); - DepthMap(const Mat& mat, const float depth_min, const float depth_max); + DepthMap(size_t width, size_t height, float depth_min, float depth_max); + DepthMap(const Mat& mat, float depth_min, float depth_max); inline float GetDepthMin() const; inline float GetDepthMax() const; - inline float Get(const size_t row, const size_t col) const; + inline float Get(size_t row, size_t col) const; - void Rescale(const float factor); - void Downsize(const size_t max_width, const size_t max_height); + void Rescale(float factor); + void Downsize(size_t max_width, size_t max_height); - Bitmap ToBitmap(const float min_percentile, const float max_percentile) const; + Bitmap ToBitmap(float min_percentile, float max_percentile) const; private: float depth_min_ = -1.0f; diff --git a/src/colmap/mvs/fusion.h b/src/colmap/mvs/fusion.h index 8c98a6df95..b8b3f5b8c8 100644 --- a/src/colmap/mvs/fusion.h +++ b/src/colmap/mvs/fusion.h @@ -117,10 +117,7 @@ class StereoFusion : public Thread { private: void Run(); void InitFusedPixelMask(int image_idx, size_t width, size_t height); - void Fuse(const int thread_id, - const int image_idx, - const int row, - const int col); + void Fuse(int thread_id, int image_idx, int row, int col); const StereoFusionOptions options_; const std::string workspace_path_; diff --git a/src/colmap/mvs/image.h b/src/colmap/mvs/image.h index 979e865156..0e6f97efea 100644 --- a/src/colmap/mvs/image.h +++ b/src/colmap/mvs/image.h @@ -47,8 +47,8 @@ class Image { public: Image(); Image(const std::string& path, - const size_t width, - const size_t height, + size_t width, + size_t height, const float* K, const float* R, const float* T); @@ -67,9 +67,9 @@ class Image { inline const float* GetInvP() const; inline const float* GetViewingDirection() const; - void Rescale(const float factor); - void Rescale(const float factor_x, const float factor_y); - void Downsize(const size_t max_width, const size_t max_height); + void Rescale(float factor); + void Rescale(float factor_x, float factor_y); + void Downsize(size_t max_width, size_t max_height); private: std::string path_; diff --git a/src/colmap/mvs/mat.h b/src/colmap/mvs/mat.h index b71576524a..1def609834 100644 --- a/src/colmap/mvs/mat.h +++ b/src/colmap/mvs/mat.h @@ -45,7 +45,7 @@ template class Mat { public: Mat(); - Mat(const size_t width, const size_t height, const size_t depth); + Mat(size_t width, size_t height, size_t depth); size_t GetWidth() const; size_t GetHeight() const; @@ -53,20 +53,17 @@ class Mat { size_t GetNumBytes() const; - T Get(const size_t row, const size_t col, const size_t slice = 0) const; - void GetSlice(const size_t row, const size_t col, T* values) const; + T Get(size_t row, size_t col, size_t slice = 0) const; + void GetSlice(size_t row, size_t col, T* values) const; T* GetPtr(); const T* GetPtr() const; const std::vector& GetData() const; - void Set(const size_t row, const size_t col, const T value); - void Set(const size_t row, - const size_t col, - const size_t slice, - const T value); + void Set(size_t row, size_t col, T value); + void Set(size_t row, size_t col, size_t slice, T value); - void Fill(const T value); + void Fill(T value); void Read(const std::string& path); void Write(const std::string& path) const; diff --git a/src/colmap/mvs/model.h b/src/colmap/mvs/model.h index 94f65e3ea2..79529ed0ff 100644 --- a/src/colmap/mvs/model.h +++ b/src/colmap/mvs/model.h @@ -64,13 +64,13 @@ struct Model { // Get the image index for the given image name. int GetImageIdx(const std::string& name) const; - std::string GetImageName(const int image_idx) const; + std::string GetImageName(int image_idx) const; // For each image, determine the maximally overlapping images, sorted based on // the number of shared points subject to a minimum robust average // triangulation angle of the points. std::vector> GetMaxOverlappingImages( - const size_t num_images, const double min_triangulation_angle) const; + size_t num_images, double min_triangulation_angle) const; // Get the overlapping images defined in the vis.dat file. const std::vector>& GetMaxOverlappingImagesFromPMVS() const; @@ -83,7 +83,7 @@ struct Model { // Compute the median triangulation angles between all overlapping images. std::vector> ComputeTriangulationAngles( - const float percentile = 50) const; + float percentile = 50) const; // Note that in case the data is read from a COLMAP reconstruction, the index // of an image or point does not correspond to its original identifier in the diff --git a/src/colmap/mvs/normal_map.h b/src/colmap/mvs/normal_map.h index dde154cd1d..3c94ae4775 100644 --- a/src/colmap/mvs/normal_map.h +++ b/src/colmap/mvs/normal_map.h @@ -44,11 +44,11 @@ namespace mvs { class NormalMap : public Mat { public: NormalMap(); - NormalMap(const size_t width, const size_t height); + NormalMap(size_t width, size_t height); explicit NormalMap(const Mat& mat); - void Rescale(const float factor); - void Downsize(const size_t max_width, const size_t max_height); + void Rescale(float factor); + void Downsize(size_t max_width, size_t max_height); Bitmap ToBitmap() const; }; diff --git a/src/colmap/mvs/patch_match.h b/src/colmap/mvs/patch_match.h index 0476f4f34f..32c057851d 100644 --- a/src/colmap/mvs/patch_match.h +++ b/src/colmap/mvs/patch_match.h @@ -260,8 +260,7 @@ class PatchMatchController : public Thread { void ReadWorkspace(); void ReadProblems(); void ReadGpuIndices(); - void ProcessProblem(const PatchMatchOptions& options, - const size_t problem_idx); + void ProcessProblem(const PatchMatchOptions& options, size_t problem_idx); const PatchMatchOptions options_; const std::string workspace_path_; diff --git a/src/colmap/mvs/workspace.h b/src/colmap/mvs/workspace.h index 773a022752..47dd990953 100644 --- a/src/colmap/mvs/workspace.h +++ b/src/colmap/mvs/workspace.h @@ -74,22 +74,22 @@ class Workspace { inline const Model& GetModel() const { return model_; } - virtual const Bitmap& GetBitmap(const int image_idx); - virtual const DepthMap& GetDepthMap(const int image_idx); - virtual const NormalMap& GetNormalMap(const int image_idx); + virtual const Bitmap& GetBitmap(int image_idx); + virtual const DepthMap& GetDepthMap(int image_idx); + virtual const NormalMap& GetNormalMap(int image_idx); // Get paths to bitmap, depth map, normal map and consistency graph. - std::string GetBitmapPath(const int image_idx) const; - std::string GetDepthMapPath(const int image_idx) const; - std::string GetNormalMapPath(const int image_idx) const; + std::string GetBitmapPath(int image_idx) const; + std::string GetDepthMapPath(int image_idx) const; + std::string GetNormalMapPath(int image_idx) const; // Return whether bitmap, depth map, normal map, and consistency graph exist. - bool HasBitmap(const int image_idx) const; - bool HasDepthMap(const int image_idx) const; - bool HasNormalMap(const int image_idx) const; + bool HasBitmap(int image_idx) const; + bool HasDepthMap(int image_idx) const; + bool HasNormalMap(int image_idx) const; protected: - std::string GetFileName(const int image_idx) const; + std::string GetFileName(int image_idx) const; Options options_; Model model_; @@ -110,9 +110,9 @@ class CachedWorkspace : public Workspace { inline void ClearCache() { cache_.Clear(); } - const Bitmap& GetBitmap(const int image_idx) override; - const DepthMap& GetDepthMap(const int image_idx) override; - const NormalMap& GetNormalMap(const int image_idx) override; + const Bitmap& GetBitmap(int image_idx) override; + const DepthMap& GetDepthMap(int image_idx) override; + const NormalMap& GetNormalMap(int image_idx) override; private: class CachedImage { diff --git a/src/colmap/optim/bundle_adjustment.h b/src/colmap/optim/bundle_adjustment.h index 1000d37829..d68945673b 100644 --- a/src/colmap/optim/bundle_adjustment.h +++ b/src/colmap/optim/bundle_adjustment.h @@ -113,45 +113,45 @@ class BundleAdjustmentConfig { size_t NumResiduals(const Reconstruction& reconstruction) const; // Add / remove images from the configuration. - void AddImage(const image_t image_id); - bool HasImage(const image_t image_id) const; - void RemoveImage(const image_t image_id); + void AddImage(image_t image_id); + bool HasImage(image_t image_id) const; + void RemoveImage(image_t image_id); // Set cameras of added images as constant or variable. By default all // cameras of added images are variable. Note that the corresponding images // have to be added prior to calling these methods. - void SetConstantCamera(const camera_t camera_id); - void SetVariableCamera(const camera_t camera_id); - bool IsConstantCamera(const camera_t camera_id) const; + void SetConstantCamera(camera_t camera_id); + void SetVariableCamera(camera_t camera_id); + bool IsConstantCamera(camera_t camera_id) const; // Set the pose of added images as constant. The pose is defined as the // rotational and translational part of the projection matrix. - void SetConstantPose(const image_t image_id); - void SetVariablePose(const image_t image_id); - bool HasConstantPose(const image_t image_id) const; + void SetConstantPose(image_t image_id); + void SetVariablePose(image_t image_id); + bool HasConstantPose(image_t image_id) const; // Set the translational part of the pose, hence the constant pose // indices may be in [0, 1, 2] and must be unique. Note that the // corresponding images have to be added prior to calling these methods. - void SetConstantTvec(const image_t image_id, const std::vector& idxs); - void RemoveConstantTvec(const image_t image_id); - bool HasConstantTvec(const image_t image_id) const; + void SetConstantTvec(image_t image_id, const std::vector& idxs); + void RemoveConstantTvec(image_t image_id); + bool HasConstantTvec(image_t image_id) const; // Add / remove points from the configuration. Note that points can either // be variable or constant but not both at the same time. - void AddVariablePoint(const point3D_t point3D_id); - void AddConstantPoint(const point3D_t point3D_id); - bool HasPoint(const point3D_t point3D_id) const; - bool HasVariablePoint(const point3D_t point3D_id) const; - bool HasConstantPoint(const point3D_t point3D_id) const; - void RemoveVariablePoint(const point3D_t point3D_id); - void RemoveConstantPoint(const point3D_t point3D_id); + void AddVariablePoint(point3D_t point3D_id); + void AddConstantPoint(point3D_t point3D_id); + bool HasPoint(point3D_t point3D_id) const; + bool HasVariablePoint(point3D_t point3D_id) const; + bool HasConstantPoint(point3D_t point3D_id) const; + void RemoveVariablePoint(point3D_t point3D_id); + void RemoveConstantPoint(point3D_t point3D_id); // Access configuration data. const std::unordered_set& Images() const; const std::unordered_set& VariablePoints() const; const std::unordered_set& ConstantPoints() const; - const std::vector& ConstantTvec(const image_t image_id) const; + const std::vector& ConstantTvec(image_t image_id) const; private: std::unordered_set constant_camera_ids_; @@ -179,11 +179,11 @@ class BundleAdjuster { ceres::LossFunction* loss_function); void TearDown(Reconstruction* reconstruction); - void AddImageToProblem(const image_t image_id, + void AddImageToProblem(image_t image_id, Reconstruction* reconstruction, ceres::LossFunction* loss_function); - void AddPointToProblem(const point3D_t point3D_id, + void AddPointToProblem(point3D_t point3D_id, Reconstruction* reconstruction, ceres::LossFunction* loss_function); @@ -227,12 +227,12 @@ class RigBundleAdjuster : public BundleAdjuster { void TearDown(Reconstruction* reconstruction, const std::vector& camera_rigs); - void AddImageToProblem(const image_t image_id, + void AddImageToProblem(image_t image_id, Reconstruction* reconstruction, std::vector* camera_rigs, ceres::LossFunction* loss_function); - void AddPointToProblem(const point3D_t point3D_id, + void AddPointToProblem(point3D_t point3D_id, Reconstruction* reconstruction, ceres::LossFunction* loss_function); diff --git a/src/colmap/optim/combination_sampler.h b/src/colmap/optim/combination_sampler.h index 1e7600afe0..a53cbb0702 100644 --- a/src/colmap/optim/combination_sampler.h +++ b/src/colmap/optim/combination_sampler.h @@ -41,9 +41,9 @@ namespace colmap { // that the input data is shuffled in advance. class CombinationSampler : public Sampler { public: - explicit CombinationSampler(const size_t num_samples); + explicit CombinationSampler(size_t num_samples); - void Initialize(const size_t total_num_samples) override; + void Initialize(size_t total_num_samples) override; size_t MaxNumSamples() override; diff --git a/src/colmap/optim/progressive_sampler.h b/src/colmap/optim/progressive_sampler.h index 5740344a04..e178b6a965 100644 --- a/src/colmap/optim/progressive_sampler.h +++ b/src/colmap/optim/progressive_sampler.h @@ -46,9 +46,9 @@ namespace colmap { // front of the list. class ProgressiveSampler : public Sampler { public: - explicit ProgressiveSampler(const size_t num_samples); + explicit ProgressiveSampler(size_t num_samples); - void Initialize(const size_t total_num_samples) override; + void Initialize(size_t total_num_samples) override; size_t MaxNumSamples() override; diff --git a/src/colmap/optim/random_sampler.h b/src/colmap/optim/random_sampler.h index c5564234cf..4fff97d298 100644 --- a/src/colmap/optim/random_sampler.h +++ b/src/colmap/optim/random_sampler.h @@ -40,9 +40,9 @@ namespace colmap { // Note that a separate sampler should be instantiated per thread. class RandomSampler : public Sampler { public: - explicit RandomSampler(const size_t num_samples); + explicit RandomSampler(size_t num_samples); - void Initialize(const size_t total_num_samples) override; + void Initialize(size_t total_num_samples) override; size_t MaxNumSamples() override; diff --git a/src/colmap/optim/ransac.h b/src/colmap/optim/ransac.h index 387738dc73..44565a51b0 100644 --- a/src/colmap/optim/ransac.h +++ b/src/colmap/optim/ransac.h @@ -109,10 +109,10 @@ class RANSAC { // number of trials. // // @return The required number of iterations. - static size_t ComputeNumTrials(const size_t num_inliers, - const size_t num_samples, - const double confidence, - const double num_trials_multiplier); + static size_t ComputeNumTrials(size_t num_inliers, + size_t num_samples, + double confidence, + double num_trials_multiplier); // Robustly estimate model with RANSAC (RANdom SAmple Consensus). // diff --git a/src/colmap/optim/sampler.h b/src/colmap/optim/sampler.h index 2e9c0f3f94..eca9cb554c 100644 --- a/src/colmap/optim/sampler.h +++ b/src/colmap/optim/sampler.h @@ -42,11 +42,11 @@ namespace colmap { class Sampler { public: Sampler() = default; - explicit Sampler(const size_t num_samples); + explicit Sampler(size_t num_samples); virtual ~Sampler() = default; // Initialize the sampler, before calling the `Sample` method. - virtual void Initialize(const size_t total_num_samples) = 0; + virtual void Initialize(size_t total_num_samples) = 0; // Maximum number of unique samples that can be generated. virtual size_t MaxNumSamples() = 0; diff --git a/src/colmap/optim/sprt.h b/src/colmap/optim/sprt.h index 7dc14d2af2..9c48414cfd 100644 --- a/src/colmap/optim/sprt.h +++ b/src/colmap/optim/sprt.h @@ -66,7 +66,7 @@ class SPRT { void Update(const Options& options); bool Evaluate(const std::vector& residuals, - const double max_residual, + double max_residual, size_t* num_inliers, size_t* num_eval_samples); diff --git a/src/colmap/optim/support_measurement.h b/src/colmap/optim/support_measurement.h index abe757a859..f4356c7c02 100644 --- a/src/colmap/optim/support_measurement.h +++ b/src/colmap/optim/support_measurement.h @@ -50,8 +50,7 @@ struct InlierSupportMeasurer { }; // Compute the support of the residuals. - Support Evaluate(const std::vector& residuals, - const double max_residual); + Support Evaluate(const std::vector& residuals, double max_residual); // Compare the two supports and return the better support. bool Compare(const Support& support1, const Support& support2); @@ -69,8 +68,7 @@ struct MEstimatorSupportMeasurer { }; // Compute the support of the residuals. - Support Evaluate(const std::vector& residuals, - const double max_residual); + Support Evaluate(const std::vector& residuals, double max_residual); // Compare the two supports and return the better support. bool Compare(const Support& support1, const Support& support2); diff --git a/src/colmap/retrieval/inverted_file.h b/src/colmap/retrieval/inverted_file.h index 3b3d579832..9e1fc61ce6 100644 --- a/src/colmap/retrieval/inverted_file.h +++ b/src/colmap/retrieval/inverted_file.h @@ -90,7 +90,7 @@ class InvertedFile { // information stored in an inverted file entry. In particular, this function // generates the binary descriptor for the inverted file entry and then stores // the entry in the inverted file. - void AddEntry(const int image_id, + void AddEntry(int image_id, typename DescType::Index feature_idx, const DescType& descriptor, const GeomType& geometry); @@ -111,7 +111,7 @@ class InvertedFile { std::bitset* binary_descriptor) const; // Compute the idf-weight for this inverted file. - void ComputeIDFWeight(const int num_total_images); + void ComputeIDFWeight(int num_total_images); // Return the idf-weight of this inverted file. float IDFWeight() const; diff --git a/src/colmap/retrieval/inverted_index.h b/src/colmap/retrieval/inverted_index.h index 4307e92e04..d055bee9b0 100644 --- a/src/colmap/retrieval/inverted_index.h +++ b/src/colmap/retrieval/inverted_index.h @@ -68,7 +68,7 @@ class InvertedIndex { int NumVisualWords() const; // Initializes the inverted index with num_words empty inverted files. - void Initialize(const int num_words); + void Initialize(int num_words); // Finalizes the inverted index by sorting each inverted file such that all // entries are in ascending order of image ids. @@ -83,8 +83,8 @@ class InvertedIndex { const Eigen::VectorXi& word_ids); // Add single entry to the index. - void AddEntry(const int image_id, - const int word_id, + void AddEntry(int image_id, + int word_id, typename DescType::Index feature_idx, const DescType& descriptor, const GeomType& geometry); @@ -98,13 +98,13 @@ class InvertedIndex { std::vector* image_scores) const; void ConvertToBinaryDescriptor( - const int word_id, + int word_id, const DescType& descriptor, std::bitset* binary_descriptor) const; - float GetIDFWeight(const int word_id) const; + float GetIDFWeight(int word_id) const; - void FindMatches(const int word_id, + void FindMatches(int word_id, const std::unordered_set& image_ids, std::vector* matches) const; diff --git a/src/colmap/retrieval/visual_index.h b/src/colmap/retrieval/visual_index.h index a03c3e48eb..7a1bc48b79 100644 --- a/src/colmap/retrieval/visual_index.h +++ b/src/colmap/retrieval/visual_index.h @@ -123,12 +123,12 @@ class VisualIndex { // Add image to the visual index. void Add(const IndexOptions& options, - const int image_id, + int image_id, const GeomType& geometries, const DescType& descriptors); // Check if an image has been indexed. - bool ImageIndexed(const int image_id) const; + bool ImageIndexed(int image_id) const; // Query for most similar images in the visual index. void Query(const QueryOptions& options, @@ -166,9 +166,9 @@ class VisualIndex { // Find the nearest neighbor visual words for the given descriptors. Eigen::MatrixXi FindWordIds(const DescType& descriptors, - const int num_neighbors, - const int num_checks, - const int num_threads) const; + int num_neighbors, + int num_checks, + int num_threads) const; // The search structure on the quantized descriptor space. flann::AutotunedIndex> visual_word_index_; diff --git a/src/colmap/sfm/incremental_mapper.h b/src/colmap/sfm/incremental_mapper.h index 127a39dbae..55882de87a 100644 --- a/src/colmap/sfm/incremental_mapper.h +++ b/src/colmap/sfm/incremental_mapper.h @@ -151,7 +151,7 @@ class IncrementalMapper { // Cleanup the mapper after the current reconstruction is done. If the // model is discarded, the number of total and shared registered images will // be updated accordingly. - void EndReconstruction(const bool discard); + void EndReconstruction(bool discard); // Find initial image pair to seed the incremental reconstruction. The image // pairs should be passed to `RegisterInitialImagePair`. This function @@ -167,16 +167,16 @@ class IncrementalMapper { // Attempt to seed the reconstruction from an image pair. bool RegisterInitialImagePair(const Options& options, - const image_t image_id1, - const image_t image_id2); + image_t image_id1, + image_t image_id2); // Attempt to register image to the existing model. This requires that // a previous call to `RegisterInitialImagePair` was successful. - bool RegisterNextImage(const Options& options, const image_t image_id); + bool RegisterNextImage(const Options& options, image_t image_id); // Triangulate observations of image. size_t TriangulateImage(const IncrementalTriangulator::Options& tri_options, - const image_t image_id); + image_t image_id); // Retriangulate image pairs that should have common observations according to // the scene graph but don't due to drift, etc. To handle drift, the employed @@ -205,7 +205,7 @@ class IncrementalMapper { const Options& options, const BundleAdjustmentOptions& ba_options, const IncrementalTriangulator::Options& tri_options, - const image_t image_id, + image_t image_id, const std::unordered_set& point3D_ids); // Global bundle adjustment using Ceres Solver. @@ -242,22 +242,22 @@ class IncrementalMapper { // to the first image and have camera calibration priors. The returned list is // ordered such that most suitable images are in the front. std::vector FindSecondInitialImage(const Options& options, - const image_t image_id1) const; + image_t image_id1) const; // Find local bundle for given image in the reconstruction. The local bundle // is defined as the images that are most connected, i.e. maximum number of // shared 3D points, to the given image. std::vector FindLocalBundle(const Options& options, - const image_t image_id) const; + image_t image_id) const; // Register / De-register image in current reconstruction and update // the number of shared images between all reconstructions. - void RegisterImageEvent(const image_t image_id); - void DeRegisterImageEvent(const image_t image_id); + void RegisterImageEvent(image_t image_id); + void DeRegisterImageEvent(image_t image_id); bool EstimateInitialTwoViewGeometry(const Options& options, - const image_t image_id1, - const image_t image_id2); + image_t image_id1, + image_t image_id2); // Class that holds all necessary data from database in memory. const DatabaseCache* database_cache_; diff --git a/src/colmap/sfm/incremental_triangulator.h b/src/colmap/sfm/incremental_triangulator.h index 4fff4b3631..ea65c37122 100644 --- a/src/colmap/sfm/incremental_triangulator.h +++ b/src/colmap/sfm/incremental_triangulator.h @@ -97,12 +97,12 @@ class IncrementalTriangulator { // // Note that the given image must be registered and its pose must be set // in the associated reconstruction. - size_t TriangulateImage(const Options& options, const image_t image_id); + size_t TriangulateImage(const Options& options, image_t image_id); // Complete triangulations for image. Tries to create new tracks for not // yet triangulated observations and tries to complete existing tracks. // Returns the number of completed observations. - size_t CompleteImage(const Options& options, const image_t image_id); + size_t CompleteImage(const Options& options, image_t image_id); // Complete tracks for specific 3D points. // @@ -134,7 +134,7 @@ class IncrementalTriangulator { size_t Retriangulate(const Options& options); // Indicate that a 3D point has been modified. - void AddModifiedPoint3D(const point3D_t point3D_id); + void AddModifiedPoint3D(point3D_t point3D_id); // Get changed 3D points, since the last call to `ClearModifiedPoints3D`. const std::unordered_set& GetModifiedPoints3D(); @@ -159,9 +159,9 @@ class IncrementalTriangulator { // Find (transitive) correspondences to other images. size_t Find(const Options& options, - const image_t image_id, - const point2D_t point2D_idx, - const size_t transitivity, + image_t image_id, + point2D_t point2D_idx, + size_t transitivity, std::vector* corrs_data); // Try to create a new 3D point from the given correspondences. @@ -174,10 +174,10 @@ class IncrementalTriangulator { const std::vector& corrs_data); // Try to merge 3D point with any of its corresponding 3D points. - size_t Merge(const Options& options, const point3D_t point3D_id); + size_t Merge(const Options& options, point3D_t point3D_id); // Try to transitively complete the track of a 3D point. - size_t Complete(const Options& options, const point3D_t point3D_id); + size_t Complete(const Options& options, point3D_t point3D_id); // Check if camera has bogus parameters and cache the result. bool HasCameraBogusParams(const Options& options, const Camera& camera); diff --git a/src/colmap/ui/colormaps.h b/src/colmap/ui/colormaps.h index e3adcde976..138d85dd3a 100644 --- a/src/colmap/ui/colormaps.h +++ b/src/colmap/ui/colormaps.h @@ -49,11 +49,11 @@ class PointColormapBase { std::unordered_map& points3D, std::vector& reg_image_ids) = 0; - virtual Eigen::Vector4f ComputeColor(const point3D_t point3D_id, + virtual Eigen::Vector4f ComputeColor(point3D_t point3D_id, const Point3D& point3D) = 0; void UpdateScale(std::vector* values); - float AdjustScale(const float gray); + float AdjustScale(float gray); float scale; float min; @@ -71,7 +71,7 @@ class PointColormapPhotometric : public PointColormapBase { std::unordered_map& points3D, std::vector& reg_image_ids) override; - Eigen::Vector4f ComputeColor(const point3D_t point3D_id, + Eigen::Vector4f ComputeColor(point3D_t point3D_id, const Point3D& point3D) override; }; @@ -83,7 +83,7 @@ class PointColormapError : public PointColormapBase { std::unordered_map& points3D, std::vector& reg_image_ids) override; - Eigen::Vector4f ComputeColor(const point3D_t point3D_id, + Eigen::Vector4f ComputeColor(point3D_t point3D_id, const Point3D& point3D) override; }; @@ -95,7 +95,7 @@ class PointColormapTrackLen : public PointColormapBase { std::unordered_map& points3D, std::vector& reg_image_ids) override; - Eigen::Vector4f ComputeColor(const point3D_t point3D_id, + Eigen::Vector4f ComputeColor(point3D_t point3D_id, const Point3D& point3D) override; }; @@ -107,7 +107,7 @@ class PointColormapGroundResolution : public PointColormapBase { std::unordered_map& points3D, std::vector& reg_image_ids) override; - Eigen::Vector4f ComputeColor(const point3D_t point3D_id, + Eigen::Vector4f ComputeColor(point3D_t point3D_id, const Point3D& point3D) override; private: diff --git a/src/colmap/ui/database_management_widget.h b/src/colmap/ui/database_management_widget.h index 5df693a31a..df538c9452 100644 --- a/src/colmap/ui/database_management_widget.h +++ b/src/colmap/ui/database_management_widget.h @@ -75,7 +75,7 @@ class MatchesTab : public TwoViewInfoTab { public: MatchesTab(QWidget* parent, OptionManager* options, Database* database); - void Reload(const std::vector& images, const image_t image_id); + void Reload(const std::vector& images, image_t image_id); }; class TwoViewGeometriesTab : public TwoViewInfoTab { @@ -84,7 +84,7 @@ class TwoViewGeometriesTab : public TwoViewInfoTab { OptionManager* options, Database* database); - void Reload(const std::vector& images, const image_t image_id); + void Reload(const std::vector& images, image_t image_id); }; class OverlappingImagesWidget : public QWidget { @@ -93,7 +93,7 @@ class OverlappingImagesWidget : public QWidget { OptionManager* options, Database* database); - void ShowMatches(const std::vector& images, const image_t image_id); + void ShowMatches(const std::vector& images, image_t image_id); private: void closeEvent(QCloseEvent* event); diff --git a/src/colmap/ui/feature_extraction_widget.h b/src/colmap/ui/feature_extraction_widget.h index f4a8f4436f..b98be005ea 100644 --- a/src/colmap/ui/feature_extraction_widget.h +++ b/src/colmap/ui/feature_extraction_widget.h @@ -52,7 +52,7 @@ class FeatureExtractionWidget : public QWidget { QGroupBox* CreateCameraModelBox(); - void SelectCameraModel(const int code); + void SelectCameraModel(int code); void Extract(); QWidget* parent_; diff --git a/src/colmap/ui/image_viewer_widget.h b/src/colmap/ui/image_viewer_widget.h index b778d66c0e..882def52cb 100644 --- a/src/colmap/ui/image_viewer_widget.h +++ b/src/colmap/ui/image_viewer_widget.h @@ -109,7 +109,7 @@ class DatabaseImageViewerWidget : public FeatureImageViewerWidget { ModelViewerWidget* model_viewer_widget, OptionManager* options); - void ShowImageWithId(const image_t image_id); + void ShowImageWithId(image_t image_id); private: void ResizeTable(); diff --git a/src/colmap/ui/line_painter.h b/src/colmap/ui/line_painter.h index ff28697975..389e32d7a5 100644 --- a/src/colmap/ui/line_painter.h +++ b/src/colmap/ui/line_painter.h @@ -55,9 +55,9 @@ class LinePainter { void Setup(); void Upload(const std::vector& data); void Render(const QMatrix4x4& pmv_matrix, - const int width, - const int height, - const float line_width); + int width, + int height, + float line_width); private: QOpenGLShaderProgram shader_program_; diff --git a/src/colmap/ui/log_widget.h b/src/colmap/ui/log_widget.h index 5f8e38d574..b39a0637f7 100644 --- a/src/colmap/ui/log_widget.h +++ b/src/colmap/ui/log_widget.h @@ -74,7 +74,7 @@ class StandardOutputRedirector : public std::basic_streambuf { class LogWidget : public QWidget { public: - explicit LogWidget(QWidget* parent, const int max_num_blocks = 100000); + explicit LogWidget(QWidget* parent, int max_num_blocks = 100000); ~LogWidget(); void Append(const std::string& text); diff --git a/src/colmap/ui/main_window.h b/src/colmap/ui/main_window.h index 5e97b65235..7919147822 100644 --- a/src/colmap/ui/main_window.h +++ b/src/colmap/ui/main_window.h @@ -115,7 +115,7 @@ class MainWindow : public QMainWindow { void RenderSelectedReconstruction(); void RenderClear(); - void SelectReconstructionIdx(const size_t); + void SelectReconstructionIdx(size_t); size_t SelectedReconstructionIdx(); bool HasSelectedReconstruction(); bool IsSelectedReconstructionValid(); diff --git a/src/colmap/ui/model_viewer_widget.h b/src/colmap/ui/model_viewer_widget.h index c580930b8f..307762e298 100644 --- a/src/colmap/ui/model_viewer_widget.h +++ b/src/colmap/ui/model_viewer_widget.h @@ -88,40 +88,34 @@ class ModelViewerWidget : public QOpenGLWidget, void EnableCoordinateGrid(); void DisableCoordinateGrid(); - void ChangeFocusDistance(const float delta); - void ChangeNearPlane(const float delta); - void ChangePointSize(const float delta); - void ChangeCameraSize(const float delta); - - void RotateView(const float x, - const float y, - const float prev_x, - const float prev_y); - void TranslateView(const float x, - const float y, - const float prev_x, - const float prev_y); + void ChangeFocusDistance(float delta); + void ChangeNearPlane(float delta); + void ChangePointSize(float delta); + void ChangeCameraSize(float delta); + + void RotateView(float x, float y, float prev_x, float prev_y); + void TranslateView(float x, float y, float prev_x, float prev_y); void ResetView(); QMatrix4x4 ModelViewMatrix() const; void SetModelViewMatrix(const QMatrix4x4& matrix); - void SelectObject(const int x, const int y); - void SelectMoviewGrabberView(const size_t view_idx); + void SelectObject(int x, int y); + void SelectMoviewGrabberView(size_t view_idx); QImage GrabImage(); void GrabMovie(); - void ShowPointInfo(const point3D_t point3D_id); - void ShowImageInfo(const image_t image_id); + void ShowPointInfo(point3D_t point3D_id); + void ShowImageInfo(image_t image_id); float PointSize() const; float ImageSize() const; - void SetPointSize(const float point_size); - void SetImageSize(const float image_size); + void SetPointSize(float point_size); + void SetImageSize(float image_size); - void SetBackgroundColor(const float r, const float g, const float b); + void SetBackgroundColor(float r, float g, float b); // Copy of current scene data that is displayed Reconstruction* reconstruction = nullptr; @@ -148,9 +142,9 @@ class ModelViewerWidget : public QOpenGLWidget, void Upload(); void UploadCoordinateGridData(); - void UploadPointData(const bool selection_mode = false); + void UploadPointData(bool selection_mode = false); void UploadPointConnectionData(); - void UploadImageData(const bool selection_mode = false); + void UploadImageData(bool selection_mode = false); void UploadImageConnectionData(); void UploadMovieGrabberData(); @@ -160,7 +154,7 @@ class ModelViewerWidget : public QOpenGLWidget, float AspectRatio() const; float OrthographicWindowExtent() const; - Eigen::Vector3f PositionToArcballVector(const float x, const float y) const; + Eigen::Vector3f PositionToArcballVector(float x, float y) const; OptionManager* options_; diff --git a/src/colmap/ui/options_widget.h b/src/colmap/ui/options_widget.h index 37e8454069..c04a83e673 100644 --- a/src/colmap/ui/options_widget.h +++ b/src/colmap/ui/options_widget.h @@ -49,20 +49,20 @@ class OptionsWidget : public QWidget { QSpinBox* AddOptionInt(int* option, const std::string& label_text, - const int min = 0, - const int max = static_cast(1e7)); + int min = 0, + int max = static_cast(1e7)); QDoubleSpinBox* AddOptionDouble(double* option, const std::string& label_text, - const double min = 0, - const double max = 1e7, - const double step = 0.01, - const int decimals = 2); + double min = 0, + double max = 1e7, + double step = 0.01, + int decimals = 2); QDoubleSpinBox* AddOptionDoubleLog(double* option, const std::string& label_text, - const double min = 0, - const double max = 1e7, - const double step = 0.01, - const int decimals = 2); + double min = 0, + double max = 1e7, + double step = 0.01, + int decimals = 2); QCheckBox* AddOptionBool(bool* option, const std::string& label_text); QLineEdit* AddOptionText(std::string* option, const std::string& label_text); QLineEdit* AddOptionFilePath(std::string* option, diff --git a/src/colmap/ui/point_painter.h b/src/colmap/ui/point_painter.h index 7b6ea942e4..99772c9fa5 100644 --- a/src/colmap/ui/point_painter.h +++ b/src/colmap/ui/point_painter.h @@ -58,7 +58,7 @@ class PointPainter { void Setup(); void Upload(const std::vector& data); - void Render(const QMatrix4x4& pmv_matrix, const float point_size); + void Render(const QMatrix4x4& pmv_matrix, float point_size); private: QOpenGLShaderProgram shader_program_; diff --git a/src/colmap/ui/point_viewer_widget.h b/src/colmap/ui/point_viewer_widget.h index 8193736a7f..b64efb8cb7 100644 --- a/src/colmap/ui/point_viewer_widget.h +++ b/src/colmap/ui/point_viewer_widget.h @@ -47,7 +47,7 @@ class PointViewerWidget : public QWidget { ModelViewerWidget* model_viewer_widget, OptionManager* option); - void Show(const point3D_t point3D_id); + void Show(point3D_t point3D_id); private: void closeEvent(QCloseEvent* event); diff --git a/src/colmap/ui/reconstruction_manager_widget.h b/src/colmap/ui/reconstruction_manager_widget.h index d744dd7971..d00bb6a6c2 100644 --- a/src/colmap/ui/reconstruction_manager_widget.h +++ b/src/colmap/ui/reconstruction_manager_widget.h @@ -47,7 +47,7 @@ class ReconstructionManagerWidget : public QComboBox { void Update(); size_t SelectedReconstructionIdx() const; - void SelectReconstruction(const size_t idx); + void SelectReconstruction(size_t idx); private: const ReconstructionManager* reconstruction_manager_; diff --git a/src/colmap/ui/render_options_widget.h b/src/colmap/ui/render_options_widget.h index fb9d7bd927..6b9a27ccfd 100644 --- a/src/colmap/ui/render_options_widget.h +++ b/src/colmap/ui/render_options_widget.h @@ -61,8 +61,8 @@ class RenderOptionsWidget : public OptionsWidget { void ApplyBackgroundColor(); void SelectColor(const std::string& title, Eigen::Vector4f* color); - void SelectPointColormap(const int idx); - void SelectImageColormap(const int idx); + void SelectPointColormap(int idx); + void SelectImageColormap(int idx); void IncreasePointSize(); void DecreasePointSize(); diff --git a/src/colmap/ui/thread_control_widget.h b/src/colmap/ui/thread_control_widget.h index 60144685a9..fd84858dc6 100644 --- a/src/colmap/ui/thread_control_widget.h +++ b/src/colmap/ui/thread_control_widget.h @@ -44,7 +44,7 @@ class ThreadControlWidget : public QWidget { explicit ThreadControlWidget(QWidget* parent); void StartThread(const QString& progress_text, - const bool stoppable, + bool stoppable, std::unique_ptr thread); void StartFunction(const QString& progress_text, const std::function& func); diff --git a/src/colmap/util/cache.h b/src/colmap/util/cache.h index da42328ff9..999e087697 100644 --- a/src/colmap/util/cache.h +++ b/src/colmap/util/cache.h @@ -61,8 +61,7 @@ class LRUCache { const value_t& Get(const key_t& key); value_t& GetMutable(const key_t& key); - // Manually set the value of an element. Note that the ownership of the value - // is moved to the cache, which invalidates the object on the caller side. + // Manually set the value of an element. virtual void Set(const key_t& key, value_t value); // Pop least recently used element from cache. diff --git a/src/colmap/util/cuda.h b/src/colmap/util/cuda.h index ff8321f59a..fff8848fc5 100644 --- a/src/colmap/util/cuda.h +++ b/src/colmap/util/cuda.h @@ -35,6 +35,6 @@ namespace colmap { int GetNumCudaDevices(); -void SetBestCudaDevice(const int gpu_index); +void SetBestCudaDevice(int gpu_index); } // namespace colmap diff --git a/src/colmap/util/endian.h b/src/colmap/util/endian.h index 7668dd279e..b75c8a07e0 100644 --- a/src/colmap/util/endian.h +++ b/src/colmap/util/endian.h @@ -49,13 +49,13 @@ bool IsBigEndian(); // and double types, these functions are only valid if the format is IEEE-754. // This is the case for pretty much most processors. template -T LittleEndianToNative(const T x); +T LittleEndianToNative(T x); template -T BigEndianToNative(const T x); +T BigEndianToNative(T x); template -T NativeToLittleEndian(const T x); +T NativeToLittleEndian(T x); template -T NativeToBigEndian(const T x); +T NativeToBigEndian(T x); // Read data in little endian format for cross-platform support. template diff --git a/src/colmap/util/logging.h b/src/colmap/util/logging.h index a922f05a2e..ae145a398f 100644 --- a/src/colmap/util/logging.h +++ b/src/colmap/util/logging.h @@ -75,8 +75,8 @@ void InitializeGlog(char** argv); const char* __GetConstFileBaseName(const char* file); bool __CheckOptionImpl(const char* file, - const int line, - const bool result, + int line, + bool result, const char* expr_str); template diff --git a/src/colmap/util/math.h b/src/colmap/util/math.h index c012ff0314..3c8259c684 100644 --- a/src/colmap/util/math.h +++ b/src/colmap/util/math.h @@ -49,27 +49,27 @@ namespace colmap { // Return 1 if number is positive, -1 if negative, and 0 if the number is 0. template -int SignOfNumber(const T val); +int SignOfNumber(T val); // Check if the given floating point number is a not-a-number (NaN) value. -inline bool IsNaN(const float x); -inline bool IsNaN(const double x); +inline bool IsNaN(float x); +inline bool IsNaN(double x); // Check if the given floating point number is a infinity. -inline bool IsInf(const float x); -inline bool IsInf(const double x); +inline bool IsInf(float x); +inline bool IsInf(double x); // Clip the given value to a low and maximum value. template inline T Clip(const T& value, const T& low, const T& high); // Convert angle in degree to radians. -inline float DegToRad(const float deg); -inline double DegToRad(const double deg); +inline float DegToRad(float deg); +inline double DegToRad(double deg); // Convert angle in radians to degree. -inline float RadToDeg(const float rad); -inline double RadToDeg(const double rad); +inline float RadToDeg(float rad); +inline double RadToDeg(double rad); // Determine median value in vector. Returns NaN for empty vectors. template @@ -104,7 +104,7 @@ bool NextCombination(Iterator first, Iterator middle, Iterator last); // Sigmoid function. template -T Sigmoid(const T x, const T alpha = 1); +T Sigmoid(T x, T alpha = 1); // Scale values according to sigmoid transform. // @@ -116,19 +116,19 @@ T Sigmoid(const T x, const T alpha = 1); // // @return The scaled value in the range [0, 1]. template -T ScaleSigmoid(T x, const T alpha = 1, const T x0 = 10); +T ScaleSigmoid(T x, T alpha = 1, T x0 = 10); // Binomial coefficient or all combinations, defined as n! / ((n - k)! k!). -size_t NChooseK(const size_t n, const size_t k); +size_t NChooseK(size_t n, size_t k); // Cast value from one type to another and truncate instead of overflow, if the // input value is out of range of the output data type. template -T2 TruncateCast(const T1 value); +T2 TruncateCast(T1 value); // Compute the n-th percentile in the given sequence. template -T Percentile(const std::vector& elems, const double p); +T Percentile(const std::vector& elems, double p); //////////////////////////////////////////////////////////////////////////////// // Implementation diff --git a/src/colmap/util/misc.h b/src/colmap/util/misc.h index c750d1a882..b97795865a 100644 --- a/src/colmap/util/misc.h +++ b/src/colmap/util/misc.h @@ -113,7 +113,7 @@ void PrintHeading2(const std::string& heading); // Check if vector contains elements. template -bool VectorContainsValue(const std::vector& vector, const T value); +bool VectorContainsValue(const std::vector& vector, T value); template bool VectorContainsDuplicateValues(const std::vector& vector); diff --git a/src/colmap/util/opengl_utils.h b/src/colmap/util/opengl_utils.h index 68bf9bdc7d..63c2ac1648 100644 --- a/src/colmap/util/opengl_utils.h +++ b/src/colmap/util/opengl_utils.h @@ -86,7 +86,7 @@ class OpenGLContextManager : public QObject { void RunThreadWithOpenGLContext(Thread* thread); // Get the OpenGL errors and print them to stderr. -void GLError(const char* file, const int line); +void GLError(const char* file, int line); #else diff --git a/src/colmap/util/option_manager.h b/src/colmap/util/option_manager.h index 28afe0f221..61ec4afa05 100644 --- a/src/colmap/util/option_manager.h +++ b/src/colmap/util/option_manager.h @@ -109,11 +109,11 @@ class OptionManager { const std::string& help_text = ""); void Reset(); - void ResetOptions(const bool reset_paths); + void ResetOptions(bool reset_paths); bool Check(); - void Parse(const int argc, char** argv); + void Parse(int argc, char** argv); bool Read(const std::string& path); bool ReRead(const std::string& path); void Write(const std::string& path) const; diff --git a/src/colmap/util/ply.h b/src/colmap/util/ply.h index a10550d1c9..267729dddc 100644 --- a/src/colmap/util/ply.h +++ b/src/colmap/util/ply.h @@ -85,12 +85,12 @@ std::vector ReadPly(const std::string& path); // Write PLY point cloud to text or binary file. void WriteTextPlyPoints(const std::string& path, const std::vector& points, - const bool write_normal = true, - const bool write_rgb = true); + bool write_normal = true, + bool write_rgb = true); void WriteBinaryPlyPoints(const std::string& path, const std::vector& points, - const bool write_normal = true, - const bool write_rgb = true); + bool write_normal = true, + bool write_rgb = true); // Write PLY mesh to text or binary file. void WriteTextPlyMesh(const std::string& path, const PlyMesh& mesh); diff --git a/src/colmap/util/random.h b/src/colmap/util/random.h index ab36809ee2..a0c9a1deb3 100644 --- a/src/colmap/util/random.h +++ b/src/colmap/util/random.h @@ -54,19 +54,19 @@ void SetPRNGSeed(unsigned seed = kDefaultPRNGSeed); // // This implementation is unbiased and thread-safe in contrast to `rand()`. template -T RandomInteger(const T min, const T max); +T RandomInteger(T min, T max); // Generate uniformly distributed random real number. // // This implementation is unbiased and thread-safe in contrast to `rand()`. template -T RandomReal(const T min, const T max); +T RandomReal(T min, T max); // Generate Gaussian distributed random real number. // // This implementation is unbiased and thread-safe in contrast to `rand()`. template -T RandomGaussian(const T mean, const T stddev); +T RandomGaussian(T mean, T stddev); // Fisher-Yates shuffling. // @@ -78,7 +78,7 @@ T RandomGaussian(const T mean, const T stddev); // @param num_to_shuffle Optional parameter, specifying the number of first // N elements in the vector to shuffle. template -void Shuffle(const uint32_t num_to_shuffle, std::vector* elems); +void Shuffle(uint32_t num_to_shuffle, std::vector* elems); //////////////////////////////////////////////////////////////////////////////// // Implementation diff --git a/src/colmap/util/threading.h b/src/colmap/util/threading.h index be30b5341a..0c29e430c7 100644 --- a/src/colmap/util/threading.h +++ b/src/colmap/util/threading.h @@ -131,7 +131,7 @@ class Thread { bool CheckValidSetup(); // Set callbacks that can be triggered within the main run function. - void AddCallback(const int id, const std::function& func); + void AddCallback(int id, const std::function& func); // Get timing information of the thread, properly accounting for pause times. const Timer& GetTimer() const; @@ -146,10 +146,10 @@ class Thread { // Register a new callback. Note that only registered callbacks can be // set/reset and called from within the thread. Hence, this method should be // called from the derived thread constructor. - void RegisterCallback(const int id); + void RegisterCallback(int id); // Call back to the function with the specified name, if it exists. - void Callback(const int id) const; + void Callback(int id) const; // Get the unique identifier of the current thread. std::thread::id GetThreadId() const; @@ -195,7 +195,7 @@ class ThreadPool { public: static const int kMaxNumThreads = -1; - explicit ThreadPool(const int num_threads = kMaxNumThreads); + explicit ThreadPool(int num_threads = kMaxNumThreads); ~ThreadPool(); inline size_t NumThreads() const; @@ -220,7 +220,7 @@ class ThreadPool { int GetThreadIndex(); private: - void WorkerFunc(const int index); + void WorkerFunc(int index); std::vector workers_; std::queue> tasks_; @@ -277,7 +277,7 @@ class JobQueue { }; JobQueue(); - explicit JobQueue(const size_t max_num_jobs); + explicit JobQueue(size_t max_num_jobs); ~JobQueue(); // The number of pushed and not popped jobs in the queue. @@ -310,7 +310,7 @@ class JobQueue { // Return the number of logical CPU cores if num_threads <= 0, // otherwise return the input value of num_threads. -int GetEffectiveNumThreads(const int num_threads); +int GetEffectiveNumThreads(int num_threads); //////////////////////////////////////////////////////////////////////////////// // Implementation diff --git a/src/lib/SiftGPU/SiftGPU.h b/src/lib/SiftGPU/SiftGPU.h index 3acf17730e..5e93f962cf 100644 --- a/src/lib/SiftGPU/SiftGPU.h +++ b/src/lib/SiftGPU/SiftGPU.h @@ -181,8 +181,8 @@ class SiftGPU:public SiftParam //set SiftGPU to brief display mode, which is faster inline void SetVerboseBrief(){SetVerbose(2);}; //parse SiftGPU parameters - SIFTGPU_EXPORT virtual void ParseParam(const int argc, const char **argv); - //run SIFT on a new image given filename + SIFTGPU_EXPORT virtual void ParseParam(int argc, const char** argv); + //run SIFT on a new image given filename SIFTGPU_EXPORT virtual int RunSIFT(const char * imgpath); //run SIFT on an image in the image list given the file index SIFTGPU_EXPORT virtual int RunSIFT(int index); From c10a0ee07b6f20f1e5685a14f713bc4a450f35b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Jul 2023 20:42:49 +0300 Subject: [PATCH 7/7] s --- cmake/CMakeHelper.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index 47c2e9d9d0..1820447801 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -115,7 +115,7 @@ macro(COLMAP_ADD_LIBRARY TARGET_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap) endmacro(COLMAP_ADD_LIBRARY) @@ -130,7 +130,7 @@ macro(COLMAP_ADD_CUDA_LIBRARY TARGET_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap/) endmacro(COLMAP_ADD_CUDA_LIBRARY) @@ -150,7 +150,7 @@ macro(COLMAP_ADD_EXECUTABLE TARGET_NAME) install(TARGETS ${TARGET_NAME} DESTINATION bin/) endif() if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() endmacro(COLMAP_ADD_EXECUTABLE) @@ -163,7 +163,7 @@ macro(COLMAP_ADD_TEST TEST_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() target_link_libraries(${TARGET_NAME} colmap ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) @@ -183,7 +183,7 @@ macro(COLMAP_ADD_CUDA_TEST TEST_NAME) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*;--fix") + set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() target_link_libraries(${TARGET_NAME} colmap ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})