From 1911af5218b2b879ee72b5c13616849eefa5198d Mon Sep 17 00:00:00 2001 From: Victor Fragoso Date: Sun, 12 Apr 2020 09:59:32 -0700 Subject: [PATCH 1/2] Fixing compilation of radial distortion homography tests on clang. Change-Id: I5a8787fc23264ac998d784a9476d1cf471a71fa1 --- .../estimate_radial_distortion_homography_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/theia/sfm/estimators/estimate_radial_distortion_homography_test.cc b/src/theia/sfm/estimators/estimate_radial_distortion_homography_test.cc index bb27243f5..a1b7665d3 100644 --- a/src/theia/sfm/estimators/estimate_radial_distortion_homography_test.cc +++ b/src/theia/sfm/estimators/estimate_radial_distortion_homography_test.cc @@ -69,10 +69,10 @@ static constexpr double kRadialDistortion1 = -1e-7; static constexpr double kRadialDistortion2 = -5e-7; static constexpr double kReprojectionError = 3.0; -// allowing 10 percent error for radial distortion parameters -static constexpr double kRadDistThreshold1 = +// Allowing 10 percent error for radial distortion parameters. +static const double kRadDistThreshold1 = 0.1 * std::abs(kRadialDistortion1 * std::pow(kFocalLength1, 2)); -static constexpr double kRadDistThreshold2 = +static const double kRadDistThreshold2 = 0.1 * std::abs(kRadialDistortion2 * std::pow(kFocalLength2, 2)); // Generate points on a plane so that a homography can accurately estimate the @@ -111,7 +111,7 @@ void GenerateDistortedImagePoint( AddNoiseToProjection(projection_noise_std_dev, &rng, &image_2_point); } - // normalize points with focal length (and principal point) estimate + // Normalize points with focal length (and principal point) estimate. UndistortPoint(image_1_point, focal_length1, 0.0, image_1_point_normalized); UndistortPoint(image_2_point, focal_length2, 0.0, image_2_point_normalized); } @@ -164,13 +164,13 @@ void ExecuteRandomTest(const RansacParameters& options, std::vector image_1_points_normalized, image_2_points_normalized; std::vector image_1_points, image_2_points; - // Generate distorted points + // Generate distorted points. GenerateDistortedImagePoints( points3d, noise, rotation, position, focal_length_1, focal_length_2, radial_distortion_1, radial_distortion_2, inlier_ratio, &image_1_points_normalized, &image_2_points_normalized, &image_1_points, &image_2_points); - // Get correspondences + // Get correspondences. std::vector correspondences; for (size_t i = 0; i < image_1_points.size(); ++i) { RadialDistortionFeatureCorrespondence correspondence; From 2de4bcc65afc8cd0f31f6c484f5a0584b0933d24 Mon Sep 17 00:00:00 2001 From: Victor Fragoso Date: Sun, 12 Apr 2020 10:34:00 -0700 Subject: [PATCH 2/2] Reading kpts from bundler as floats instead of integers. Change-Id: Ie892161ee44ba39fb6ed57479f2a1d36301b3b23 --- src/theia/io/bundler_file_reader.cc | 5 +++-- src/theia/io/bundler_file_reader.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/theia/io/bundler_file_reader.cc b/src/theia/io/bundler_file_reader.cc index 507167698..db7f1dd99 100644 --- a/src/theia/io/bundler_file_reader.cc +++ b/src/theia/io/bundler_file_reader.cc @@ -134,6 +134,7 @@ bool ReadViewList(FILE* in, std::vector* view_list) { int num_views = 0; if (fscanf(in, "%d", &num_views) != 1) { VLOG(3) << "Unable to read number of views for point."; + return false; } VLOG(3) << "Num. views to read: " << num_views; view_list->resize(num_views); @@ -153,12 +154,12 @@ bool ReadViewList(FILE* in, std::vector* view_list) { if (fscanf(in, "%f", &entry) != 1) { return false; } - (*view_list)[i].kpt_x = static_cast(entry); + (*view_list)[i].kpt_x = entry; // Kpt y. if (fscanf(in, "%f", &entry) != 1) { return false; } - (*view_list)[i].kpt_y = static_cast(entry); + (*view_list)[i].kpt_y = entry; } return true; } diff --git a/src/theia/io/bundler_file_reader.h b/src/theia/io/bundler_file_reader.h index 071be7e9b..0105f2a6b 100644 --- a/src/theia/io/bundler_file_reader.h +++ b/src/theia/io/bundler_file_reader.h @@ -64,8 +64,8 @@ struct FeatureInfo { // Index of the feature in the SIFT file. int sift_index; // Pixel position. - int kpt_x; - int kpt_y; + float kpt_x; + float kpt_y; }; // Reconstructed 3D point.