Function
iou
(r0: np.array, r1: np.array)
Source from the content-addressed store, hash-verified
| 16 | |
| 17 | |
| 18 | def iou(r0: np.array, r1: np.array) -> float: |
| 19 | xx1 = max(r0[1], r1[1]) |
| 20 | yy1 = max(r0[2], r1[2]) |
| 21 | xx2 = min(r0[3], r1[3]) |
| 22 | yy2 = min(r0[4], r1[4]) |
| 23 | dx = max(0., xx2 - xx1) |
| 24 | dy = max(0, yy2 - yy1) |
| 25 | i = dx * dy |
| 26 | u = (r0[3] - r0[1]) * (r0[4] - r0[2]) + (r1[3] - r1[1]) * (r1[4] - |
| 27 | r1[2]) - i |
| 28 | iou = i / u |
| 29 | return iou |
| 30 | |
| 31 | |
| 32 | def is_overlap(rect1: np.array, rect2: np.array, iou_thr: float) -> bool: |
Tested by
no test coverage detected