leon il y a 4 semaines
Parent
commit
7dbb167790
4 fichiers modifiés avec 109 ajouts et 64 suppressions
  1. 2 1
      .vscode/settings.json
  2. 5 3
      src/graph/graph.cpp
  3. 18 3
      src/main.cpp
  4. 84 57
      workspace/demo.json

+ 2 - 1
.vscode/settings.json

@@ -63,6 +63,7 @@
         "set": "cpp",
         "any": "cpp",
         "span": "cpp",
-        "valarray": "cpp"
+        "valarray": "cpp",
+        "__config": "cpp"
     }
 }

+ 5 - 3
src/graph/graph.cpp

@@ -1,4 +1,6 @@
 #include "graph/graph.hpp"
+#include <fstream>
+
 
 namespace Graph
 {
@@ -26,9 +28,9 @@ static GNode::DecodeType string_to_decode_type(const std::string& type_str) {
 
 void Graph::create_from_json(const std::string& json_path)
 {
-    // 1. Read and parse JSON file
     std::ifstream json_file(json_path);
-    if (!json_file.is_open()) {
+    if (!json_file.is_open()) 
+    {
         throw std::runtime_error("Failed to open JSON file: " + json_path);
     }
 
@@ -148,7 +150,7 @@ void Graph::create_from_json(const std::string& json_path)
                         } 
                         else if (node_type == "Push")
                         {
-                            new_node = std::make_shared<GNode::PushNode>(node_id);
+                            new_node = std::make_shared<GNode::HttpPushNode>(node_id);
 
                         } 
                         else if (node_type == "Recorder") 

+ 18 - 3
src/main.cpp

@@ -9,6 +9,8 @@
 
 #include "plog/Log.h"
 #include "plog/Initializers/RollingFileInitializer.h"
+#include "graph/graph.hpp"
+
 
 void run_from_json()
 {
@@ -145,12 +147,25 @@ void test_multi()
     getchar();
 }
 
+void test_from_json(const std::string& json_path)
+{
+    
+}
+
 int main()
 {
     plog::init(plog::info, "log/vsp.log", 1000000, 5);
-    PLOGI.printf("Start pipepline test_yolo");
-    test_yolo();
-    
+    Graph::Graph graph_manager;
+    graph_manager.create_from_json("workspace/demo.json");
+
+    for (const auto& p : graph_manager.getPipelines()) {
+        std::cout << "Pipeline ID: " << p.pipeline_id << ", Description: " << p.description << ", Nodes: " << p.nodes.size() << std::endl;
+        for(const auto& node : p.nodes) {
+            std::cout << "  - Node Name: " << node->get_name() << std::endl;
+        }
+    }
+    graph_manager.start_pipelines();
+    getchar();
     return 0;
 }
 

+ 84 - 57
workspace/demo.json

@@ -1,15 +1,91 @@
 {
     "models": {
         "yolo_model_main": {
-            "model_path": "model/yolo11s.engine",
-            "model_type": "YOLO11",
+            "model_path": "model/model1.engine",
+            "model_type": "YOLO11SEG",
             "names": [
                 "person",
+                "bicycle",
                 "car",
-                "close",
-                "open"
+                "motorcycle",
+                "airplane",
+                "bus",
+                "train",
+                "truck",
+                "boat",
+                "traffic light",
+                "fire hydrant",
+                "stop sign",
+                "parking meter",
+                "bench",
+                "bird",
+                "cat",
+                "dog",
+                "horse",
+                "sheep",
+                "cow",
+                "elephant",
+                "bear",
+                "zebra",
+                "giraffe",
+                "backpack",
+                "umbrella",
+                "handbag",
+                "tie",
+                "suitcase",
+                "frisbee",
+                "skis",
+                "snowboard",
+                "sports ball",
+                "kite",
+                "baseball bat",
+                "baseball glove",
+                "skateboard",
+                "surfboard",
+                "tennis racket",
+                "bottle",
+                "wine glass",
+                "cup",
+                "fork",
+                "knife",
+                "spoon",
+                "bowl",
+                "banana",
+                "apple",
+                "sandwich",
+                "orange",
+                "broccoli",
+                "carrot",
+                "hot dog",
+                "pizza",
+                "donut",
+                "cake",
+                "chair",
+                "couch",
+                "potted plant",
+                "bed",
+                "dining table",
+                "toilet",
+                "tv",
+                "laptop",
+                "mouse",
+                "remote",
+                "keyboard",
+                "cell phone",
+                "microwave",
+                "oven",
+                "toaster",
+                "sink",
+                "refrigerator",
+                "book",
+                "clock",
+                "vase",
+                "scissors",
+                "teddy bear",
+                "hair drier",
+                "toothbrush"
             ],
-            "gpu_id": 0,
+            "gpu_id": 1,
             "confidence_threshold": 0.25,
             "nms_threshold": 0.45
         }
@@ -23,10 +99,10 @@
                     "node_id": "src_0",
                     "node_type": "Source",
                     "params": {
-                        "stream_url": "rtsp://xxxx_cam0",
-                        "gpu_id": 0,
+                        "stream_url": "carperson.mp4",
+                        "gpu_id": 1,
                         "decode_type": "GPU",
-                        "skip_frame": 10
+                        "skip_frame": 1
                     }
                 },
                 {
@@ -68,55 +144,6 @@
                     }
                 }
             ]
-        },
-        {
-            "pipeline_id": "pipeline_1",
-            "description": "处理摄像头1的视频流",
-            "nodes": [
-                {
-                    "node_id": "src_1",
-                    "node_type": "Source",
-                    "params": {
-                        "stream_url": "rtsp://xxxx_cam1",
-                        "gpu_id": 0,
-                        "decode_type": "GPU",
-                        "skip_frame": 10
-                    }
-                },
-                {
-                    "node_id": "infer_1",
-                    "node_type": "Inference",
-                    "params": {
-                        "model_id": "yolo_model_main",
-                    }
-                },
-                {
-                    "node_id": "track_1",
-                    "node_type": "Tracker",
-                    "params": {
-                        "track_name": "person",
-                        "track_frame": 30,
-                        "track_distance": 30
-                    }
-                },
-                {
-                    "node_id": "analyze_1",
-                    "node_type": "Analyzer",
-                    "params": {}
-                },
-                {
-                    "node_id": "draw_1",
-                    "node_type": "Drawer",
-                    "params": {}
-                },
-                {
-                    "node_id": "record_1",
-                    "node_type": "Recorder",
-                    "params": {
-                        "record_path": "result/result_pipeline1.mp4"
-                    }
-                }
-            ]
         }
     ]
 }