diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 03c9b3a..6f9d897 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -82,135 +82,134 @@ CMultiSourceProcess::~CMultiSourceProcess(){ } int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ - if (CheckTime()) { - set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); - LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); + if (!CheckTime()) { + return AUTHOR_ERROR; + } - SourceSingleton::getInstance(); + set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); + LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); - skip_frame_ = 5; - m_batch_size = 20; + SourceSingleton::getInstance(); - m_devId = vptParam.gpuid; + skip_frame_ = 5; + m_batch_size = 20; - string models_dir = vptParam.models_dir; + m_devId = vptParam.gpuid; - VPTProcess_PARAM vparam; - vparam.gpuid = m_devId; - vparam.max_batch = m_batch_size; - vparam.threshold = 0.4; - vparam.model_dir = models_dir; + string models_dir = vptParam.models_dir; - aclrtSetDevice(m_devId); + VPTProcess_PARAM vparam; + vparam.gpuid = m_devId; + vparam.max_batch = m_batch_size; + vparam.threshold = 0.4; + vparam.model_dir = models_dir; - int ret = vpt_process.init(vparam); - if (ret < 0){ - return ret; - } + aclrtSetDevice(m_devId); - //三轮车头肩检测 - if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init tricycle_hs failed"); - return -1; - } + int ret = vpt_process.init(vparam); + if (ret < 0){ + return ret; + } - //货车头肩检测 - if (!truck_manned_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init truck_hs failed"); - return -1; - } + //三轮车头肩检测 + if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init tricycle_hs failed"); + return -1; + } - //二轮车头肩检测 - if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init motor_hs failed"); - return -1; - } + //货车头肩检测 + if (!truck_manned_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init truck_hs failed"); + return -1; + } - #ifdef WITH_FACE_DET_SS - // 人脸检测初始化 - facedet_ai_engine_param fd_param; - char model_path_yolov5s[100]; - strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str()); - fd_param.sdk_param.det_modelNames = model_path_yolov5s; - char model_path_ldmk[100]; - strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str()); - fd_param.sdk_param.ldmk_modelNames = model_path_ldmk; - char model_path_pose[100]; - strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str()); - fd_param.sdk_param.pose_modelNames = model_path_pose; - char model_path_score[100]; - strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str()); - fd_param.sdk_param.score_modelNames = model_path_score; - char model_path_fuzzy[100]; - strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str()); - fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy; - char model_path_occlusion[100]; - strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str()); - fd_param.sdk_param.occlusion_modelNames = model_path_occlusion; - fd_param.sdk_param.thresld = 0.6; - fd_param.sdk_param.devId = m_devId; - fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; - fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 - fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 - fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 - fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE - fd_param.sdk_param.max_result_count = 50; - ret = m_face_det_ai_engine.init_ai_engine(fd_param); - if (ret < 0 ) { - LOG_FATAL("Init face detection failed"); - return ret; - } - #endif + //二轮车头肩检测 + if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init motor_hs failed"); + return -1; + } + + #ifdef WITH_FACE_DET_SS + // 人脸检测初始化 + facedet_ai_engine_param fd_param; + char model_path_yolov5s[100]; + strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str()); + fd_param.sdk_param.det_modelNames = model_path_yolov5s; + char model_path_ldmk[100]; + strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str()); + fd_param.sdk_param.ldmk_modelNames = model_path_ldmk; + char model_path_pose[100]; + strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str()); + fd_param.sdk_param.pose_modelNames = model_path_pose; + char model_path_score[100]; + strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str()); + fd_param.sdk_param.score_modelNames = model_path_score; + char model_path_fuzzy[100]; + strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str()); + fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy; + char model_path_occlusion[100]; + strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str()); + fd_param.sdk_param.occlusion_modelNames = model_path_occlusion; + fd_param.sdk_param.thresld = 0.6; + fd_param.sdk_param.devId = m_devId; + fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; + fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 + fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 + fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 + fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE + fd_param.sdk_param.max_result_count = 50; + ret = m_face_det_ai_engine.init_ai_engine(fd_param); + if (ret < 0 ) { + LOG_FATAL("Init face detection failed"); + return ret; + } +#endif - m_task_param_manager = task_param_manager::getInstance(); - m_snapshot_reprocessing = new snapshot_reprocessing(m_devId); - m_save_snapshot_reprocessing = new save_snapshot_reprocessing(m_devId); + m_task_param_manager = task_param_manager::getInstance(); + m_snapshot_reprocessing = new snapshot_reprocessing(m_devId); + m_save_snapshot_reprocessing = new save_snapshot_reprocessing(m_devId); - #ifdef POST_USE_RABBITMQ - mq_manager_ = new mq::Manager(); - #endif +#ifdef POST_USE_RABBITMQ + mq_manager_ = new mq::Manager(); +#endif - VPCUtil* pVpcUtil = VPCUtil::getInstance(); - pVpcUtil->init(m_devId); + VPCUtil* pVpcUtil = VPCUtil::getInstance(); + pVpcUtil->init(m_devId); - m_pAlgorthimThread = new thread([](void* arg) { - CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; - process->algorthim_process_thread(); - return (void*)0; - } - , this); + m_pAlgorthimThread = new thread([](void* arg) { + CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; + process->algorthim_process_thread(); + return (void*)0; + } + , this); - m_recode_thread = new thread([](void* arg) { - CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; - process->recode_thread(); - return (void*)0; - } - , this); - - - m_timing_snapshot_thread = new std::thread( - [](void* arg) - { - CMultiSourceProcess* _this=(CMultiSourceProcess*)arg; - if(_this != nullptr){ - _this->timing_snapshot_thread(); - }else{ - LOG_ERROR("定时抓拍线程启动失败 !"); - } - return (void*)0; - }, this); - - if(nullptr == m_timing_snapshot_thread){ - LOG_ERROR("定时抓拍线程启动失败 !"); + m_recode_thread = new thread([](void* arg) { + CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; + process->recode_thread(); + return (void*)0; } + , this); - LOG_INFO("InitAlgorthim succeed !"); - return 0; - } - else { - return AUTHOR_ERROR; + m_timing_snapshot_thread = new std::thread( + [](void* arg) + { + CMultiSourceProcess* _this=(CMultiSourceProcess*)arg; + if(_this != nullptr){ + _this->timing_snapshot_thread(); + }else{ + LOG_ERROR("定时抓拍线程启动失败 !"); + } + return (void*)0; + }, this); + + if(nullptr == m_timing_snapshot_thread){ + LOG_ERROR("定时抓拍线程启动失败 !"); } + + LOG_INFO("InitAlgorthim succeed !"); + + return 0; } #ifdef POST_USE_RABBITMQ