Calculate box iou. Note that jit version runs ~10x faster than the box_overlaps function in mmdet3d.core.evaluation. Note: This function is for counterclockwise boxes. Args: boxes (np.ndarray): Input bounding boxes with shape of (N, 4). query_boxes (np.ndarray):
(boxes, query_boxes, mode='iou', eps=0.0)
| 495 | |
| 496 | @numba.jit(nopython=True) |
| 497 | def iou_jit(boxes, query_boxes, mode='iou', eps=0.0): |
| 498 | """Calculate box iou. Note that jit version runs ~10x faster than the |
| 499 | box_overlaps function in mmdet3d.core.evaluation. |
| 500 | |
| 501 | Note: |
| 502 | This function is for counterclockwise boxes. |
| 503 | |
| 504 | Args: |
| 505 | boxes (np.ndarray): Input bounding boxes with shape of (N, 4). |
| 506 | query_boxes (np.ndarray): Query boxes with shape of (K, 4). |
| 507 | mode (str, optional): IoU mode. Defaults to 'iou'. |
| 508 | eps (float, optional): Value added to denominator. Defaults to 0. |
| 509 | |
| 510 | Returns: |
| 511 | np.ndarray: Overlap between boxes and query_boxes |
| 512 | with the shape of [N, K]. |
| 513 | """ |
| 514 | N = boxes.shape[0] |
| 515 | K = query_boxes.shape[0] |
| 516 | overlaps = np.zeros((N, K), dtype=boxes.dtype) |
| 517 | for k in range(K): |
| 518 | box_area = ((query_boxes[k, 2] - query_boxes[k, 0] + eps) * |
| 519 | (query_boxes[k, 3] - query_boxes[k, 1] + eps)) |
| 520 | for n in range(N): |
| 521 | iw = (min(boxes[n, 2], query_boxes[k, 2]) - |
| 522 | max(boxes[n, 0], query_boxes[k, 0]) + eps) |
| 523 | if iw > 0: |
| 524 | ih = (min(boxes[n, 3], query_boxes[k, 3]) - |
| 525 | max(boxes[n, 1], query_boxes[k, 1]) + eps) |
| 526 | if ih > 0: |
| 527 | if mode == 'iou': |
| 528 | ua = ((boxes[n, 2] - boxes[n, 0] + eps) * |
| 529 | (boxes[n, 3] - boxes[n, 1] + eps) + box_area - |
| 530 | iw * ih) |
| 531 | else: |
| 532 | ua = ((boxes[n, 2] - boxes[n, 0] + eps) * |
| 533 | (boxes[n, 3] - boxes[n, 1] + eps)) |
| 534 | overlaps[n, k] = iw * ih / ua |
| 535 | return overlaps |
| 536 | |
| 537 | |
| 538 | def projection_matrix_to_CRT_kitti(proj): |
nothing calls this directly
no outgoing calls
no test coverage detected