Commit 36291faf authored by Hamdi Sahloul's avatar Hamdi Sahloul

Affine feature2D: Prevent crashing due to invalid covariant matrix

parent bccbec79
......@@ -170,6 +170,10 @@ bool calcAffineAdaptation(const Mat & fimage, Elliptic_KeyPoint & keypoint)
//Differentation scale selection
selDifferentiationScale(warpedImg, Lxm2smooth, Lxmysmooth, Lym2smooth, si,
Point(cx, cy));
if (Lym2smooth.empty()) {
divergence = true;
continue;
}
//Spatial Localization
cxPr = cx; //Previous iteration point in normalized window
......@@ -428,7 +432,8 @@ float selDifferentiationScale(const Mat & img, Mat & Lxm2smooth, Mat & Lxmysmoot
eigen(M, eval);
double eval1 = std::abs(eval.at<float> (0, 0));
double eval2 = std::abs(eval.at<float> (1, 0));
double q = min(eval1, eval2) / max(eval1, eval2);
double m = max(eval1, eval2);
double q = (m == 0) ? -1 : min(eval1, eval2) / m;
if (q >= qMax)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment