Skip to content

Commit

Permalink
clang format all code and require clang-format-14 (colmap#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojnnes authored Feb 1, 2023
1 parent 43de802 commit b243efc
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions scripts/shell/clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ fi
echo "Found clang-format: $(which ${clang_format})"

# Check version
version_string=$($clang_format --version | sed -E 's/^.*([0-9]+\.[0-9]+\.[0-9]+-[0-9]+).*$/\1/')
expected_version_string='8.0.0'
version_string=$($clang_format --version | sed -E 's/^.*(\d+\.\d+\.\d+-.*).*$/\1/')
expected_version_string='14.0.0'
if [[ "$version_string" =~ "$expected_version_string" ]]; then
echo "clang-format version '$version_string' matches '$expected_version_string'"
else
Expand Down
3 changes: 2 additions & 1 deletion src/base/camera_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ BOOST_AUTO_TEST_CASE(TestIsUndistorted) {
BOOST_CHECK(!camera.IsUndistorted());
camera.InitializeWithId(FullOpenCVCameraModel::model_id, 1.0, 1, 1);
BOOST_CHECK(camera.IsUndistorted());
camera.SetParams({1.0, 1.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.001});
camera.SetParams(
{1.0, 1.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.001});
BOOST_CHECK(!camera.IsUndistorted());
}

Expand Down
3 changes: 1 addition & 2 deletions src/base/image_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ ImageReader::Status ImageReader::Next(Camera* camera, Image* image,

if (mask && !options_.mask_path.empty()) {
const std::string mask_path =
JoinPaths(options_.mask_path,
image->Name() + ".png");
JoinPaths(options_.mask_path, image->Name() + ".png");
if (ExistsFile(mask_path) && !mask->Read(mask_path, false)) {
// NOTE: Maybe introduce a separate error type MASK_ERROR?
return Status::BITMAP_ERROR;
Expand Down
3 changes: 1 addition & 2 deletions src/estimators/coordinate_frame_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#define TEST_NAME "estimators/coordinate_frame"
#include "util/testing.h"

#include "estimators/coordinate_frame.h"
#include "base/gps.h"
#include "estimators/coordinate_frame.h"

using namespace colmap;

Expand Down Expand Up @@ -153,5 +153,4 @@ BOOST_AUTO_TEST_CASE(TestAlignToENUPlane) {
.norm();
BOOST_CHECK_LE(std::abs(dist_orig - dist_tform), 1e-6);
}

}
2 changes: 1 addition & 1 deletion src/estimators/generalized_absolute_pose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void GP3PEstimator::Residuals(const std::vector<X_t>& points2D,
const double reproj_error = dx_0 * dx_0 + dx_1 * dx_1;
(*residuals)[i] = reproj_error;
} else {
LOG(FATAL) << "Invalid residual type";
LOG(FATAL) << "Invalid residual type";
}
} else {
(*residuals)[i] = std::numeric_limits<double>::max();
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/generalized_absolute_pose.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class GP3PEstimator {
// 2D-3D point correspondences and a projection matrix of the generalized
// camera.
void Residuals(const std::vector<X_t>& points2D,
const std::vector<Y_t>& points3D,
const M_t& proj_matrix, std::vector<double>* residuals);
const std::vector<Y_t>& points3D, const M_t& proj_matrix,
std::vector<double>* residuals);
};

} // namespace colmap
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/two_view_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ void TwoViewGeometry::EstimateUncalibrated(
}

if (options.compute_relative_pose) {
EstimateRelativePose(camera1, points1, camera2, points2);
EstimateRelativePose(camera1, points1, camera2, points2);
}
}

Expand Down Expand Up @@ -486,7 +486,7 @@ void TwoViewGeometry::EstimateHomography(
}

