leon 1 месяц назад
Родитель
Сommit
8b3852d9a0
2 измененных файлов с 12 добавлено и 3 удалено
  1. 1 1
      src/main.cpp
  2. 11 2
      src/nodes/draw/drawNode.cpp

+ 1 - 1
src/main.cpp

@@ -32,7 +32,7 @@ void test_yolo()
 {
     std::vector<std::string> names = { "person", "clothes", "vest" };
     std::shared_ptr<GNode::StreamNode> src_node0   = std::make_shared<GNode::StreamNode>("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, GNode::DecodeType::GPU);
-    src_node0->set_skip_frame(10);
+    src_node0->set_skip_frame(1);
 
     std::shared_ptr<Infer> yolo_model = load("model/yolo11s.engine", ModelType::YOLO11, names, 0, 0.25, 0.45);
     std::shared_ptr<GNode::InferNode> infer_node   = std::make_shared<GNode::InferNode>("yolo11");

+ 11 - 2
src/nodes/draw/drawNode.cpp

@@ -42,8 +42,17 @@ void DrawNode::work()
 
                 std::tuple<int, int, int, int> pbox = std::make_tuple(box.left, box.top, box.right, box.bottom);
                 int x, y;
-                std::tie(x, y) = pm.selectOptimalPosition(pbox, image_width, image_height, box.label);
-                std::string text = str_format("%s %.2f id=%d", box.label.c_str(), box.score, box.track_id);
+                std::string text;
+                if (box.track_id != -1) 
+                {
+                    text = str_format("%s %.2f id=%d", box.label.c_str(), box.score, box.track_id);
+                }
+                else
+                {
+                    text = str_format("%s %.2f", box.label.c_str(), box.score);
+                }
+                std::tie(x, y) = pm.selectOptimalPosition(pbox, image_width, image_height, text);
+                
                 cv::putText(image, text, cv::Point(x, y), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0), 2);
             }
             metaData->draw_image = image;