(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.2)
| 37 | |
| 38 | |
| 39 | def box_candidates(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.2): |
| 40 | # box1(4,n), box2(4,n) |
| 41 | # Compute candidate boxes which include follwing 5 things: |
| 42 | # box1 before augment, box2 after augment, wh_thr (pixels), aspect_ratio_thr, area_ratio |
| 43 | w1, h1 = box1[2] - box1[0], box1[3] - box1[1] |
| 44 | w2, h2 = box2[2] - box2[0], box2[3] - box2[1] |
| 45 | ar = np.maximum(w2 / (h2 + 1e-16), h2 / (w2 + 1e-16)) # aspect ratio |
| 46 | return ( |
| 47 | (w2 > wh_thr) |
| 48 | & (h2 > wh_thr) |
| 49 | & (w2 * h2 / (w1 * h1 + 1e-16) > area_thr) |
| 50 | & (ar < ar_thr) |
| 51 | ) # candidates |
| 52 | |
| 53 | |
| 54 | def random_perspective( |
no outgoing calls
no test coverage detected