Browse Source

update analyze

leon 2 weeks ago
parent
commit
c6e03608ba
4 changed files with 47 additions and 5 deletions
  1. 3 3
      src/nodes/analyze/analyzeNode.cpp
  2. 1 1
      src/nodes/base/base.hpp
  3. 14 1
      src/pipeline/pipeline.cpp
  4. 29 0
      workspace/demo.json

+ 3 - 3
src/nodes/analyze/analyzeNode.cpp

@@ -21,8 +21,8 @@ void AnalyzeNode::handle_data(std::shared_ptr<meta::BaseData>& meta_data)
     }
 
     auto config_data = std::dynamic_pointer_cast<meta::AnalyzeConfigData>(config_data_);
-    std::vector<std::string> task_names = config_data->task_names;
-    if (task_names.empty()) 
+    std::vector<std::string> algorithm_names = config_data->algorithm_names;
+    if (algorithm_names.empty()) 
     {
         PLOGE.printf("AnalyzeNode : [%s] No task names provided", name_.c_str());
         return;
@@ -32,7 +32,7 @@ void AnalyzeNode::handle_data(std::shared_ptr<meta::BaseData>& meta_data)
     int width = frame_data->image.cols;
     int height = frame_data->image.rows;
 
-    for (const auto& task_name : task_names) 
+    for (const auto& task_name : algorithm_names) 
     {
         if (task_name == "cross_line") 
         {

+ 1 - 1
src/nodes/base/base.hpp

@@ -103,7 +103,7 @@ public:
 
     inline bool set_config_data(std::shared_ptr<meta::BaseData> config_data)
     {
-        if (config_data == nullptr || config_data->get_type() != meta::DataType::CONFIG) 
+        if (config_data == nullptr || config_data->data_type != meta::DataType::CONFIG) 
         {
             PLOGE.printf("Node : [%s] set_config_data failed, invalid config data", name_.c_str());
             return false;

+ 14 - 1
src/pipeline/pipeline.cpp

@@ -139,7 +139,20 @@ void PipelineManager::create_from_json(const std::string& json_path)
                         else if (node_type == "Analyzer") 
                         {
                             new_node = std::make_shared<GNode::AnalyzeNode>(node_id);
-
+                            std::shared_ptr<meta::AnalyzeConfigData> config_data = std::make_shared<meta::AnalyzeConfigData>();
+                            config_data->algorithm_names = params.at("algorithm_names").get<std::vector<std::string>>();
+                            for (const auto& [name, points] : params["algorithm_params_fence"].items()) 
+                            {
+                                std::vector<cv::Point> fence_points;
+                                for (const auto& point : points) 
+                                {
+                                    int x = point.at("x").get<int>();
+                                    int y = point.at("y").get<int>();
+                                    fence_points.emplace_back(x, y);
+                                }
+                                config_data->algorithm_params_fence[name] = fence_points;
+                            }
+                            new_node->set_config_data(config_data);
                         } 
                         else if (node_type == "Drawer") 
                         {

+ 29 - 0
workspace/demo.json

@@ -131,6 +131,35 @@
                         "track_distance": 30
                     }
                 },
+                {
+                    "node_id": "analyze_0",
+                    "node_type": "Analyzer",
+                    "params": {
+                        "algorithm_names": [
+                            "person"
+                        ],
+                        "algorithm_params_fence": {
+                            "person": [
+                                {
+                                    "x": 100,
+                                    "y": 100
+                                },
+                                {
+                                    "x": 100,
+                                    "y": 200
+                                },
+                                {
+                                    "x": 200,
+                                    "y": 200
+                                },
+                                {
+                                    "x": 200,
+                                    "y": 100
+                                }
+                            ]
+                        }
+                    }
+                },
                 {
                     "node_id": "draw_0",
                     "node_type": "Drawer",