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

Input focal length guess if initial guess fails. #346

Merged
merged 14 commits into from
Feb 9, 2020
Merged
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <opencv2/core/eigen.hpp>
#include <Eigen/StdVector>
#include <iostream>
#include <cstdlib>

namespace aslam {

Expand Down Expand Up @@ -776,10 +778,23 @@ bool PinholeProjection<DISTORTION_T>::initializeIntrinsics(const std::vector<Gri
}
}
}

//get the median of the guesses
if(f_guesses.empty())
return false;
if(f_guesses.empty()) {
const char* manual_input = std::getenv("KALIBR_MANUAL_FOCAL_LENGTH_INIT");
if(manual_input != nullptr) {
double input_guess;
std::cout << "Initialization of focal length failed. Provide manual initialization: " << std::endl;
std::cin >> input_guess;
SM_ASSERT_GT(std::runtime_error, input_guess, 0.0,
"Focal length needs to be positive.");
std::cout << "Initializing focal length to " << input_guess << std::endl;
f_guesses.push_back(input_guess);
} else {
std::cout << "Initialization of focal length failed. You can enable"
<< " manual input by setting 'KALIBR_MANUAL_FOCAL_LENGTH_INIT'." << std::endl;
return false;
}
}
// Get the median of the guesses if available.
double f0 = PinholeHelpers::medianOfVectorElements(f_guesses);

//set the estimate
Expand Down