(boxes, overlap_threshold, old_type=False)
| 77 | |
| 78 | |
| 79 | def nms_3d_faster(boxes, overlap_threshold, old_type=False): |
| 80 | x1 = boxes[:, 0] |
| 81 | y1 = boxes[:, 1] |
| 82 | z1 = boxes[:, 2] |
| 83 | x2 = boxes[:, 3] |
| 84 | y2 = boxes[:, 4] |
| 85 | z2 = boxes[:, 5] |
| 86 | score = boxes[:, 6] |
| 87 | area = (x2 - x1) * (y2 - y1) * (z2 - z1) |
| 88 | |
| 89 | I = np.argsort(score) |
| 90 | pick = [] |
| 91 | while I.size != 0: |
| 92 | last = I.size |
| 93 | i = I[-1] |
| 94 | pick.append(i) |
| 95 | |
| 96 | xx1 = np.maximum(x1[i], x1[I[: last - 1]]) |
| 97 | yy1 = np.maximum(y1[i], y1[I[: last - 1]]) |
| 98 | zz1 = np.maximum(z1[i], z1[I[: last - 1]]) |
| 99 | xx2 = np.minimum(x2[i], x2[I[: last - 1]]) |
| 100 | yy2 = np.minimum(y2[i], y2[I[: last - 1]]) |
| 101 | zz2 = np.minimum(z2[i], z2[I[: last - 1]]) |
| 102 | |
| 103 | l = np.maximum(0, xx2 - xx1) |
| 104 | w = np.maximum(0, yy2 - yy1) |
| 105 | h = np.maximum(0, zz2 - zz1) |
| 106 | |
| 107 | if old_type: |
| 108 | o = (l * w * h) / area[I[: last - 1]] |
| 109 | else: |
| 110 | inter = l * w * h |
| 111 | o = inter / (area[i] + area[I[: last - 1]] - inter) |
| 112 | |
| 113 | I = np.delete( |
| 114 | I, np.concatenate(([last - 1], np.where(o > overlap_threshold)[0])) |
| 115 | ) |
| 116 | |
| 117 | return pick |
| 118 | |
| 119 | |
| 120 | def nms_3d_faster_samecls(boxes, overlap_threshold, old_type=False): |
nothing calls this directly
no outgoing calls
no test coverage detected