Commit 10e639cd authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #7966 from Tetragramm:Issue#4235

parents c9cedf3c 7cc0b0f9
......@@ -50,6 +50,7 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double eps = 1.e-5;
double mmm;
double result = 0;
bool anyA = false, anyB = false;
HuMoments( moments(contour1), ma );
HuMoments( moments(contour2), mb );
......@@ -62,6 +63,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if (ama > 0)
anyA = true;
if (amb > 0)
anyB = true;
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
......@@ -90,6 +96,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if (ama > 0)
anyA = true;
if (amb > 0)
anyB = true;
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
......@@ -118,6 +129,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if (ama > 0)
anyA = true;
if (amb > 0)
anyB = true;
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
......@@ -145,6 +161,12 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
CV_Error( CV_StsBadArg, "Unknown comparison method" );
}
//If anyA and anyB are both true, the result is correct.
//If anyA and anyB are both false, the distance is 0, perfect match.
//If only one is true, then it's a false 0 and return large error.
if (anyA != anyB)
result = DBL_MAX;
return result;
}
......
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