Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the bug for threshold update #148

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion glomap/estimators/bundle_adjustment.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ struct BundleAdjusterOptions : public OptimizationBaseOptions {
// Constrain the minimum number of views per track
int min_num_view_per_track = 3;

void UpdateThreshold() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this fix, I suggest the following:

struct BundleAdjusterOptions {
  double thres_loss_function = 1;

  std::shared_ptr<ceres::LossFunction> CreateLossFunction() {
    return std::make_shared<ceres::HuberLoss>(thres_loss_function);
  }
};

Since you explicitly have to call CreateLossFunction(), it is harder to accidentally forget calling the UpdateThreshold().

loss_function = std::make_shared<ceres::HuberLoss>(thres_loss_function);
}

BundleAdjusterOptions() : OptimizationBaseOptions() {
thres_loss_function = 1.;
loss_function = std::make_shared<ceres::HuberLoss>(thres_loss_function);
UpdateThreshold();
solver_options.max_num_iterations = 200;
}
};
Expand Down
6 changes: 5 additions & 1 deletion glomap/estimators/global_positioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ struct GlobalPositionerOptions : public OptimizationBaseOptions {
double constraint_reweight_scale =
1.0; // only relevant for POINTS_AND_CAMERAS_BALANCED

void UpdateThreshold() {
loss_function = std::make_shared<ceres::HuberLoss>(thres_loss_function);
}

GlobalPositionerOptions() : OptimizationBaseOptions() {
thres_loss_function = 1e-1;
loss_function = std::make_shared<ceres::HuberLoss>(thres_loss_function);
UpdateThreshold();
}
};

Expand Down
4 changes: 4 additions & 0 deletions glomap/exe/global_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ int RunMapper(int argc, char** argv) {
return EXIT_FAILURE;
}

options.mapper->opt_gp.UpdateThreshold();
options.mapper->opt_ba.UpdateThreshold();
GlobalMapper global_mapper(*options.mapper);

// Main solver
Expand Down Expand Up @@ -134,6 +136,8 @@ int RunMapperResume(int argc, char** argv) {
reconstruction.Read(input_path);
ConvertColmapToGlomap(reconstruction, cameras, images, tracks);

options.mapper->opt_gp.UpdateThreshold();
options.mapper->opt_ba.UpdateThreshold();
GlobalMapper global_mapper(*options.mapper);

// Main solver
Expand Down
1 change: 1 addition & 0 deletions pybind11
Submodule pybind11 added at 3ebdc5
1 change: 1 addition & 0 deletions pyglomap/pybind11
Submodule pybind11 added at 3ebdc5
Loading