-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathba_crossline_sample.cpp
51 lines (42 loc) · 2.19 KB
/
ba_crossline_sample.cpp
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
50
51
#include "../nodes/vp_file_src_node.h"
#include "../nodes/infers/vp_yolo_detector_node.h"
#include "../nodes/track/vp_sort_track_node.h"
#include "../nodes/ba/vp_ba_crossline_node.h"
#include "../nodes/osd/vp_ba_crossline_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"
/*
* ## ba crossline sample ##
* behaviour analysis for crossline.
*/
int main() {
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, "./vp_data/test_video/vehicle_count.mp4", 0.4);
auto yolo_detector = std::make_shared<vp_nodes::vp_yolo_detector_node>("yolo_detector", "./vp_data/models/det_cls/yolov3-tiny-2022-0721_best.weights", "./vp_data/models/det_cls/yolov3-tiny-2022-0721.cfg", "./vp_data/models/det_cls/yolov3_tiny_5classes.txt");
auto tracker = std::make_shared<vp_nodes::vp_sort_track_node>("sort_tracker");
// define a line in frame for every channel (value MUST in the scope of frame'size)
vp_objects::vp_point start(0, 250); // change to proper value
vp_objects::vp_point end(700, 220); // change to proper value
std::map<int, vp_objects::vp_line> lines = {{0, vp_objects::vp_line(start, end)}}; // channel0 -> line
auto ba_crossline = std::make_shared<vp_nodes::vp_ba_crossline_node>("ba_crossline", lines);
auto osd = std::make_shared<vp_nodes::vp_ba_crossline_osd_node>("osd");
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/9000");
// construct pipeline
yolo_detector->attach_to({file_src_0});
tracker->attach_to({yolo_detector});
ba_crossline->attach_to({tracker});
osd->attach_to({ba_crossline});
screen_des_0->attach_to({osd});
rtmp_des_0->attach_to({osd});
file_src_0->start();
// for debug purpose
vp_utils::vp_analysis_board board({file_src_0});
board.display(1, false);
std::string wait;
std::getline(std::cin, wait);
file_src_0->detach_recursively();
}