From 3830b8bcb88380ac3ef36664638b68bbfcca98df Mon Sep 17 00:00:00 2001 From: DavidTorresOcana Date: Sun, 27 Oct 2019 19:01:10 +0100 Subject: [PATCH 1/2] Add potential fixes for fisheye model --- camera_calibration_parsers/src/parse_ini.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/camera_calibration_parsers/src/parse_ini.cpp b/camera_calibration_parsers/src/parse_ini.cpp index c955934e..e1632d36 100644 --- a/camera_calibration_parsers/src/parse_ini.cpp +++ b/camera_calibration_parsers/src/parse_ini.cpp @@ -91,6 +91,15 @@ bool writeCalibrationIni(std::ostream& out, const std::string& camera_name, sensor_msgs::distortion_models::PLUMB_BOB.c_str(), (int)cam_info.D.size()); return false; } + else if ( cam_info.distortion_model != sensor_msgs::distortion_models::FISHEYE || + cam_info.D.size() != 5) { + ROS_ERROR("Videre INI format can only save calibrations using the plumb bob distortion model. " + "Use the YAML format instead.\n" + "\tdistortion_model = '%s', expected '%s'\n" + "\tD.size() = %d, expected 5", cam_info.distortion_model.c_str(), + sensor_msgs::distortion_models::FISHEYE.c_str(), (int)cam_info.D.size()); + return false; + } out.precision(5); out << std::fixed; @@ -210,7 +219,12 @@ bool parseCalibrationIniRange(Iterator first, Iterator last, // Figure out the distortion model if (cam_info.D.size() == 5) - cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; + if (cam_info.distortion_model.find(sensor_msgs::distortion_models::FISHEYE)!=std::string::npos){ + cam_info.distortion_model = sensor_msgs::distortion_models::FISHEYE; + } + else{ + cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; + } else if (cam_info.D.size() == 8) cam_info.distortion_model = sensor_msgs::distortion_models::RATIONAL_POLYNOMIAL; From c3f4c1d3b723320dff2484f6768f8a8c8fc59802 Mon Sep 17 00:00:00 2001 From: DavidTorresOcana Date: Sun, 2 Aug 2020 16:22:44 +0200 Subject: [PATCH 2/2] Change FISHEYE distortion model for EQUIDISTANT --- camera_calibration_parsers/src/parse_ini.cpp | 21 +++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/camera_calibration_parsers/src/parse_ini.cpp b/camera_calibration_parsers/src/parse_ini.cpp index e1632d36..76382e23 100644 --- a/camera_calibration_parsers/src/parse_ini.cpp +++ b/camera_calibration_parsers/src/parse_ini.cpp @@ -91,13 +91,13 @@ bool writeCalibrationIni(std::ostream& out, const std::string& camera_name, sensor_msgs::distortion_models::PLUMB_BOB.c_str(), (int)cam_info.D.size()); return false; } - else if ( cam_info.distortion_model != sensor_msgs::distortion_models::FISHEYE || - cam_info.D.size() != 5) { - ROS_ERROR("Videre INI format can only save calibrations using the plumb bob distortion model. " + else if ( cam_info.distortion_model != sensor_msgs::distortion_models::EQUIDISTANT || + cam_info.D.size() != 4) { + ROS_ERROR("Videre INI format can only save calibrations using the equidistant distortion model. " "Use the YAML format instead.\n" "\tdistortion_model = '%s', expected '%s'\n" - "\tD.size() = %d, expected 5", cam_info.distortion_model.c_str(), - sensor_msgs::distortion_models::FISHEYE.c_str(), (int)cam_info.D.size()); + "\tD.size() = %d, expected 4", cam_info.distortion_model.c_str(), + sensor_msgs::distortion_models::EQUIDISTANT.c_str(), (int)cam_info.D.size()); return false; } @@ -219,15 +219,12 @@ bool parseCalibrationIniRange(Iterator first, Iterator last, // Figure out the distortion model if (cam_info.D.size() == 5) - if (cam_info.distortion_model.find(sensor_msgs::distortion_models::FISHEYE)!=std::string::npos){ - cam_info.distortion_model = sensor_msgs::distortion_models::FISHEYE; - } - else{ - cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; - } + cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; else if (cam_info.D.size() == 8) cam_info.distortion_model = sensor_msgs::distortion_models::RATIONAL_POLYNOMIAL; - + else if (cam_info.D.size() == 4){ + cam_info.distortion_model = sensor_msgs::distortion_models::EQUIDISTANT; + } return info.hit; } /// \endcond