Improved constructor for loading parameters from file

release/4.3a0
Varun Agrawal 2020-12-02 08:36:23 -05:00
parent e488dc8e9c
commit ecb0af57fd
2 changed files with 11 additions and 4 deletions

View File

@ -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");

View File

@ -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);
/// @}