1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-05-23 19:50:20 +03:00
33 changed files with 5693 additions and 2439 deletions
+25 -5
View File
@@ -544,21 +544,41 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
return 0.f;
}
if( pointPolygonTest(_InputArray(fp1, n), fp2[0], false) >= 0 )
bool intersected = false;
// check if all of fp2's vertices is inside/on the edge of fp1.
int nVertices = 0;
for (int i=0; i<m; ++i)
nVertices += pointPolygonTest(_InputArray(fp1, n), fp2[i], false) >= 0;
// if all of fp2's vertices is inside/on the edge of fp1.
if (nVertices == m)
{
intersected = true;
result = fp2;
nr = m;
}
else if( pointPolygonTest(_InputArray(fp2, m), fp1[0], false) >= 0 )
else // otherwise check if fp2 is inside fp1.
{
result = fp1;
nr = n;
nVertices = 0;
for (int i=0; i<n; ++i)
nVertices += pointPolygonTest(_InputArray(fp2, m), fp1[i], false) >= 0;
// // if all of fp1's vertices is inside/on the edge of fp2.
if (nVertices == n)
{
intersected = true;
result = fp1;
nr = n;
}
}
else
if (!intersected)
{
_p12.release();
return 0.f;
}
area = (float)contourArea(_InputArray(result, nr), false);
}