From 6b15ef3f627aa7f9f8d840a36fac1098567ad95c Mon Sep 17 00:00:00 2001 From: Rostislav Vasilikhin Date: Thu, 26 Jan 2023 03:03:33 +0100 Subject: [PATCH] fix for 1-camera and stereocalib --- modules/ccalib/src/omnidir.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ccalib/src/omnidir.cpp b/modules/ccalib/src/omnidir.cpp index 6c54a527c1e..c861e35290b 100644 --- a/modules/ccalib/src/omnidir.cpp +++ b/modules/ccalib/src/omnidir.cpp @@ -1782,13 +1782,15 @@ void cv::omnidir::internal::estimateUncertainties(InputArrayOfArrays objectPoint Mat sigma_x; meanStdDev(reprojError.reshape(1,1), noArray(), sigma_x); - sigma_x *= sqrt(2.0*(double)reprojError.total()/(2.0*(double)reprojError.total() - 1.0)); - double s = sigma_x.at(0); Mat _JTJ_inv, _JTE; computeJacobian(objectPoints, imagePoints, parameters, _JTJ_inv, _JTE, flags, 0.0); sqrt(_JTJ_inv, _JTJ_inv); + int nParams = _JTJ_inv.rows; + sigma_x *= sqrt(2.0*(double)reprojError.total()/(2.0*(double)reprojError.total() - nParams)); + double s = sigma_x.at(0); + errors = 3 * s * _JTJ_inv.diag(); rms = 0; @@ -1868,13 +1870,15 @@ void cv::omnidir::internal::estimateUncertaintiesStereo(InputArrayOfArrays objec Mat sigma_x; meanStdDev(reprojErrorAll.reshape(1,1), noArray(), sigma_x); - sigma_x *= sqrt(2.0*(double)reprojErrorAll.total()/(2.0*(double)reprojErrorAll.total() - 1.0)); - double s = sigma_x.at(0); Mat _JTJ_inv, _JTE; computeJacobianStereo(objectPoints, imagePoints1, imagePoints2, _parameters, _JTJ_inv, _JTE, flags, 0.0); cv::sqrt(_JTJ_inv, _JTJ_inv); + int nParams = _JTJ_inv.rows; + sigma_x *= sqrt(2.0*(double)reprojErrorAll.total()/(2.0*(double)reprojErrorAll.total() - nParams)); + double s = sigma_x.at(0); + errors = 3 * s * _JTJ_inv.diag(); rms = 0;