Perform Non-Maxima Supression on a list of given detections.
103 std::vector<Detection> detections =
104 convert_to_detections(config, detected_boxes);
106 const unsigned int num_detections =
static_cast<unsigned int>(detections.size());
107 for (
unsigned int c = 0; c < config.num_classes; ++c)
110 std::sort(detections.begin(), detections.begin() +
static_cast<std::ptrdiff_t
>(num_detections),
111 [c](Detection& detection1, Detection& detection2)
113 return (detection1.classes[c] - detection2.classes[c]) > 0;
116 for (
unsigned int d = 0; d < num_detections; ++d)
119 if (detections[d].classes[c] == 0.f)
125 const Box& box1 = detections[d].box;
126 for (
unsigned int b = d + 1; b < num_detections; ++b)
128 const Box& box2 = detections[b].box;
129 if (iou(box1, box2) > config.iou_threshold)
131 detections[b].classes[c] = 0.f;