Compute intersection over union of two rectangles.
(r1, r2)
| 136 | |
| 137 | |
| 138 | def _iou(r1, r2): |
| 139 | """Compute intersection over union of two rectangles.""" |
| 140 | ix = max(0, min(r1[2], r2[2]) - max(r1[0], r2[0])) |
| 141 | iy = max(0, min(r1[3], r2[3]) - max(r1[1], r2[1])) |
| 142 | intersection = ix * iy # intersection area |
| 143 | if not intersection: |
| 144 | return 0 |
| 145 | area1 = (r1[2] - r1[0]) * (r1[3] - r1[1]) |
| 146 | area2 = (r2[2] - r2[0]) * (r2[3] - r2[1]) |
| 147 | return intersection / (area1 + area2 - intersection) |
| 148 | |
| 149 | |
| 150 | def intersects_words_h(bbox, y, word_rects) -> bool: |
no outgoing calls
no test coverage detected
searching dependent graphs…