From 2645de1c056e6b82048cbc4d6ba9c036222dbeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 12 Aug 2024 09:24:31 +0200 Subject: [PATCH 1/6] Fix conversion of colmap pose prior --- glomap/io/colmap_converter.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glomap/io/colmap_converter.cc b/glomap/io/colmap_converter.cc index eceaead4..6996b9e2 100644 --- a/glomap/io/colmap_converter.cc +++ b/glomap/io/colmap_converter.cc @@ -184,14 +184,15 @@ void ConvertDatabaseToGlomap(const colmap::Database& database, << images_colmap.size() << std::flush; counter++; - image_t image_id = image.ImageId(); + const image_t image_id = image.ImageId(); if (image_id == colmap::kInvalidImageId) continue; auto ite = images.insert(std::make_pair( image_id, Image(image_id, image.CameraId(), image.Name()))); const colmap::PosePrior prior = database.ReadPosePrior(image_id); if (prior.IsValid()) { - ite.first->second.cam_from_world = Rigid3d( - colmap::Rigid3d(Eigen::Quaterniond::Identity(), prior.position)); + const colmap::Rigid3d world_from_cam_prior(Eigen::Quaterniond::Identity(), + prior.position); + ite.first->second.cam_from_world = Rigid3d(Inverse(world_from_cam_prior)); } else { ite.first->second.cam_from_world = Rigid3d(); } @@ -204,8 +205,7 @@ void ConvertDatabaseToGlomap(const colmap::Database& database, image.features.reserve(keypoints.size()); for (int i = 0; i < keypoints.size(); i++) { - image.features.emplace_back( - Eigen::Vector2d(keypoints[i].x, keypoints[i].y)); + image.features.emplace_back(keypoints[i].x, keypoints[i].y); } } From 2b4346eaad33fd427f6a216e4567a10cac53190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 12 Aug 2024 09:27:47 +0200 Subject: [PATCH 2/6] d --- glomap/io/colmap_converter.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/glomap/io/colmap_converter.cc b/glomap/io/colmap_converter.cc index 6996b9e2..37473086 100644 --- a/glomap/io/colmap_converter.cc +++ b/glomap/io/colmap_converter.cc @@ -201,19 +201,18 @@ void ConvertDatabaseToGlomap(const colmap::Database& database, // Read keypoints for (auto& [image_id, image] : images) { - colmap::FeatureKeypoints keypoints = database.ReadKeypoints(image_id); - - image.features.reserve(keypoints.size()); - for (int i = 0; i < keypoints.size(); i++) { - image.features.emplace_back(keypoints[i].x, keypoints[i].y); + const colmap::FeatureKeypoints keypoints = database.ReadKeypoints(image_id); + const int num_keypoints = keypoints.size(); + image.features.resize(num_keypoints); + for (int i = 0; i < num_keypoints; i++) { + image.features[i] = Eigen::Vector2d(keypoints[i].x, keypoints[i].y); } } // Add the cameras std::vector cameras_colmap = database.ReadAllCameras(); for (auto& camera : cameras_colmap) { - camera_t camera_id = camera.camera_id; - cameras[camera_id] = camera; + cameras[camera.camera_id] = camera; } // Add the matches From a0dc97b4484edee744b5333947792b897cd30fe4 Mon Sep 17 00:00:00 2001 From: Linfei Pan Date: Mon, 12 Aug 2024 10:13:05 +0200 Subject: [PATCH 3/6] restore the pose prior after rotation averaging --- glomap/estimators/global_rotation_averaging.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glomap/estimators/global_rotation_averaging.cc b/glomap/estimators/global_rotation_averaging.cc index 429a6bdc..b03b4db5 100644 --- a/glomap/estimators/global_rotation_averaging.cc +++ b/glomap/estimators/global_rotation_averaging.cc @@ -56,6 +56,8 @@ bool RotationEstimator::EstimateRotations( image.cam_from_world.rotation = Eigen::Quaterniond(AngleAxisToRotation( rotation_estimated_.segment(image_id_to_idx_[image_id], 3))); } + // Restore the prior position (t = -Rc) + image.cam_from_world.translation = -(image.cam_from_world.rotation * image.cam_from_world.translation); } return true; From 150f1cff4437e5d741fa59db3f673d762620f3c4 Mon Sep 17 00:00:00 2001 From: Linfei Pan Date: Mon, 12 Aug 2024 10:15:51 +0200 Subject: [PATCH 4/6] f --- glomap/estimators/global_rotation_averaging.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glomap/estimators/global_rotation_averaging.cc b/glomap/estimators/global_rotation_averaging.cc index b03b4db5..882d2f36 100644 --- a/glomap/estimators/global_rotation_averaging.cc +++ b/glomap/estimators/global_rotation_averaging.cc @@ -57,7 +57,8 @@ bool RotationEstimator::EstimateRotations( rotation_estimated_.segment(image_id_to_idx_[image_id], 3))); } // Restore the prior position (t = -Rc) - image.cam_from_world.translation = -(image.cam_from_world.rotation * image.cam_from_world.translation); + image.cam_from_world.translation = + -(image.cam_from_world.rotation * image.cam_from_world.translation); } return true; From 34f27b5067a1c5c8d935145169aca3fbb2945f2d Mon Sep 17 00:00:00 2001 From: Linfei Pan Date: Mon, 26 Aug 2024 11:52:38 +0200 Subject: [PATCH 5/6] f --- glomap/estimators/global_rotation_averaging.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glomap/estimators/global_rotation_averaging.cc b/glomap/estimators/global_rotation_averaging.cc index 8e00ecae..570dca77 100644 --- a/glomap/estimators/global_rotation_averaging.cc +++ b/glomap/estimators/global_rotation_averaging.cc @@ -56,9 +56,9 @@ bool RotationEstimator::EstimateRotations( image.cam_from_world.rotation = Eigen::Quaterniond(AngleAxisToRotation( rotation_estimated_.segment(image_id_to_idx_[image_id], 3))); } - // Restore the prior position (t = -Rc) + // Restore the prior position (t = -Rc = R * R_ori * t_ori = R_ori t_ori) image.cam_from_world.translation = - -(image.cam_from_world.rotation * image.cam_from_world.translation); + (image.cam_from_world.rotation * image.cam_from_world.translation); } return true; From 32243119187cac9363636cdaa439eddfd357c8c2 Mon Sep 17 00:00:00 2001 From: Linfei Pan Date: Mon, 26 Aug 2024 11:53:20 +0200 Subject: [PATCH 6/6] f --- glomap/estimators/global_rotation_averaging.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glomap/estimators/global_rotation_averaging.cc b/glomap/estimators/global_rotation_averaging.cc index 570dca77..a968fa15 100644 --- a/glomap/estimators/global_rotation_averaging.cc +++ b/glomap/estimators/global_rotation_averaging.cc @@ -56,7 +56,7 @@ bool RotationEstimator::EstimateRotations( image.cam_from_world.rotation = Eigen::Quaterniond(AngleAxisToRotation( rotation_estimated_.segment(image_id_to_idx_[image_id], 3))); } - // Restore the prior position (t = -Rc = R * R_ori * t_ori = R_ori t_ori) + // Restore the prior position (t = -Rc = R * R_ori * t_ori = R * t_ori) image.cam_from_world.translation = (image.cam_from_world.rotation * image.cam_from_world.translation); }