From 103336c76e4c4352193182ed441a40b89a9eb75d Mon Sep 17 00:00:00 2001 From: Deanna Hood Date: Thu, 16 Apr 2015 11:59:05 -0400 Subject: [PATCH] Fix Bug #3989: correctly identify ellipse with its axes parallel to x-y axes during semi-major axis calculation --- modules/imgproc/src/shapedescr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/shapedescr.cpp b/modules/imgproc/src/shapedescr.cpp index 5e0c432d9c..65eddfd1af 100644 --- a/modules/imgproc/src/shapedescr.cpp +++ b/modules/imgproc/src/shapedescr.cpp @@ -447,9 +447,9 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) // store angle and radii rp[4] = -0.5 * atan2(gfp[2], gfp[1] - gfp[0]); // convert from APP angle usage t = sin(-2.0 * rp[4]); - if( fabs(t) > fabs(gfp[2])*min_eps ) + if( fabs(t) > min_eps ) t = gfp[2]/t; - else + else // ellipse is rotated by an integer multiple of pi/2 t = gfp[1] - gfp[0]; rp[2] = fabs(gfp[0] + gfp[1] - t); if( rp[2] > min_eps )