From 8a7b4760ac0c071509e0de938b3d8602ef8b8142 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sun, 6 Jun 2010 17:21:40 +0000 Subject: [PATCH] avoid one possible singularity in cvFindHomography --- modules/calib3d/src/fundam.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index 944785c1f4..ece3889214 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -184,7 +184,8 @@ bool CvHomographyEstimator::refine( const CvMat* m1, const CvMat* m2, CvMat* mod { const double* h = _param->data.db; double Mx = M[i].x, My = M[i].y; - double ww = 1./(h[6]*Mx + h[7]*My + 1.); + double ww = h[6]*Mx + h[7]*My + 1.; + ww = fabs(ww) > DBL_EPSILON ? 1./ww : 0; double _xi = (h[0]*Mx + h[1]*My + h[2])*ww; double _yi = (h[3]*Mx + h[4]*My + h[5])*ww; double err[] = { _xi - m[i].x, _yi - m[i].y };