wangrong
2025-01-03 2c4b8838f89bebca97615c5f0bac2c58e0349771
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_plate_detector_v2.h"
#include "../../nodes/track/vp_sort_track_node.h"
#include "../../nodes/broker/vp_plate_socket_broker_node.h"
#include "../../nodes/osd/vp_plate_osd_node.h"
#include "../../nodes/vp_screen_des_node.h"
#include "../../nodes/vp_rtmp_des_node.h"
#include "../../utils/analysis_board/vp_analysis_board.h"
 
/*
* ## license plate recognize(lpr) pipeline ##
* detect and recognize license plate in the whole frame, and send results via socket.
*/
 
int main(int argc, char* argv[]) {
    // get directory for test video and models
    assert(argc == 2);
    std::string data_dir(argv[1]);
    if (!vp_utils::ends_with(data_dir, "/")) {
        data_dir += "/";
    }
 
    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, data_dir + "vp_data/test_video/plate2.mp4");
    auto plate_detector = std::make_shared<vp_nodes::vp_trt_vehicle_plate_detector_v2>("plate_detector", data_dir + "vp_data/models/trt/plate/det_v8.5.trt", data_dir + "vp_data/models/trt/plate/rec_v8.5.trt");
    auto track =  std::make_shared<vp_nodes::vp_sort_track_node>("tracker");
    auto plate_broker = std::make_shared<vp_nodes::vp_plate_socket_broker_node>("plate_broker", "192.168.77.68", 9999, "static/plate_images");
    auto osd_0 = std::make_shared<vp_nodes::vp_plate_osd_node>("osd_0", data_dir + "vp_data/font/NotoSansCJKsc-Medium.otf", false);
    auto screen_des_0 = std::make_shared<vp_nodes::vp_screen_des_node>("screen_des_0", 0);
    auto rtmp_des_0 = std::make_shared<vp_nodes::vp_rtmp_des_node>("rtmp_des_0", 0, "rtmp://192.168.77.60/live/lpr");
    
    // construct pipeline 
    plate_detector->attach_to({file_src_0});
    track->attach_to({plate_detector});
    plate_broker->attach_to({track});
    osd_0->attach_to({plate_broker});
    screen_des_0->attach_to({osd_0});
    rtmp_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();
}