#include "../nodes/vp_file_src_node.h" #include "../nodes/infers/vp_trt_vehicle_detector.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/record/vp_record_node.h" #include "../nodes/vp_split_node.h" #include "../nodes/vp_screen_des_node.h" #include "../nodes/broker/vp_json_kafka_broker_node.h" #include "../utils/analysis_board/vp_analysis_board.h" /* * ## ba jam sample ## * behaviour analysis for jam, single instance of ba node work on 2 channels. */ 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 model_path = "./vp_data/models/trt/vehicle/vehicle_detection.trt"; std::string video_path = "./vp_data/test_video/jam.mp4"; float resize_ratio = 0.5; // 如果提供了第一个和第二个参数,则覆盖默认的路径 if (args.size() >= 2) { model_path = args[0]; video_path = args[1]; if (args.size() >= 3){ resize_ratio = std::stof(args[2]); } } else { std::cout << "Usage: " << argv[0] << " [resize_ratio]\n"; std::cout << "Example: " << argv[0] << " ./vp_data/models/trt/vehicle/vehicle_detection.trt ./vp_data/test_video/jam2.mp4 1\n"; return -1; } // create nodes auto file_src_0 = std::make_shared("file_src_0", 0, video_path, resize_ratio); auto trt_vehicle_detector = std::make_shared("vehicle_detector", model_path); 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(20, 360), vp_objects::vp_point(400, 250), vp_objects::vp_point(535, 250), vp_objects::vp_point(555, 560), vp_objects::vp_point(30, 550)}} // channel0 -> region }; auto ba_jam = std::make_shared("ba_jam", regions); auto json_kafka_broker_0 = std::make_shared("json_kafka_broker_0", "192.168.130.228:9092", "vp_ba_jam", vp_nodes::vp_broke_for::BARESULT); auto osd = std::make_shared("jam_osd"); auto recorder = std::make_shared("recorder", "./record", "./record"); auto split = std::make_shared("split", true); auto screen_des_0 = std::make_shared("screen_des_0", 0); // construct pipeline trt_vehicle_detector->attach_to({file_src_0}); tracker->attach_to({trt_vehicle_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}); split->attach_to({recorder}); screen_des_0->attach_to({split}); 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(); }