This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

Ordinary I use the following metric: area(intersection(rect1 & rect2)) / area(union(rect1&rect2)) > 0.5

2 | No.2 Revision |

Ordinary I use the following metric:
~~area(intersection(rect1 & rect2)) ~~area(intersection(rect1,rect2)) / ~~area(union(rect1&rect2)) ~~area(union(rect1,rect2)) > 0.5

3 | No.3 Revision |

Ordinary I use the following metric: area(intersection(rect1,rect2)) / area(union(rect1,rect2)) > 0.5

If you use the C++ way (cv::Rect), you can easily say

```
interesect = r1 & r2;
```

for intersection calculation.

For CvRect:

```
CvRect intersect(CvRect r1, CvRect r2)
{
CvRect intersection;
// find overlapping region
intersection.x = (r1.x < r2.x) ? r2.x : r1.x;
intersection.y = (r1.y < r2.y) ? r2.y : r1.y;
intersection.width = (r1.x + r1.width < r2.x + r2.width) ?
r1.x + r1.width : r2.x + r2.width;
intersection.width -= intersection.x;
intersection.height = (r1.y + r1.height < r2.y + r2.height) ?
r1.y + r1.height : r2.y + r2.height;
intersection.height -= intersection.y;
// check for non-overlapping regions
if ((intersection.width <= 0) || (intersection.height <= 0)) {
intersection = cvRect(0, 0, 0, 0);
}
return intersection;
}
```

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.