Compute the areas of rectangles given two corners. Args: left_top (N, 2): left top corner. right_bottom (N, 2): right bottom corner. Returns: area (N): return the area.
(left_top, right_bottom)
| 1 | import numpy as np |
| 2 | |
| 3 | def area_of(left_top, right_bottom): |
| 4 | """ |
| 5 | Compute the areas of rectangles given two corners. |
| 6 | Args: |
| 7 | left_top (N, 2): left top corner. |
| 8 | right_bottom (N, 2): right bottom corner. |
| 9 | Returns: |
| 10 | area (N): return the area. |
| 11 | """ |
| 12 | hw = np.clip(right_bottom - left_top, 0.0, None) |
| 13 | return hw[..., 0] * hw[..., 1] |
| 14 | |
| 15 | def iou_of(boxes0, boxes1, eps=1e-5): |
| 16 | """ |