| 78 | } |
| 79 | |
| 80 | static inline void nms_sorted_bboxes(const struct Dpp_Box* boxes, int boxes_size, int* picked, int* picked_size, |
| 81 | float nms_threshold) |
| 82 | { |
| 83 | float areas[boxes_size]; |
| 84 | int n_picked = 0; |
| 85 | for(int i = 0; i < boxes_size; i++) |
| 86 | { |
| 87 | float width = boxes[i].x1 - boxes[i].x0; |
| 88 | float height = boxes[i].y1 - boxes[i].y0; |
| 89 | |
| 90 | areas[i] = width * height; |
| 91 | } |
| 92 | |
| 93 | for(int i = 0; i < boxes_size; i++) |
| 94 | { |
| 95 | int keep = 1; |
| 96 | for(int j = 0; j < n_picked; j++) |
| 97 | { |
| 98 | // intersection over union |
| 99 | float inter_area = intersection_area(boxes[i], boxes[picked[j]]); |
| 100 | float union_area = areas[i] + areas[picked[j]] - inter_area; |
| 101 | // float IoU = inter_area / union_area |
| 102 | if(inter_area / union_area > nms_threshold) |
| 103 | keep = 0; |
| 104 | } |
| 105 | |
| 106 | if(keep) |
| 107 | { |
| 108 | picked[n_picked] = i; |
| 109 | n_picked++; |
| 110 | } |
| 111 | } |
| 112 | *picked_size = n_picked; |
| 113 | } |
| 114 | |
| 115 | void sort_boxes_by_score(struct Dpp_Box* boxes, int size) |
| 116 | { |
no test coverage detected