if (options.compute_relative_pose) {
EstimateRelativePose(camera1, points1, camera2, points2);
EstimateRelativePose(camera1, points1, camera2, points2);
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/exe/feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ int RunFeatureExtractor(int argc, char** argv) {
options.AddImageOptions();
options.AddDefaultOption("camera_mode", &camera_mode);
options.AddDefaultOption("image_list_path", &image_list_path);
options.AddDefaultOption("descriptor_normalization", &descriptor_normalization,
"{'l1_root', 'l2'}");
options.AddDefaultOption("descriptor_normalization",
&descriptor_normalization, "{'l1_root', 'l2'}");
options.AddExtractionOptions();
options.Parse(argc, argv);

Expand All @@ -128,13 +128,12 @@ int RunFeatureExtractor(int argc, char** argv) {
StringToLower(&descriptor_normalization);
if (descriptor_normalization == "l1_root") {
options.sift_extraction->normalization =
SiftExtractionOptions::Normalization::L1_ROOT;
SiftExtractionOptions::Normalization::L1_ROOT;
} else if (descriptor_normalization == "l2") {
options.sift_extraction->normalization =
SiftExtractionOptions::Normalization::L2;
SiftExtractionOptions::Normalization::L2;
} else {
std::cerr << "ERROR: Invalid `descriptor_normalization`"
<< std::endl;
std::cerr << "ERROR: Invalid `descriptor_normalization`" << std::endl;
return EXIT_FAILURE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/exe/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <iostream>

#ifdef GUI_ENABLED
#include <QApplication>
#include "ui/main_window.h"
#include <QApplication>
#else
// Dummy QApplication class when GUI is disabled
class QApplication {
Expand Down
6 changes: 3 additions & 3 deletions src/exe/sfm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ int RunPointTriangulator(int argc, char** argv) {
Reconstruction reconstruction;
reconstruction.Read(input_path);

return RunPointTriangulatorImpl(
reconstruction, *options.database_path, *options.image_path, output_path,
*options.mapper, clear_points);
return RunPointTriangulatorImpl(reconstruction, *options.database_path,
*options.image_path, output_path,
*options.mapper, clear_points);
}

int RunPointTriangulatorImpl(Reconstruction& reconstruction,
Expand Down
3 changes: 2 additions & 1 deletion src/feature/matching.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ TwoViewGeometryVerifier::TwoViewGeometryVerifier(
two_view_geometry_options_.ransac_options.min_inlier_ratio =
options_.min_inlier_ratio;
two_view_geometry_options_.force_H_use = options_.planar_scene;
two_view_geometry_options_.compute_relative_pose = options_.compute_relative_pose;
two_view_geometry_options_.compute_relative_pose =
options_.compute_relative_pose;
}

void TwoViewGeometryVerifier::Run() {
Expand Down
3 changes: 2 additions & 1 deletion src/feature/sift.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ struct SiftMatchingOptions {
// Force Homography use for Two-view Geometry (can help for planar scenes)
bool planar_scene = false;

// Whether to estimate the relative pose between the two images and save them to the DB.
// Whether to estimate the relative pose between the two images and save them
// to the DB.
bool compute_relative_pose = false;

bool Check() const;
Expand Down
2 changes: 1 addition & 1 deletion src/retrieval/visual_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include <Eigen/Core>
#include <boost/heap/fibonacci_heap.hpp>

#include "flann/flann.hpp"
#include "feature/types.h"
#include "flann/flann.hpp"
#include "retrieval/inverted_file.h"
#include "retrieval/inverted_index.h"
#include "retrieval/vote_and_verify.h"
Expand Down
4 changes: 2 additions & 2 deletions src/ui/render_options_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ RenderOptionsWidget::RenderOptionsWidget(QWidget* parent,
HideOption(&point3D_colormap_max_q_);
HideOption(&point3D_colormap_scale_);
connect(point3D_colormap_cb_,
(void (QComboBox::*)(int)) & QComboBox::currentIndexChanged, this,
(void(QComboBox::*)(int)) & QComboBox::currentIndexChanged, this,
&RenderOptionsWidget::SelectPointColormap);

AddSpacer();
Expand Down Expand Up @@ -150,7 +150,7 @@ RenderOptionsWidget::RenderOptionsWidget(QWidget* parent,

HideLayout(image_colormap_name_filter_layout_);
connect(image_colormap_cb_,
(void (QComboBox::*)(int)) & QComboBox::currentIndexChanged, this,
(void(QComboBox::*)(int)) & QComboBox::currentIndexChanged, this,
&RenderOptionsWidget::SelectImageColormap);

AddSpacer();
Expand Down
2 changes: 1 addition & 1 deletion src/util/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <future>
#include <list>
#include <queue>
#include <unordered_map>
#include <thread>
#include <unordered_map>

#include "util/timer.h"

Expand Down

0 comments on commit b243efc

Please sign in to comment.