Selaa lähdekoodia

update analyze node

leon 2 kuukautta sitten
vanhempi
commit
5f012d0aa6

+ 4 - 6
src/common/utils.hpp

@@ -2,6 +2,10 @@
 #define UTILS_HPP
 #include <memory>
 #include <string>
+#include <chrono>   // 用于时间测量
+#include <iostream> // 用于打印输出
+#include <string>   // 用于计时器名称
+#include <iomanip>  // 用于格式化输出 (std::fixed, std::setprecision)
 
 std::string getTimeString();
 
@@ -18,12 +22,6 @@ static std::string str_format(const std::string &format, Args ... args)
 	return std::string(buf.get(), buf.get() + size_buf - 1); 
 }
 
-#pragma once // 或者使用传统的 include guards
-
-#include <chrono>   // 用于时间测量
-#include <iostream> // 用于打印输出
-#include <string>   // 用于计时器名称
-#include <iomanip>  // 用于格式化输出 (std::fixed, std::setprecision)
 
 class Timer {
 public:

+ 5 - 25
src/nodes/analyze/analyzeNode.cpp

@@ -7,32 +7,12 @@ namespace GNode
 {
 
 
-void AnalyzeNode::work()
+void AnalyzeNode::handle_data(std::shared_ptr<meta::MetaData>& meta_data)
 {
-    printf("AnalyzeNode %s\n", name_.c_str());
-    while (running_)
-    {
-        
-        for (auto& input_buffer : input_buffers_)
-        {
-            std::shared_ptr<meta::MetaData> metaData;
-            if (!input_buffer.second->try_pop(metaData))
-            {
-                continue;
-            }
-            // printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
-            int width = metaData->image.cols;
-            int height = metaData->image.rows;
-
-            auto res = person_cross_line(metaData->track_boxes, cv::Point(0, 0), cv::Point(width, height));
-            metaData->result = res;
-            for (auto& output_buffer : output_buffers_)
-            {
-                // printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
-                output_buffer.second->push(metaData);
-            }
-        }
-    }
+    int width = meta_data->image.cols;
+    int height = meta_data->image.rows;
+    auto res = person_cross_line(meta_data->track_boxes, cv::Point(0, 0), cv::Point(width, height));
+    meta_data->result = res;
 }
 
 

+ 1 - 1
src/nodes/analyze/analyzeNode.hpp

@@ -14,7 +14,7 @@ public:
     AnalyzeNode(const std::string& name) : BaseNode(name, NODE_TYPE::MID_NODE) { }
     virtual ~AnalyzeNode() { stop(); };
 
-    void work() override;
+    void handle_data(std::shared_ptr<meta::MetaData>& meta_data) override;
 };
 
 

+ 2 - 0
src/nodes/base/base.cpp

@@ -29,10 +29,12 @@ void BaseNode::stop()
     if (running_.exchange(false))
     {
         // 删除队列中全部元素
+        PLOGI.printf("Node : [%s] delete queue start", name_.c_str());
         std::for_each(input_buffers_.begin(), input_buffers_.end(),
                   [&](const auto &item) { item.second->clear(); });
         std::for_each(output_buffers_.begin(), output_buffers_.end(),
                     [&](const auto &item) { item.second->clear(); });
+        PLOGI.printf("Node : [%s] delete queue stop", name_.c_str());
         cond_var_->notify_all();
         if (worker_thread_.joinable())
         {