Skip to content

Commit 7d9014e

Browse files
authored
Merge pull request opencv#26263 from mlourakis:4.x
inversion checks
2 parents 40428d9 + fa6d652 commit 7d9014e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/calib3d/src/sqpnp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ bool PoseSolver::invertSPD3x3(const cv::Matx<double, 3, 3>& A, cv::Matx<double,
453453
v[0]=L[6]*D[0];
454454
v[1]=L[7]*D[1];
455455
D[2]=A(2, 2)-L[6]*v[0]-L[7]*v[1];
456+
if(D[2]<=1E-10) return false;
456457
//L[8]=1.0;
457458

458459
D[0]=1.0/D[0];
@@ -510,7 +511,7 @@ bool PoseSolver::analyticalInverse3x3Symm(const cv::Matx<double, 3, 3>& Q,
510511
t12 = c * c;
511512
double det = -t4 * f + a * t2 + t7 * f - 2.0 * t9 * e + t12 * d;
512513

513-
if (fabs(det) < threshold) return false;
514+
if (fabs(det) < threshold) { cv::invert(Q, Qinv, cv::DECOMP_SVD); return false; } // fall back to pseudoinverse
514515

515516
// 3. Inverse
516517
double t15, t20, t24, t30;

0 commit comments

Comments
 (0)