|
@@ -102,6 +102,21 @@ static std::tuple<uint8_t, uint8_t, uint8_t> random_color(int id)
|
|
|
return hsv2bgr(h_plane, s_plane, 1);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+static float box_iou(const data::Box& box1, const data::Box& box2)
|
|
|
+{
|
|
|
+ float inter_x1 = std::max(box1.left, box2.left);
|
|
|
+ float inter_y1 = std::max(box1.top, box2.top);
|
|
|
+ float inter_x2 = std::min(box1.right, box2.right);
|
|
|
+ float inter_y2 = std::min(box1.bottom, box2.bottom);
|
|
|
+
|
|
|
+ float inter_area = std::max(0.0f, inter_x2 - inter_x1) * std::max(0.0f, inter_y2 - inter_y1);
|
|
|
+ float box1_area = (box1.right - box1.left) * (box1.bottom - box1.top);
|
|
|
+ float box2_area = (box2.right - box2.left) * (box2.bottom - box2.top);
|
|
|
+
|
|
|
+ return inter_area / (box1_area + box2_area - inter_area + 1e-6f); // Avoid division by zero
|
|
|
+}
|
|
|
+
|
|
|
void DrawNode::handle_data(std::shared_ptr<meta::MetaData>& meta_data)
|
|
|
{
|
|
|
bool show_track = true;
|