wangrong
2025-03-19 291afb9c81aae1d15d9e3edcea618d0a2e1fc5a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "../nodes/vp_file_src_node.h"
#include "../nodes/infers/vp_trt_vehicle_detector.h"
#include "../nodes/osd/vp_osd_node.h"
#include "../nodes/vp_screen_des_node.h"
#include "../nodes/track/vp_sort_track_node.h"
 
#include "../utils/analysis_board/vp_analysis_board.h"
 
int main(int argc, char* argv[]) {
    std::vector<std::string> args(argv + 1, argv + argc);
 
    float resize_ratio  = 1.0;
 
 
    if (args.size() < 2) {
        std::cout << "Usage: " << argv[0] << " <detector_path> <video_path> \n";
        std::cout << "Example: " << argv[0] << " ./vp_data/models/trt/vehicle/vehicle_v8.5.trt ./vp_data/test_video/vehicle_stop.mp4\n";
        return -1;
    }else if (args.size() >=3 ){
        resize_ratio = std::stof(args[2]);
    }
 
    // 默认的命令行参数
    std::string model_path = args[0];
    std::string video_path = args[1];
 
    VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO);
    VP_LOGGER_INIT();
 
    // create nodes
    auto file_src_0 = std::make_shared<vp_nodes::vp_file_src_node>("file_src_0", 0, video_path, resize_ratio);
    auto trt_vehicle_detector = std::make_shared<vp_nodes::vp_trt_vehicle_detector>("vehicle_detector", model_path);
    auto track_0 = std::make_shared<vp_nodes::vp_sort_track_node>("track_0");
    auto osd_0 = std::make_shared<vp_nodes::vp_osd_node>("osd_0", "./vp_data/font/NotoSansCJKsc-Medium.otf");
    auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
 
    // construct pipeline
    trt_vehicle_detector->attach_to({file_src_0});
    track_0->attach_to({trt_vehicle_detector});
    osd_0->attach_to({track_0});
    screen_des_0->attach_to({osd_0});
 
    // start pipeline
    file_src_0->start();
 
    // visualize pipeline for debug
    vp_utils::vp_analysis_board board({file_src_0});
    board.display();
}