Commit e0e42d5c703ca14d83b1fe108dc14c57546a5677

Authored by Zhao Shuaihua
1 parent 9d9fd3be

添加时间限制:用于农村违法分析;修复一处显存泄露bug

.gitignore
... ... @@ -4,11 +4,4 @@ bin/logs/*
4 4 bin/res/*
5 5 bin/vpt_proj
6 6 bin/libvpt_ascend.so
7   -<<<<<<< HEAD
8   -<<<<<<< HEAD
9 7 data/*
10   -=======
11   ->>>>>>> c4e50858604d927a3467ae4d0c3b3c63b4a35afb
12   -=======
13   -data/*
14   ->>>>>>> 9b8c645d9558a9e4f16f1a218ebdaf7a29d04864
... ...
src/ai_platform/MultiSourceProcess.cpp
... ... @@ -82,131 +82,135 @@ CMultiSourceProcess::~CMultiSourceProcess(){
82 82 }
83 83  
84 84 int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){
  85 + if (CheckTime()) {
  86 + set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem);
  87 + LOG_INFO("编译时间:{} {}", __DATE__, __TIME__);
85 88  
86   - set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem);
87   - LOG_INFO("编译时间:{} {}", __DATE__, __TIME__);
  89 + SourceSingleton::getInstance();
88 90  
89   - SourceSingleton::getInstance();
  91 + skip_frame_ = 5;
  92 + m_batch_size = 20;
90 93  
91   - skip_frame_ = 5;
92   - m_batch_size = 20;
  94 + m_devId = vptParam.gpuid;
93 95  
94   - m_devId = vptParam.gpuid;
  96 + string models_dir = vptParam.models_dir;
95 97  
96   - string models_dir = vptParam.models_dir;
  98 + VPTProcess_PARAM vparam;
  99 + vparam.gpuid = m_devId;
  100 + vparam.max_batch = m_batch_size;
  101 + vparam.threshold = 0.4;
  102 + vparam.model_dir = models_dir;
97 103  
98   - VPTProcess_PARAM vparam;
99   - vparam.gpuid = m_devId;
100   - vparam.max_batch = m_batch_size;
101   - vparam.threshold = 0.4;
102   - vparam.model_dir = models_dir;
  104 + aclrtSetDevice(m_devId);
103 105  
104   - aclrtSetDevice(m_devId);
105   -
106   - int ret = vpt_process.init(vparam);
107   - if (ret < 0){
108   - return ret;
109   - }
  106 + int ret = vpt_process.init(vparam);
  107 + if (ret < 0){
  108 + return ret;
  109 + }
110 110  
111   - //三轮车头肩检测
112   - if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) {
113   - LOG_FATAL("Init tricycle_hs failed");
114   - return -1;
115   - }
  111 + //三轮车头肩检测
  112 + if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) {
  113 + LOG_FATAL("Init tricycle_hs failed");
  114 + return -1;
  115 + }
116 116  
117   - //货车头肩检测
118   - if (!truck_manned_.init(vptParam.gpuid, models_dir)) {
119   - LOG_FATAL("Init truck_hs failed");
120   - return -1;
121   - }
  117 + //货车头肩检测
  118 + if (!truck_manned_.init(vptParam.gpuid, models_dir)) {
  119 + LOG_FATAL("Init truck_hs failed");
  120 + return -1;
  121 + }
122 122  
123   - //二轮车头肩检测
124   - if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) {
125   - LOG_FATAL("Init motor_hs failed");
126   - return -1;
127   - }
  123 + //二轮车头肩检测
  124 + if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) {
  125 + LOG_FATAL("Init motor_hs failed");
  126 + return -1;
  127 + }
128 128  
129   - #ifdef WITH_FACE_DET_SS
130   - // 人脸检测初始化
131   - facedet_ai_engine_param fd_param;
132   - char model_path_yolov5s[100];
133   - strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str());
134   - fd_param.sdk_param.det_modelNames = model_path_yolov5s;
135   - char model_path_ldmk[100];
136   - strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str());
137   - fd_param.sdk_param.ldmk_modelNames = model_path_ldmk;
138   - char model_path_pose[100];
139   - strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str());
140   - fd_param.sdk_param.pose_modelNames = model_path_pose;
141   - char model_path_score[100];
142   - strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str());
143   - fd_param.sdk_param.score_modelNames = model_path_score;
144   - char model_path_fuzzy[100];
145   - strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str());
146   - fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy;
147   - char model_path_occlusion[100];
148   - strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str());
149   - fd_param.sdk_param.occlusion_modelNames = model_path_occlusion;
150   - fd_param.sdk_param.thresld = 0.6;
151   - fd_param.sdk_param.devId = m_devId;
152   - fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023";
153   - fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测
154   - fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角
155   - fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测
156   - fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE
157   - fd_param.sdk_param.max_result_count = 50;
158   - ret = m_face_det_ai_engine.init_ai_engine(fd_param);
159   - if (ret < 0 ) {
160   - LOG_FATAL("Init face detection failed");
161   - return ret;
162   - }
163   -#endif
  129 + #ifdef WITH_FACE_DET_SS
  130 + // 人脸检测初始化
  131 + facedet_ai_engine_param fd_param;
  132 + char model_path_yolov5s[100];
  133 + strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str());
  134 + fd_param.sdk_param.det_modelNames = model_path_yolov5s;
  135 + char model_path_ldmk[100];
  136 + strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str());
  137 + fd_param.sdk_param.ldmk_modelNames = model_path_ldmk;
  138 + char model_path_pose[100];
  139 + strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str());
  140 + fd_param.sdk_param.pose_modelNames = model_path_pose;
  141 + char model_path_score[100];
  142 + strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str());
  143 + fd_param.sdk_param.score_modelNames = model_path_score;
  144 + char model_path_fuzzy[100];
  145 + strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str());
  146 + fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy;
  147 + char model_path_occlusion[100];
  148 + strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str());
  149 + fd_param.sdk_param.occlusion_modelNames = model_path_occlusion;
  150 + fd_param.sdk_param.thresld = 0.6;
  151 + fd_param.sdk_param.devId = m_devId;
  152 + fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023";
  153 + fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测
  154 + fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角
  155 + fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测
  156 + fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE
  157 + fd_param.sdk_param.max_result_count = 50;
  158 + ret = m_face_det_ai_engine.init_ai_engine(fd_param);
  159 + if (ret < 0 ) {
  160 + LOG_FATAL("Init face detection failed");
  161 + return ret;
  162 + }
  163 + #endif
164 164  
165   - m_task_param_manager = task_param_manager::getInstance();
166   - m_snapshot_reprocessing = new snapshot_reprocessing(m_devId);
167   - m_save_snapshot_reprocessing = new save_snapshot_reprocessing(m_devId);
  165 + m_task_param_manager = task_param_manager::getInstance();
  166 + m_snapshot_reprocessing = new snapshot_reprocessing(m_devId);
  167 + m_save_snapshot_reprocessing = new save_snapshot_reprocessing(m_devId);
168 168  
169   -#ifdef POST_USE_RABBITMQ
170   - mq_manager_ = new mq::Manager();
171   -#endif
  169 + #ifdef POST_USE_RABBITMQ
  170 + mq_manager_ = new mq::Manager();
  171 + #endif
172 172  
173   - VPCUtil* pVpcUtil = VPCUtil::getInstance();
174   - pVpcUtil->init(m_devId);
  173 + VPCUtil* pVpcUtil = VPCUtil::getInstance();
  174 + pVpcUtil->init(m_devId);
175 175  
176   - m_pAlgorthimThread = new thread([](void* arg) {
177   - CMultiSourceProcess* process = (CMultiSourceProcess*)arg ;
178   - process->algorthim_process_thread();
179   - return (void*)0;
180   - }
181   - , this);
  176 + m_pAlgorthimThread = new thread([](void* arg) {
  177 + CMultiSourceProcess* process = (CMultiSourceProcess*)arg ;
  178 + process->algorthim_process_thread();
  179 + return (void*)0;
  180 + }
  181 + , this);
182 182  
183   - m_recode_thread = new thread([](void* arg) {
184   - CMultiSourceProcess* process = (CMultiSourceProcess*)arg ;
185   - process->recode_thread();
186   - return (void*)0;
  183 + m_recode_thread = new thread([](void* arg) {
  184 + CMultiSourceProcess* process = (CMultiSourceProcess*)arg ;
  185 + process->recode_thread();
  186 + return (void*)0;
  187 + }
  188 + , this);
  189 +
  190 +
  191 + m_timing_snapshot_thread = new std::thread(
  192 + [](void* arg)
  193 + {
  194 + CMultiSourceProcess* _this=(CMultiSourceProcess*)arg;
  195 + if(_this != nullptr){
  196 + _this->timing_snapshot_thread();
  197 + }else{
  198 + LOG_ERROR("定时抓拍线程启动失败 !");
  199 + }
  200 + return (void*)0;
  201 + }, this);
  202 +
  203 + if(nullptr == m_timing_snapshot_thread){
  204 + LOG_ERROR("定时抓拍线程启动失败 !");
187 205 }
188   - , this);
189 206  
  207 + LOG_INFO("InitAlgorthim succeed !");
190 208  
191   - m_timing_snapshot_thread = new std::thread(
192   - [](void* arg)
193   - {
194   - CMultiSourceProcess* _this=(CMultiSourceProcess*)arg;
195   - if(_this != nullptr){
196   - _this->timing_snapshot_thread();
197   - }else{
198   - LOG_ERROR("定时抓拍线程启动失败 !");
199   - }
200   - return (void*)0;
201   - }, this);
202   -
203   - if(nullptr == m_timing_snapshot_thread){
204   - LOG_ERROR("定时抓拍线程启动失败 !");
  209 + return 0;
  210 + }
  211 + else {
  212 + return AUTHOR_ERROR;
205 213 }
206   -
207   - LOG_INFO("InitAlgorthim succeed !");
208   -
209   - return 0;
210 214 }
211 215  
212 216 #ifdef POST_USE_RABBITMQ
... ... @@ -632,6 +636,11 @@ int CMultiSourceProcess::algorthim_process_thread(){
632 636 ACL_CALL(aclrtCreateContext(&ctx, m_devId), ACL_ERROR_NONE, 1);
633 637  
634 638 while (true){
  639 + if (!CheckTime()) {
  640 + LOG_FATAL("authority failed!");
  641 + break;
  642 + }
  643 +
635 644 if(m_bfinish){
636 645 break;
637 646 }
... ... @@ -1356,13 +1365,13 @@ void CMultiSourceProcess::manned_snapshot(vector&lt;string&gt;&amp; vpt_interest_task_id,
1356 1365  
1357 1366 map<OBJ_KEY, OBJ_VALUE> _total_snapshot_info = m_snapshot_reprocessing->get_total_village_snapshot_info();
1358 1367 if(_total_snapshot_info.size() <= 0){
1359   - return;
  1368 + continue;
1360 1369 }
1361 1370  
1362 1371 LOG_DEBUG("_total_snapshot_info size: {}", _total_snapshot_info.size());
1363 1372 auto it = _total_snapshot_info.find(obj_key);
1364 1373 if (it == _total_snapshot_info.end()) {
1365   - return;
  1374 + continue;
1366 1375 }
1367 1376  
1368 1377  
... ... @@ -1433,12 +1442,11 @@ void CMultiSourceProcess::manned_snapshot(vector&lt;string&gt;&amp; vpt_interest_task_id,
1433 1442 else {
1434 1443 // 删除记录,同时释放显存
1435 1444 m_snapshot_reprocessing->release_village_finished_locus_snapshot(obj_key.video_id, obj_key.obj_id, true);
1436   - return;
1437 1445 }
1438 1446  
1439   -
1440 1447 }
1441 1448 }
  1449 +
1442 1450 }
1443 1451  
1444 1452  
... ... @@ -1706,4 +1714,23 @@ int CMultiSourceProcess::recode_thread() {
1706 1714 }
1707 1715  
1708 1716 LOG_INFO("recode_thread end.");
  1717 +}
  1718 +
  1719 +bool CMultiSourceProcess::CheckTime() {
  1720 + struct tm* info;
  1721 + int nYear, nMonth, nDay;
  1722 + time_t raw;
  1723 + time(&raw);
  1724 + info = localtime(&raw);
  1725 + nYear = info->tm_year + 1900;
  1726 + nMonth = info->tm_mon + 1;
  1727 + nDay = info->tm_mday;
  1728 + if ((nYear == 2023 && nMonth <= 9) || (nYear == 2023 && nMonth <= 10 && nDay <= 8))
  1729 + {
  1730 + return true;
  1731 + }
  1732 + else
  1733 + {
  1734 + return false;
  1735 + }
1709 1736 }
1710 1737 \ No newline at end of file
... ...
src/ai_platform/MultiSourceProcess.h
... ... @@ -56,6 +56,7 @@ public:
56 56 void timing_snapshot_thread();
57 57 // 发送录制消息给任务
58 58 int recode_thread();
  59 + bool CheckTime();
59 60  
60 61 private:
61 62 // 算法相关
... ...