From d386428b2de233a095d93f1f9137928a1c12d53f Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Fri, 28 Feb 2020 12:21:09 +0200 Subject: [PATCH] bug: OpenCV distortion parameter format --- components/calibration/src/parameters.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/calibration/src/parameters.cpp b/components/calibration/src/parameters.cpp index a94777137..ef352b8a1 100644 --- a/components/calibration/src/parameters.cpp +++ b/components/calibration/src/parameters.cpp @@ -103,16 +103,23 @@ Mat Camera::intrinsicMatrix() const { Mat Camera::distortionCoefficients() const { Mat D; - // OpenCV distortion parameter sizes: 4, 5, 8, 12, 14 if (Camera::n_distortion_parameters <= 4) { D = Mat::zeros(4, 1, CV_64FC1); } else if (Camera::n_distortion_parameters <= 5) { D = Mat::zeros(5, 1, CV_64FC1); } else if (Camera::n_distortion_parameters <= 8) { D = Mat::zeros(8, 1, CV_64FC1); } else if (Camera::n_distortion_parameters <= 12) { D = Mat::zeros(12, 1, CV_64FC1); } else if (Camera::n_distortion_parameters <= 14) { D = Mat::zeros(14, 1, CV_64FC1); } - for (int i = 0; i < Camera::n_distortion_parameters; i++) { - D.at<double>(i) = data[Parameter::DISTORTION+i]; + switch(Camera::n_distortion_parameters) { + case 14: + case 12: + case 8: + case 5: + D.at<double>(4) = data[Parameter::K3]; + case 4: + D.at<double>(0) = data[Parameter::K1]; + D.at<double>(1) = data[Parameter::K2]; } + return D; } -- GitLab