34 #include <ceres/ceres.h>
43 class BundleAdjustmentIterationCallback :
public ceres::IterationCallback {
45 explicit BundleAdjustmentIterationCallback(Thread* thread)
48 virtual ceres::CallbackReturnType operator()(
49 const ceres::IterationSummary& summary) {
50 CHECK_NOTNULL(thread_);
51 thread_->BlockIfPaused();
52 if (thread_->IsStopped()) {
53 return ceres::SOLVER_TERMINATE_SUCCESSFULLY;
55 return ceres::SOLVER_CONTINUE;
67 : options_(options), reconstruction_(reconstruction) {}
69 void BundleAdjustmentController::Run() {
70 CHECK_NOTNULL(reconstruction_);
74 const std::vector<image_t>& reg_image_ids = reconstruction_->
RegImageIds();
76 if (reg_image_ids.size() < 2) {
77 std::cout <<
"WARNING: Need at least two views." <<
std::endl;
85 ba_options.solver_options.minimizer_progress_to_stdout =
true;
87 BundleAdjustmentIterationCallback iteration_callback(
this);
88 ba_options.solver_options.callbacks.push_back(&iteration_callback);
91 BundleAdjustmentConfig ba_config;
92 for (
const image_t image_id : reg_image_ids) {
93 ba_config.AddImage(image_id);
95 ba_config.SetConstantPose(reg_image_ids[0]);
96 ba_config.SetConstantTvec(reg_image_ids[1], {0});
99 BundleAdjuster bundle_adjuster(ba_options, ba_config);
100 bundle_adjuster.Solve(reconstruction_);
BundleAdjustmentController(const OptionManager &options, Reconstruction *reconstruction)
std::shared_ptr< BundleAdjustmentOptions > bundle_adjustment
size_t FilterObservationsWithNegativeDepth()
const std::vector< image_t > & RegImageIds() const
const Timer & GetTimer() const
void PrintMinutes() const
QTextStream & endl(QTextStream &stream)
void PrintHeading1(const std::string &heading)