diff --git a/gtsam/geometry/Cal3.cpp b/gtsam/geometry/Cal3.cpp index ec39d7eda..6210a6065 100644 --- a/gtsam/geometry/Cal3.cpp +++ b/gtsam/geometry/Cal3.cpp @@ -33,12 +33,11 @@ Cal3::Cal3(double fov, int w, int h) } /* ************************************************************************* */ -Cal3::Cal3(const std::string& path) - : fx_(320), fy_(320), s_(0), u0_(320), v0_(140) { +Cal3::Cal3(const std::string& path) { const auto buffer = path + std::string("/calibration_info.txt"); std::ifstream infile(buffer, std::ios::in); - if (infile) { + if (infile && !infile.eof()) { infile >> fx_ >> fy_ >> s_ >> u0_ >> v0_; } else { throw std::runtime_error("Cal3: Unable to load the calibration"); diff --git a/gtsam/geometry/Cal3.h b/gtsam/geometry/Cal3.h index b1a61c592..712414c82 100644 --- a/gtsam/geometry/Cal3.h +++ b/gtsam/geometry/Cal3.h @@ -103,7 +103,15 @@ class GTSAM_EXPORT Cal3 { /// @name Advanced Constructors /// @{ - /// load calibration from location (default name is calibration_info.txt) + /** + * Load calibration parameters from `calibration_info.txt` file located in + * `path` directory. + * + * The contents of calibration file should be the 5 parameters in order: + * `fx, fy, s, u0, v0` + * + * @param path path to directory containing `calibration_info.txt`. + */ Cal3(const std::string& path); /// @}