#include "../nodes/vp_file_src_node.h" #include "../nodes/vp_rtsp_src_node.h" #include "../nodes/infers/vp_yunet_face_detector_node.h" #include "../nodes/infers/vp_sface_feature_encoder_node.h" #include "../nodes/track/vp_sort_track_node.h" #include "../nodes/osd/vp_face_osd_node.h" #include "../nodes/vp_screen_des_node.h" #include "../utils/analysis_board/vp_analysis_board.h" /* * ## face tracking sample ## * track for multi faces using vp_sort_track_node. */ int main(int argc, char* argv[]) { VP_SET_LOG_INCLUDE_CODE_LOCATION(false); VP_SET_LOG_INCLUDE_THREAD_ID(false); VP_SET_LOG_LEVEL(vp_utils::vp_log_level::INFO); VP_LOGGER_INIT(); std::vector args(argv + 1, argv + argc); // 默认的命令行参数 std::string rtsp_path = "./vp_data/models/trt/vehicle/vehicle_detection.trt"; float resize_ratio = 0.5; // 如果提供了第一个和第二个参数,则覆盖默认的路径 if (args.size() >= 1) { rtsp_path = args[0]; if (args.size() >= 3){ resize_ratio = std::stof(args[1]); } } else { std::cout << "Usage: " << argv[0] << " \n"; std::cout << "Example: " << argv[0] << " rtsp://192.168.1.24:8554/demo 0.5\n"; return -1; } // create nodes //auto file_src_0 = std::make_shared("file_src_0", 0, "./vp_data/test_video/face.mp4"); auto rtsp_src_1 = std::make_shared("rtsp_src_1", 1, rtsp_path, resize_ratio, "avdec_h264"); auto yunet_face_detector_0 = std::make_shared("yunet_face_detector_0", "./vp_data/models/face/face_detection_yunet_2022mar.onnx"); auto sface_face_encoder_0 = std::make_shared("sface_face_encoder_0", "./vp_data/models/face/face_recognition_sface_2021dec.onnx"); auto track_0 = std::make_shared("track_0", vp_nodes::vp_track_for::FACE); // track for face auto osd_0 = std::make_shared("osd_0"); auto screen_des_0 = std::make_shared("screen_des_0", 0); // construct pipeline yunet_face_detector_0->attach_to({rtsp_src_1}); sface_face_encoder_0->attach_to({yunet_face_detector_0}); track_0->attach_to({sface_face_encoder_0}); osd_0->attach_to({track_0}); screen_des_0->attach_to({osd_0}); rtsp_src_1->start(); // for debug purpose vp_utils::vp_analysis_board board({rtsp_src_1}); board.display(); }