#include "../nodes/vp_file_src_node.h" #include "../nodes/vp_rtsp_src_node.h" #include "../nodes/infers/vp_yolo_detector_node.h" #include "../nodes/track/vp_sort_track_node.h" #include "../nodes/ba/vp_ba_jam_node.h" #include "../nodes/osd/vp_ba_jam_osd_node.h" #include "../nodes/vp_screen_des_node.h" #include "../nodes/vp_rtmp_des_node.h" #include "../nodes/broker/vp_json_kafka_broker_node.h" #include "../nodes/vp_file_des_node.h" #include "../nodes/record/vp_record_node.h" #include "../nodes/vp_fake_des_node.h" #include "../utils/analysis_board/vp_analysis_board.h" /* * ## ba crossline sample ## * behaviour analysis for crossline. */ int main(int argc, char* argv[]) { VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO); VP_LOGGER_INIT(); std::vector args(argv + 1, argv + argc); // 默认的命令行参数 std::string rtsp_path_1 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_2 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_3 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_4 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_5 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_6 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_7 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_8 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_9 = "rtsp://192.168.1.24:8554/demo"; std::string rtsp_path_10 = "rtsp://192.168.1.24:8554/demo"; std::string kafka_server_point = "192.168.0.85:9092"; float resize_ratio = 0.4; // 如果提供了第一个和第二个参数,则覆盖默认的路径 if (args.size() >= 3) { rtsp_path_1 = args[0]; rtsp_path_2 = args[1]; rtsp_path_3 = args[2]; rtsp_path_4 = args[3]; rtsp_path_5 = args[4]; rtsp_path_6 = args[5]; rtsp_path_7 = args[6]; rtsp_path_8 = args[7]; rtsp_path_9 = args[8]; rtsp_path_10 = args[9]; resize_ratio = std::stof(args[10]); kafka_server_point = args[11]; } else { std::cout << "Usage: " << argv[0] << " \n"; std::cout << "Example: " << argv[0] << " rtsp://192.168.1.24:8554/demo 0.4 192.168.0.85:9092\n"; return -1; } // create nodes //auto rtsp_src_1 = std::make_shared("file_src_0", 0, rtsp_path, resize_ratio); auto rtsp_src_1 = std::make_shared("rtsp_src_1", 1, rtsp_path_1, resize_ratio, "avdec_h264"); auto rtsp_src_2 = std::make_shared("rtsp_src_2", 2, rtsp_path_2, resize_ratio, "avdec_h264"); auto rtsp_src_3 = std::make_shared("rtsp_src_3", 3, rtsp_path_3, resize_ratio, "avdec_h264"); auto rtsp_src_4 = std::make_shared("rtsp_src_4", 4, rtsp_path_4, resize_ratio, "avdec_h264"); auto rtsp_src_5 = std::make_shared("rtsp_src_5", 5, rtsp_path_5, resize_ratio, "avdec_h264"); auto rtsp_src_6 = std::make_shared("rtsp_src_6", 6, rtsp_path_6, resize_ratio, "avdec_h264"); auto rtsp_src_7 = std::make_shared("rtsp_src_7", 7, rtsp_path_7, resize_ratio, "avdec_h264"); auto rtsp_src_8 = std::make_shared("rtsp_src_8", 8, rtsp_path_8, resize_ratio, "avdec_h264"); auto rtsp_src_9 = std::make_shared("rtsp_src_9", 9, rtsp_path_9, resize_ratio, "avdec_h264"); auto rtsp_src_10 = std::make_shared("rtsp_src_10", 10, rtsp_path_10, resize_ratio, "avdec_h264"); auto yolo_detector = std::make_shared("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("sort_tracker"); // define a region in frame for every channel (value MUST in the scope of frame'size) std::map> regions = { //{0, std::vector{vp_objects::vp_point(641, 58), vp_objects::vp_point(747, 51), vp_objects::vp_point(1132, 267), vp_objects::vp_point(366, 678)}} {1, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {2, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {3, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {4, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {5, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {6, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {7, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {8, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {9, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}}, {10, std::vector{vp_objects::vp_point(0, 520), vp_objects::vp_point(450, 50), vp_objects::vp_point(650, 50), vp_objects::vp_point(1000, 520)}} }; auto ba_jam = std::make_shared("ba_jam", regions); auto json_kafka_broker_0 = std::make_shared("json_kafka_broker_0", kafka_server_point, "vp_ba_jam", vp_nodes::vp_broke_for::BARESULT); auto osd = std::make_shared("osd"); auto recorder = std::make_shared("recorder", "./record", "./record"); auto fake_des_0 = std::make_shared("fake_des_0", 2); // construct pipeline yolo_detector->attach_to({rtsp_src_1,rtsp_src_2,rtsp_src_3,rtsp_src_4,rtsp_src_5,rtsp_src_6,rtsp_src_7,rtsp_src_8,rtsp_src_9,rtsp_src_10}); tracker->attach_to({yolo_detector}); ba_jam->attach_to({tracker}); json_kafka_broker_0->attach_to({ba_jam}); osd->attach_to({json_kafka_broker_0}); recorder->attach_to({osd}); fake_des_0->attach_to({recorder}); rtsp_src_1->start(); rtsp_src_2->start(); rtsp_src_3->start(); rtsp_src_4->start(); rtsp_src_5->start(); rtsp_src_6->start(); rtsp_src_7->start(); rtsp_src_8->start(); rtsp_src_9->start(); rtsp_src_10->start(); std::string wait; std::getline(std::cin, wait); rtsp_src_1->detach_recursively(); }