|
@@ -12,148 +12,8 @@
|
|
|
#include "graph/graph.hpp"
|
|
|
|
|
|
|
|
|
-void run_from_json()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-void test_depth()
|
|
|
-{
|
|
|
- std::shared_ptr<GNode::StreamNode> src_node0 = std::make_shared<GNode::StreamNode>("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<Infer> depth_model = load("model/depth.engine", ModelType::DEPTH_ANYTHING, {}, 0, 0.25, 0.45);
|
|
|
- std::shared_ptr<GNode::InferNode> infer_node = std::make_shared<GNode::InferNode>("depth");
|
|
|
- infer_node->set_model_instance(depth_model, depth_model->get_gpu_id());
|
|
|
-
|
|
|
- std::shared_ptr<GNode::DrawNode> draw_node = std::make_shared<GNode::DrawNode>("draw");
|
|
|
- std::shared_ptr<GNode::HttpPushNode> push_node = std::make_shared<GNode::HttpPushNode>("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::BlockTimeout;
|
|
|
- int max_size = 100;
|
|
|
-
|
|
|
- std::vector<std::string> names = {
|
|
|
- "person", "bicycle", "car",
|
|
|
- "motorcycle", "airplane", "bus",
|
|
|
- "train", "truck", "boat",
|
|
|
- "traffic light", "fire hydrant", "stop sign",
|
|
|
- "parking meter", "bench", "bird",
|
|
|
- "cat", "dog", "horse",
|
|
|
- "sheep", "cow", "elephant",
|
|
|
- "bear", "zebra", "giraffe",
|
|
|
- "backpack", "umbrella", "handbag",
|
|
|
- "tie", "suitcase", "frisbee",
|
|
|
- "skis", "snowboard", "sports ball",
|
|
|
- "kite", "baseball bat", "baseball glove",
|
|
|
- "skateboard", "surfboard", "tennis racket",
|
|
|
- "bottle", "wine glass", "cup",
|
|
|
- "fork", "knife", "spoon",
|
|
|
- "bowl", "banana", "apple",
|
|
|
- "sandwich", "orange", "broccoli",
|
|
|
- "carrot", "hot dog", "pizza",
|
|
|
- "donut", "cake", "chair",
|
|
|
- "couch", "potted plant", "bed",
|
|
|
- "dining table", "toilet", "tv",
|
|
|
- "laptop", "mouse", "remote",
|
|
|
- "keyboard", "cell phone", "microwave",
|
|
|
- "oven", "toaster", "sink",
|
|
|
- "refrigerator", "book", "clock",
|
|
|
- "vase", "scissors", "teddy bear",
|
|
|
- "hair drier", "toothbrush"};
|
|
|
-
|
|
|
- // std::vector<std::string> names = { "person", "clothes", "vest" };
|
|
|
- // std::vector<std::string> names = { "person", "car", "close", "open" };
|
|
|
- // std::shared_ptr<GNode::StreamNode> src_node0 = std::make_shared<GNode::StreamNode>("src0", "rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/201", 0, GNode::DecodeType::GPU);
|
|
|
- std::shared_ptr<GNode::StreamNode> src_node0 = std::make_shared<GNode::StreamNode>("src0", "carperson.mp4", 1, GNode::DecodeType::GPU);
|
|
|
- src_node0->set_skip_frame(1);
|
|
|
-
|
|
|
- std::shared_ptr<Infer> yolo_model = load("model/model1.engine", ModelType::YOLO11SEG, names, 1, 0.25, 0.45);
|
|
|
- std::shared_ptr<GNode::InferNode> infer_node = std::make_shared<GNode::InferNode>("seg");
|
|
|
- infer_node->set_model_instance(yolo_model, yolo_model->get_gpu_id());
|
|
|
-
|
|
|
- std::shared_ptr<GNode::TrackNode> track_node = std::make_shared<GNode::TrackNode>("tracker", "person", 30, 30);
|
|
|
-
|
|
|
- std::shared_ptr<GNode::AnalyzeNode> analyze_node = std::make_shared<GNode::AnalyzeNode>("analyze");
|
|
|
-
|
|
|
- std::shared_ptr<GNode::DrawNode> draw_node = std::make_shared<GNode::DrawNode>("draw");
|
|
|
- std::shared_ptr<GNode::RecordNode> record_node = std::make_shared<GNode::RecordNode>("record");
|
|
|
- record_node->set_record_path("result/result.mp4");
|
|
|
- record_node->set_fps(25);
|
|
|
- record_node->set_fourcc(cv::VideoWriter::fourcc('m', 'p', '4', 'v'));
|
|
|
-
|
|
|
- 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<std::string> names = { "person", "clothes", "vest" };
|
|
|
-
|
|
|
- std::shared_ptr<GNode::StreamNode> src_node0 = std::make_shared<GNode::StreamNode>("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<GNode::StreamNode> src_node1 = std::make_shared<GNode::StreamNode>("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<GNode::StreamNode> src_node2 = std::make_shared<GNode::StreamNode>("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<Infer> yolo_model = load("model/yolo11s.engine", ModelType::YOLO11, names, 1, 0.25, 0.45);
|
|
|
- std::shared_ptr<GNode::InferNode> infer_node1 = std::make_shared<GNode::InferNode>("yolo11");
|
|
|
- infer_node1->set_model_instance(yolo_model, yolo_model->get_gpu_id());
|
|
|
-
|
|
|
- std::shared_ptr<Infer> depth_model = load("model/depth.engine", ModelType::DEPTH_ANYTHING, {}, 1, 0.25, 0.45);
|
|
|
- std::shared_ptr<GNode::InferNode> infer_node2 = std::make_shared<GNode::InferNode>("depth");
|
|
|
- infer_node2->set_model_instance(depth_model, depth_model->get_gpu_id());
|
|
|
-
|
|
|
- std::shared_ptr<GNode::DrawNode> draw_node = std::make_shared<GNode::DrawNode>("draw");
|
|
|
- std::shared_ptr<GNode::HttpPushNode> push_node = std::make_shared<GNode::HttpPushNode>("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();
|
|
|
-}
|
|
|
-
|
|
|
-void test_from_json(const std::string& json_path)
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
int main(int argc , char* argv[])
|
|
|
-
|
|
|
{
|
|
|
plog::init(plog::info, "log/vsp.log", 1000000, 5);
|
|
|
if (argc < 2) {
|