Skip to content

Commit ac7df16

Browse files
authored
fix the rotation averaging bug (#227)
* fix the rotation averaging bug * f
1 parent bd7e750 commit ac7df16

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

glomap/estimators/global_rotation_averaging.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ double RotationEstimator::ComputeAverageStepSize(
759759
const std::unordered_map<frame_t, Frame>& frames) {
760760
double total_update = 0;
761761
for (const auto& [frame_id, frame] : frames) {
762-
if (frames.at(frame_id).is_registered) continue;
762+
if (!frames.at(frame_id).is_registered) continue;
763763

764764
if (options_.use_gravity && frame.HasGravity()) {
765765
total_update += std::abs(tangent_space_step_[frame_id_to_idx_[frame_id]]);

glomap/exe/rotation_averager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int RunRotationAverager(int argc, char** argv) {
7474
for (auto& [image_id, image] : images) {
7575
image.camera_id = image.image_id;
7676
cameras[image.camera_id] = Camera();
77+
cameras[image.camera_id].camera_id = image.camera_id;
7778
}
7879

7980
CreateOneRigPerCamera(cameras, rigs);

glomap/io/colmap_converter.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ void CreateOneRigPerCamera(const std::unordered_map<camera_t, Camera>& cameras,
429429
Rig rig;
430430
rig.SetRigId(camera_id);
431431
rig.AddRefSensor(camera.SensorId());
432+
rigs[rig.RigId()] = rig;
432433
}
433434
}
434435

glomap/io/pose_io.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ void ReadRelPose(const std::string& file_path,
1010
ViewGraph& view_graph) {
1111
std::unordered_map<std::string, image_t> name_idx;
1212
image_t max_image_id = 0;
13+
camera_t max_camera_id = 0;
1314
for (const auto& [image_id, image] : images) {
1415
name_idx[image.file_name] = image_id;
1516

1617
max_image_id = std::max(max_image_id, image_id);
18+
max_camera_id = std::max(max_camera_id, image.camera_id);
1719
}
1820

1921
// Mark every edge in te view graph as invalid
@@ -42,14 +44,16 @@ void ReadRelPose(const std::string& file_path,
4244

4345
if (name_idx.find(file1) == name_idx.end()) {
4446
max_image_id += 1;
45-
images.insert(
46-
std::make_pair(max_image_id, Image(max_image_id, -1, file1)));
47+
max_camera_id += 1;
48+
images.insert(std::make_pair(max_image_id,
49+
Image(max_image_id, max_camera_id, file1)));
4750
name_idx[file1] = max_image_id;
4851
}
4952
if (name_idx.find(file2) == name_idx.end()) {
5053
max_image_id += 1;
51-
images.insert(
52-
std::make_pair(max_image_id, Image(max_image_id, -1, file2)));
54+
max_camera_id += 1;
55+
images.insert(std::make_pair(max_image_id,
56+
Image(max_image_id, max_camera_id, file2)));
5357
name_idx[file2] = max_image_id;
5458
}
5559

glomap/scene/view_graph.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ int ViewGraph::KeepLargestConnectedComponents(
8989
}
9090
}
9191

92+
max_img = 0;
9293
for (auto& [image_id, image] : images) {
9394
if (image.IsRegistered()) max_img++;
9495
}

0 commit comments

Comments
 (0)