main.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "nodes/base/base.hpp"
  2. #include "nodes/stream/streamNode.hpp"
  3. #include "nodes/infer/inferNode.hpp"
  4. #include "nodes/draw/drawNode.hpp"
  5. #include "nodes/httpPush/httpPush.hpp"
  6. int main()
  7. {
  8. // create trt model
  9. std::vector<std::string> names = {
  10. "person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck",
  11. "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench",
  12. "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra",
  13. "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
  14. "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove",
  15. "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup",
  16. "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
  17. "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa",
  18. "pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse",
  19. "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink",
  20. "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier",
  21. "toothbrush"
  22. };
  23. std::shared_ptr<Infer> model = load("model/yolov8.engine", ModelType::YOLO11, names, 0, 0.5, 0.45);
  24. std::shared_ptr<Node::StreamNode> src_node0 = std::make_shared<Node::StreamNode>("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/101", 0, DecodeType::GPU);
  25. src_node0->set_skip_frame(10);
  26. std::shared_ptr<Node::StreamNode> src_node1 = std::make_shared<Node::StreamNode>("src1", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, DecodeType::GPU);
  27. src_node1->set_skip_frame(10);
  28. std::shared_ptr<Node::StreamNode> src_node2 = std::make_shared<Node::StreamNode>("src2", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/301", 0, DecodeType::GPU);
  29. src_node2->set_skip_frame(10);
  30. std::shared_ptr<Node::InferNode> infer_node = std::make_shared<Node::InferNode>("infer");
  31. infer_node->set_model_instance(model);
  32. std::shared_ptr<Node::DrawNode> draw_node = std::make_shared<Node::DrawNode>("draw");
  33. std::shared_ptr<Node::HttpPushNode> push_node = std::make_shared<Node::HttpPushNode>("push", "172.16.20.168", 8080, "/push");
  34. Node::LinkNode(src_node0, infer_node);
  35. Node::LinkNode(src_node1, infer_node);
  36. Node::LinkNode(src_node2, infer_node);
  37. Node::LinkNode(infer_node, draw_node);
  38. Node::LinkNode(draw_node, push_node);
  39. push_node->start();
  40. draw_node->start();
  41. infer_node->start();
  42. src_node0->start();
  43. src_node1->start();
  44. src_node2->start();
  45. getchar();
  46. return 0;
  47. }
  48. // TODO:创建pipeline类,能够打印pipeline的结构、状态、启动、停止、重启、添加节点、删除节点、连接节点、断开节点
  49. // TODO: 硬解码
  50. // TODO: 模型多路复用
  51. // TODO: 通过配置文件创建 pipeline
  52. // TODO: 多种推理框架支持 opencv tensorrt onnxruntime ...
  53. // TODO:日志系统
  54. // TODO: 结果推送接口 http mqtt ...
  55. // TODO: 电子围栏