(box1, box2)
| 189 | return max(0, x2 - x1) * max(0, y2 - y1) |
| 190 | |
| 191 | def IoU(box1, box2): |
| 192 | intersection = intersection_area(box1, box2) |
| 193 | union = box_area(box1) + box_area(box2) - intersection + 1e-6 |
| 194 | if box_area(box1) > 0 and box_area(box2) > 0: |
| 195 | ratio1 = intersection / box_area(box1) |
| 196 | ratio2 = intersection / box_area(box2) |
| 197 | else: |
| 198 | ratio1, ratio2 = 0, 0 |
| 199 | return max(intersection / union, ratio1, ratio2) |
| 200 | |
| 201 | def is_inside(box1, box2): |
| 202 | # return box1[0] >= box2[0] and box1[1] >= box2[1] and box1[2] <= box2[2] and box1[3] <= box2[3] |
no test coverage detected