From 01b592c8e1dd5310b9cf82e8667ef48ffbb40df9 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Tue, 18 Oct 2016 17:48:36 +0200 Subject: [PATCH] calibrateCamera: mask f_x when using FIX_ASPECT_RATIO this avoids a singular Jacobian such that LM converges when DECOMP_LU is used. --- modules/calib3d/src/calibration.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index 0abbee65e0..c4c38be95f 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -787,7 +787,7 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, { if( dpdc_p ) { - dpdc_p[0] = 1; dpdc_p[1] = 0; + dpdc_p[0] = 1; dpdc_p[1] = 0; // dp_xdc_x; dp_xdc_y dpdc_p[dpdc_step] = 0; dpdc_p[dpdc_step+1] = 1; dpdc_p += dpdc_step*2; @@ -797,7 +797,7 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, { if( fixedAspectRatio ) { - dpdf_p[0] = 0; dpdf_p[1] = xd*aspectRatio; + dpdf_p[0] = 0; dpdf_p[1] = xd*aspectRatio; // dp_xdf_x; dp_xdf_y dpdf_p[dpdf_step] = 0; dpdf_p[dpdf_step+1] = yd; } @@ -1496,6 +1496,8 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints, param[0] = A(0, 0); param[1] = A(1, 1); param[2] = A(0, 2); param[3] = A(1, 2); std::copy(k, k + 14, param + 4); + if(flags & CALIB_FIX_ASPECT_RATIO) + mask[0] = 0; if( flags & CV_CALIB_FIX_FOCAL_LENGTH ) mask[0] = mask[1] = 0; if( flags & CV_CALIB_FIX_PRINCIPAL_POINT )