(boxes, overlap_threshold, old_type=False)
| 41 | |
| 42 | |
| 43 | def nms_2d_faster(boxes, overlap_threshold, old_type=False): |
| 44 | x1 = boxes[:, 0] |
| 45 | y1 = boxes[:, 1] |
| 46 | x2 = boxes[:, 2] |
| 47 | y2 = boxes[:, 3] |
| 48 | score = boxes[:, 4] |
| 49 | area = (x2 - x1) * (y2 - y1) |
| 50 | |
| 51 | I = np.argsort(score) |
| 52 | pick = [] |
| 53 | while I.size != 0: |
| 54 | last = I.size |
| 55 | i = I[-1] |
| 56 | pick.append(i) |
| 57 | |
| 58 | xx1 = np.maximum(x1[i], x1[I[: last - 1]]) |
| 59 | yy1 = np.maximum(y1[i], y1[I[: last - 1]]) |
| 60 | xx2 = np.minimum(x2[i], x2[I[: last - 1]]) |
| 61 | yy2 = np.minimum(y2[i], y2[I[: last - 1]]) |
| 62 | |
| 63 | w = np.maximum(0, xx2 - xx1) |
| 64 | h = np.maximum(0, yy2 - yy1) |
| 65 | |
| 66 | if old_type: |
| 67 | o = (w * h) / area[I[: last - 1]] |
| 68 | else: |
| 69 | inter = w * h |
| 70 | o = inter / (area[i] + area[I[: last - 1]] - inter) |
| 71 | |
| 72 | I = np.delete( |
| 73 | I, np.concatenate(([last - 1], np.where(o > overlap_threshold)[0])) |
| 74 | ) |
| 75 | |
| 76 | return pick |
| 77 | |
| 78 | |
| 79 | def nms_3d_faster(boxes, overlap_threshold, old_type=False): |
nothing calls this directly
no outgoing calls
no test coverage detected