leon 1 月之前
父節點
當前提交
3d4780fda0
共有 7 個文件被更改,包括 39 次插入20 次删除
  1. 2 1
      .vscode/settings.json
  2. 15 0
      src/common/utils.cpp
  3. 9 0
      src/common/utils.hpp
  4. 4 0
      src/main.cpp
  5. 1 12
      src/nodes/draw/drawNode.cpp
  6. 2 1
      src/nodes/httpPush/httpPush.cpp
  7. 6 6
      src/nodes/httpPush/httpPush.hpp

+ 2 - 1
.vscode/settings.json

@@ -54,6 +54,7 @@
         "vector": "cpp",
         "algorithm": "cpp",
         "tuple": "cpp",
-        "future": "cpp"
+        "future": "cpp",
+        "iomanip": "cpp"
     }
 }

+ 15 - 0
src/common/utils.cpp

@@ -0,0 +1,15 @@
+#include "common/utils.hpp"
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+
+std::string getTimeString()
+{
+    auto now = std::chrono::system_clock::now();
+    auto t = std::chrono::system_clock::to_time_t(now);
+    std::tm tm = *std::localtime(&t);
+
+    std::ostringstream oss;
+    oss << std::put_time(&tm, "%Y_%m_%d_%H_%M_%S");
+    return oss.str();
+}

+ 9 - 0
src/common/utils.hpp

@@ -0,0 +1,9 @@
+#ifndef UTILS_HPP
+#define UTILS_HPP
+
+#include <string>
+
+std::string getTimeString();
+
+
+#endif

+ 4 - 0
src/main.cpp

@@ -2,6 +2,7 @@
 #include "nodes/stream/streamNode.hpp"
 #include "nodes/infer/inferNode.hpp"
 #include "nodes/draw/drawNode.hpp"
+#include "nodes/httpPush/httpPush.hpp"
 
 
 int main()
@@ -12,8 +13,11 @@ int main()
 
     std::shared_ptr<Node::InferNode> infer_node = std::make_shared<Node::InferNode>("infer");
     std::shared_ptr<Node::DrawNode> draw_node = std::make_shared<Node::DrawNode>("draw");
+    std::shared_ptr<Node::DrawNode> push_node = std::make_shared<Node::HttpPushNode>("push", "172.16.20.168", 8080, "/push");
     Node::LinkNode(src_node, infer_node);
     Node::LinkNode(infer_node, draw_node);
+    Node::LinkNode(draw_node, push_node);
+    push_node->start();
     draw_node->start();
     infer_node->start();
     src_node->start();

+ 1 - 12
src/nodes/draw/drawNode.cpp

@@ -1,3 +1,4 @@
+#include "common/utils.hpp"
 #include "nodes/base/base.hpp"
 #include "nodes/draw/drawNode.hpp"
 #include "nodes/draw/position.hpp"
@@ -8,16 +9,6 @@
 namespace Node
 {
 
-static std::string getTimeString() {
-    auto now = std::chrono::system_clock::now();
-    auto t = std::chrono::system_clock::to_time_t(now);
-    std::tm tm = *std::localtime(&t);
-
-    std::ostringstream oss;
-    oss << std::put_time(&tm, "%Y_%m_%d_%H_%M_%S");
-    return oss.str();
-}
-
 static std::tuple<int, int, int> getFontSize(const std::string& text)
 {
     int baseline = 0;
@@ -54,8 +45,6 @@ void DrawNode::work()
                 cv::putText(image, box.label, cv::Point(x, y), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0), 2);
             }
             metaData->draw_image = image;
-            std::string image_name = getTimeString() + ".jpg";
-            cv::imwrite(image_name, image);
             for (auto& output_buffer : output_buffers_)
             {
                 printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());

+ 2 - 1
src/nodes/httpPush/httpPush.cpp

@@ -1,10 +1,11 @@
+#include "common/utils.hpp"
 #include "nodes/base/base.hpp"
 #include "nodes/httpPush/httpPush.hpp"
 
 namespace Node
 {
 
-void HttpPush::work()
+void HttpPushNode::work()
 {
     printf("HttpPush %s\n", name_.c_str());
     while (running_)

+ 6 - 6
src/nodes/httpPush/httpPush.hpp

@@ -6,15 +6,15 @@
 namespace Node
 {
 
-class HttpPush : public BaseNode
+class HttpPushNode : public BaseNode
 {
 public:
-    HttpPush() = delete;
-    HttpPush(const std::string& name) : BaseNode(name, NODE_TYPE::DES_NODE) {}
-    HttpPush(const std::string& name, const std::string& ip, int port, const std::string& address)
-        : BaseNode(name, NODE_TYPE::DES_NODE), ip_(ip), port_(port), address_(address) {}
+    HttpPushNode() = delete;
+    HttpPushNode(const std::string& name) : BaseNode(name, NODE_TYPE::DES_NODE) {}
+    HttpPushNode(const std::string& name, const std::string& ip, int port, const std::string& address)
+            : BaseNode(name, NODE_TYPE::DES_NODE), ip_(ip), port_(port), address_(address) {}
 
-    virtual ~HttpPush() { };
+    virtual ~HttpPushNode() { };
 
     inline void set_ip(const std::string& ip) { ip_ = ip; }
     inline void set_port(int port) { port_ = port; }