Skip to content

Commit d8bdfc5

Browse files
Input focal length guess if initial guess fails. (#346)
* switch to PIL library for Image * deactivate threading for cv image displays * Update MulticamGraph.py Preserve some backward compatibility with older python versions. * fix opencv windows * add option to manually input forcal length * remove debug option * PR review @LBern * switch to double in the first place * Revert "Merge pull request #304 from ethz-asl/feature/input_focal_length_guess" This reverts commit 2999e18, reversing changes made to ee2b09d. * Revert "Revert "Merge pull request #304 from ethz-asl/feature/input_focal_length_guess"" This reverts commit aac34c2. * move comment and fix indentation * revive compatibility for scripted usage Co-authored-by: Hannes Sommer <[email protected]>
1 parent cb6fb66 commit d8bdfc5

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <opencv2/core/eigen.hpp>
22
#include <Eigen/StdVector>
3+
#include <iostream>
4+
#include <cstdlib>
35

46
namespace aslam {
57

@@ -776,10 +778,23 @@ bool PinholeProjection<DISTORTION_T>::initializeIntrinsics(const std::vector<Gri
776778
}
777779
}
778780
}
779-
780-
//get the median of the guesses
781-
if(f_guesses.empty())
782-
return false;
781+
if(f_guesses.empty()) {
782+
const char* manual_input = std::getenv("KALIBR_MANUAL_FOCAL_LENGTH_INIT");
783+
if(manual_input != nullptr) {
784+
double input_guess;
785+
std::cout << "Initialization of focal length failed. Provide manual initialization: " << std::endl;
786+
std::cin >> input_guess;
787+
SM_ASSERT_GT(std::runtime_error, input_guess, 0.0,
788+
"Focal length needs to be positive.");
789+
std::cout << "Initializing focal length to " << input_guess << std::endl;
790+
f_guesses.push_back(input_guess);
791+
} else {
792+
std::cout << "Initialization of focal length failed. You can enable"
793+
<< " manual input by setting 'KALIBR_MANUAL_FOCAL_LENGTH_INIT'." << std::endl;
794+
return false;
795+
}
796+
}
797+
// Get the median of the guesses if available.
783798
double f0 = PinholeHelpers::medianOfVectorElements(f_guesses);
784799

785800
//set the estimate

0 commit comments

Comments
 (0)