(rect1, rect2, iou_threshold)
| 81 | |
| 82 | |
| 83 | def is_overlap_v2(rect1, rect2, iou_threshold): |
| 84 | xx1 = max(rect1[0], rect2[0]) |
| 85 | yy1 = max(rect1[1], rect2[1]) |
| 86 | xx2 = min(rect1[2], rect2[2]) |
| 87 | yy2 = min(rect1[3], rect2[3]) |
| 88 | dx = max(0, xx2 - xx1 + 1) |
| 89 | dy = max(0, yy2 - yy1 + 1) |
| 90 | i = dx * dy |
| 91 | u = (rect1[2] - rect1[0] + 1) * (rect1[3] - rect1[1] + 1) + ( |
| 92 | rect2[2] - rect2[0] + 1) * (rect2[3] - rect2[1] + 1) - i |
| 93 | ov = i / u |
| 94 | return rect1[4] * rect2[4] < ov or ov >= iou_threshold |
| 95 | |
| 96 | |
| 97 | def is_overlap_v1(rect1, rect2, iou_threshold): |