diff --git a/.gitignore b/.gitignore index fbdffea..6a0040d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,11 +4,4 @@ bin/logs/* bin/res/* bin/vpt_proj bin/libvpt_ascend.so -<<<<<<< HEAD -<<<<<<< HEAD data/* -======= ->>>>>>> c4e50858604d927a3467ae4d0c3b3c63b4a35afb -======= -data/* ->>>>>>> 9b8c645d9558a9e4f16f1a218ebdaf7a29d04864 diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 1e079b1..a3d0b10 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -82,131 +82,135 @@ 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__); - set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); - LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); + SourceSingleton::getInstance(); - SourceSingleton::getInstance(); + skip_frame_ = 5; + m_batch_size = 20; - skip_frame_ = 5; - m_batch_size = 20; + m_devId = vptParam.gpuid; - m_devId = vptParam.gpuid; + string models_dir = vptParam.models_dir; - string models_dir = vptParam.models_dir; + VPTProcess_PARAM vparam; + vparam.gpuid = m_devId; + vparam.max_batch = m_batch_size; + vparam.threshold = 0.4; + vparam.model_dir = models_dir; - VPTProcess_PARAM vparam; - vparam.gpuid = m_devId; - vparam.max_batch = m_batch_size; - vparam.threshold = 0.4; - vparam.model_dir = models_dir; + aclrtSetDevice(m_devId); - aclrtSetDevice(m_devId); - - int ret = vpt_process.init(vparam); - if (ret < 0){ - return ret; - } + int ret = vpt_process.init(vparam); + if (ret < 0){ + return ret; + } - //三轮车头肩检测 - if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init tricycle_hs failed"); - return -1; - } + //三轮车头肩检测 + if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init tricycle_hs failed"); + return -1; + } - //货车头肩检测 - if (!truck_manned_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init truck_hs failed"); - return -1; - } + //货车头肩检测 + if (!truck_manned_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init truck_hs failed"); + return -1; + } - //二轮车头肩检测 - if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) { - LOG_FATAL("Init motor_hs failed"); - return -1; - } + //二轮车头肩检测 + 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 + #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; + 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("定时抓拍线程启动失败 !"); } - , this); + LOG_INFO("InitAlgorthim succeed !"); - 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("定时抓拍线程启动失败 !"); + return 0; + } + else { + return AUTHOR_ERROR; } - - LOG_INFO("InitAlgorthim succeed !"); - - return 0; } #ifdef POST_USE_RABBITMQ @@ -632,6 +636,11 @@ int CMultiSourceProcess::algorthim_process_thread(){ ACL_CALL(aclrtCreateContext(&ctx, m_devId), ACL_ERROR_NONE, 1); while (true){ + if (!CheckTime()) { + LOG_FATAL("authority failed!"); + break; + } + if(m_bfinish){ break; } @@ -1356,13 +1365,13 @@ void CMultiSourceProcess::manned_snapshot(vector& vpt_interest_task_id, map _total_snapshot_info = m_snapshot_reprocessing->get_total_village_snapshot_info(); if(_total_snapshot_info.size() <= 0){ - return; + continue; } LOG_DEBUG("_total_snapshot_info size: {}", _total_snapshot_info.size()); auto it = _total_snapshot_info.find(obj_key); if (it == _total_snapshot_info.end()) { - return; + continue; } @@ -1433,12 +1442,11 @@ void CMultiSourceProcess::manned_snapshot(vector& vpt_interest_task_id, else { // 删除记录,同时释放显存 m_snapshot_reprocessing->release_village_finished_locus_snapshot(obj_key.video_id, obj_key.obj_id, true); - return; } - } } + } @@ -1706,4 +1714,23 @@ int CMultiSourceProcess::recode_thread() { } LOG_INFO("recode_thread end."); +} + +bool CMultiSourceProcess::CheckTime() { + struct tm* info; + int nYear, nMonth, nDay; + time_t raw; + time(&raw); + info = localtime(&raw); + nYear = info->tm_year + 1900; + nMonth = info->tm_mon + 1; + nDay = info->tm_mday; + if ((nYear == 2023 && nMonth <= 9) || (nYear == 2023 && nMonth <= 10 && nDay <= 8)) + { + return true; + } + else + { + return false; + } } \ No newline at end of file diff --git a/src/ai_platform/MultiSourceProcess.h b/src/ai_platform/MultiSourceProcess.h index 1c193fb..b41e4e5 100755 --- a/src/ai_platform/MultiSourceProcess.h +++ b/src/ai_platform/MultiSourceProcess.h @@ -56,6 +56,7 @@ public: void timing_snapshot_thread(); // 发送录制消息给任务 int recode_thread(); + bool CheckTime(); private: // 算法相关