#include "nodes/base/base.hpp" #include "nodes/stream/streamNode.hpp" #include "nodes/infer/inferNode.hpp" #include "nodes/draw/drawNode.hpp" #include "nodes/track/trackNode.hpp" #include "nodes/analyze/analyzeNode.hpp" #include "nodes/httpPush/httpPush.hpp" #include "nodes/record/recordNode.hpp" void run_from_json() { } void test_depth() { std::shared_ptr src_node0 = std::make_shared("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, GNode::DecodeType::GPU); src_node0->set_skip_frame(1); std::shared_ptr depth_model = load("model/depth.engine", ModelType::DEPTH_ANYTHING, {}, 0, 0.25, 0.45); std::shared_ptr infer_node = std::make_shared("depth"); infer_node->set_model_instance(depth_model, ModelType::DEPTH_ANYTHING); std::shared_ptr draw_node = std::make_shared("draw"); std::shared_ptr push_node = std::make_shared("push", "172.16.20.168", 8080, "/push"); GNode::LinkNode(src_node0, infer_node); GNode::LinkNode(infer_node, draw_node); GNode::LinkNode(draw_node, push_node); push_node->start(); draw_node->start(); infer_node->start(); src_node0->start(); std::this_thread::sleep_for(std::chrono::seconds(10)); } void test_yolo() { OverflowStrategy stage = OverflowStrategy::Block; int max_size = 100; // std::vector names = { "person", "clothes", "vest" }; std::vector names = { "person", "car", "close", "open" }; // std::shared_ptr src_node0 = std::make_shared("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, GNode::DecodeType::GPU); std::shared_ptr src_node0 = std::make_shared("src0", "carperson.mp4", 0, GNode::DecodeType::GPU); src_node0->set_skip_frame(1); std::shared_ptr yolo_model = load("model/carperson.engine", ModelType::YOLOV5, names, 0, 0.25, 0.45); std::shared_ptr infer_node = std::make_shared("yolov5"); infer_node->set_model_instance(yolo_model, ModelType::YOLO11); std::shared_ptr track_node = std::make_shared("tracker", "person", 30, 30); std::shared_ptr analyze_node = std::make_shared("analyze"); std::shared_ptr draw_node = std::make_shared("draw_track"); std::shared_ptr record_node = std::make_shared("record"); record_node->set_record_path("result/result.mp4"); record_node->set_fps(25); record_node->set_fourcc(cv::VideoWriter::fourcc('X', '2', '6', '4')); GNode::LinkNode(src_node0, infer_node, max_size, stage); GNode::LinkNode(infer_node, track_node, max_size, stage); GNode::LinkNode(track_node, analyze_node, max_size, stage); GNode::LinkNode(analyze_node, draw_node, max_size, stage); GNode::LinkNode(draw_node, record_node, max_size, stage); record_node->start(); draw_node->start(); analyze_node->start(); track_node->start(); infer_node->start(); src_node0->start(); getchar(); } void test_multi() { std::vector names = { "person", "clothes", "vest" }; std::shared_ptr src_node0 = std::make_shared("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/101", 0, GNode::DecodeType::GPU); src_node0->set_skip_frame(10); std::shared_ptr src_node1 = std::make_shared("src1", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, GNode::DecodeType::GPU); src_node1->set_skip_frame(10); std::shared_ptr src_node2 = std::make_shared("src2", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/301", 0, GNode::DecodeType::GPU); src_node2->set_skip_frame(10); std::shared_ptr yolo_model = load("model/yolo11s.engine", ModelType::YOLO11, names, 0, 0.25, 0.45); std::shared_ptr infer_node1 = std::make_shared("yolo11"); infer_node1->set_model_instance(yolo_model, ModelType::YOLO11); std::shared_ptr depth_model = load("model/depth.engine", ModelType::DEPTH_ANYTHING, {}, 0, 0.25, 0.45); std::shared_ptr infer_node2 = std::make_shared("depth"); infer_node2->set_model_instance(depth_model, ModelType::DEPTH_ANYTHING); std::shared_ptr draw_node = std::make_shared("draw"); std::shared_ptr push_node = std::make_shared("push", "172.16.20.168", 8080, "/push"); GNode::LinkNode(src_node0, infer_node1); GNode::LinkNode(src_node1, infer_node1); GNode::LinkNode(src_node2, infer_node1); GNode::LinkNode(infer_node1, infer_node2); GNode::LinkNode(infer_node2, draw_node); GNode::LinkNode(draw_node, push_node); push_node->start(); draw_node->start(); infer_node1->start(); infer_node2->start(); src_node0->start(); src_node1->start(); src_node2->start(); getchar(); } int main() { test_yolo(); return 0; } // TODO // 硬解码、软解码 完成 软解使用opencv + ffmpeg,硬解使用nvcodec + ffmpeg // 模型复用 完成,基类加锁保证一致性 // 画图节点 完成 // 推送节点 基本完成 // 分析节点 // YOLO11 seg // 通过配置文件创建 pipeline // 日志 // 设置电子围栏