Commit 10667f7cf930d79a1dc63424322e9c5ac0da470c

Authored by Hu Chunming
1 parent bb2c60a8

违法载人判断的优化

src/PicAnalysis.cpp
@@ -36,14 +36,14 @@ int PicAnalysis::init(VillageParam param) { @@ -36,14 +36,14 @@ int PicAnalysis::init(VillageParam param) {
36 return -1; 36 return -1;
37 } 37 }
38 38
39 - // head_tail_param ht_param;  
40 - // ht_param.devId = dev_id;  
41 - // ht_param.max_batch = 16;  
42 - // ht_param.sdk_path = param.sdk_path;  
43 - // ret = m_head_tail_algorithm.init(ht_param);  
44 - // if(0 != ret){  
45 - // return -1;  
46 - // } 39 + head_tail_param ht_param;
  40 + ht_param.devId = dev_id;
  41 + ht_param.max_batch = 16;
  42 + ht_param.sdk_root = param.sdk_path;
  43 + ret = m_head_tail_algorithm.init(ht_param);
  44 + if(0 != ret){
  45 + return -1;
  46 + }
47 47
48 ret = m_clothes_algorithm.init(dev_id, param.sdk_path); 48 ret = m_clothes_algorithm.init(dev_id, param.sdk_path);
49 if(0 != ret){ 49 if(0 != ret){
@@ -157,6 +157,7 @@ vector<AnalysisResult> PicAnalysis::va_result2AnalysisResult(va_result* result, @@ -157,6 +157,7 @@ vector<AnalysisResult> PicAnalysis::va_result2AnalysisResult(va_result* result,
157 info.type = result_info.type ; 157 info.type = result_info.type ;
158 info.vpt_type = result_info.vpt_type ; 158 info.vpt_type = result_info.vpt_type ;
159 159
  160 +
160 auto pendant_result = result_info.vehicle_pendant_det_res; 161 auto pendant_result = result_info.vehicle_pendant_det_res;
161 for (size_t j = 0; j < pendant_result.count; j++) 162 for (size_t j = 0; j < pendant_result.count; j++)
162 { 163 {
@@ -243,7 +244,7 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){ @@ -243,7 +244,7 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){
243 } 244 }
244 245
245 // 行人 246 // 行人
246 - if (6 == shot_type) 247 + if (0 == result_info.vpt_type)
247 { 248 {
248 ImageData* human_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_); 249 ImageData* human_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
249 250
@@ -262,20 +263,39 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){ @@ -262,20 +263,39 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){
262 263
263 delete human_data; 264 delete human_data;
264 human_data = nullptr; 265 human_data = nullptr;
265 - } else if(1 == shot_type) {  
266 - // 车尾,判断是否 货车尾部货厢载人  
267 - if(result_info.vpt_type == 6 || result_info.vpt_type == 7){  
268 - if(result_info.manned_res.hs_count > 0){  
269 - result_info.truck_manned = 1;  
270 - }  
271 - } 266 + } else if(result_info.vpt_type == 1 || result_info.vpt_type == 2 || result_info.vpt_type == 3){
  267 + if(result_info.manned_res.hs_count >= 3){
  268 + // 摩托车、三轮车载人
  269 + result_info.motor_manned = 1;
  270 + }
272 } else { 271 } else {
273 - if(result_info.vpt_type == 1 || result_info.vpt_type == 2 || result_info.vpt_type == 3){  
274 - if(result_info.manned_res.hs_count >= 3){  
275 - // 摩托车、三轮车载人  
276 - result_info.motor_manned = 1;  
277 - } 272 + ImageData* vehicle_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
  273 +
  274 + sy_img img;
  275 + img.w_ = vehicle_data->alignWidth;
  276 + img.h_ = vehicle_data->alignHeight;
  277 + img.data_ = vehicle_data->data_naked;
  278 +
  279 + vector<sy_img> vec_vehicle_img;
  280 + vec_vehicle_img.push_back(img);
  281 +
  282 + vector<HeadTailResult> head_tail_result;
  283 + ret = m_head_tail_algorithm.detect(vec_vehicle_img, head_tail_result);
  284 + if (0 != ret) {
  285 + LOG_ERROR("m_head_tail_algorithm failed!");
  286 + head_tail_result.clear();
  287 + } else {
  288 + auto one_ht_result = head_tail_result[0];
  289 +
  290 + if(result_info.vpt_type == 6 || result_info.vpt_type == 7){
  291 + if (one_ht_result.cls == 0 && result_info.manned_res.hs_count > 0)
  292 + { // 车尾,判断是否 货车尾部货厢载人
  293 + result_info.truck_manned = 1;
  294 + }
  295 + }
278 } 296 }
  297 +
  298 +
279 } 299 }
280 300
281 // 司乘 301 // 司乘
@@ -318,10 +338,6 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){ @@ -318,10 +338,6 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){
318 // 摩托车 338 // 摩托车
319 if(shot_type==2)//摩托车 339 if(shot_type==2)//摩托车
320 { 340 {
321 - //摩托车驾驶人是否戴安全帽  
322 - // analysis_result.motor_helmeted = result_info.mta_res.motor_driver_helmeted.status;  
323 - // float score=result_info.mta_res.motor_driver_helmeted.confidence;  
324 -  
325 ImageData* motor_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_); 341 ImageData* motor_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
326 342
327 sy_img img; 343 sy_img img;
@@ -378,13 +394,6 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){ @@ -378,13 +394,6 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){
378 } 394 }
379 } 395 }
380 396
381 - // vector<HeadTailResult> head_tail_result;  
382 - // ret = m_head_tail_algorithm.detect(vec_img, head_tail_result);  
383 - // if (0 != ret) {  
384 - // LOG_ERROR("m_head_tail_algorithm failed!");  
385 - // head_tail_result.clear();  
386 - // }  
387 -  
388 LOG_INFO("analysis finished!"); 397 LOG_INFO("analysis finished!");
389 398
390 return vec_result; 399 return vec_result;
src/ai_engine_module/VehicleAnalysis.cpp
@@ -19,8 +19,8 @@ int VehicleAnalysis::init(int devId, std::string sdk_root, int max_batch_size) { @@ -19,8 +19,8 @@ int VehicleAnalysis::init(int devId, std::string sdk_root, int max_batch_size) {
19 param.vehicle_motor_tricycle_analysis_config= SY_CONFIG_OPEN; //8.摩托车分析 19 param.vehicle_motor_tricycle_analysis_config= SY_CONFIG_OPEN; //8.摩托车分析
20 param.vehicle_manned_config= SY_CONFIG_OPEN; //8.开启载人分析 20 param.vehicle_manned_config= SY_CONFIG_OPEN; //8.开启载人分析
21 param.vehicle_illegal_config= SY_CONFIG_OPEN; //7.开启车违规 21 param.vehicle_illegal_config= SY_CONFIG_OPEN; //7.开启车违规
22 - param.vehicle_color_config= SY_CONFIG_CLOSE; //3.开启车颜色识别  
23 - param.vehicle_feature_config= SY_CONFIG_CLOSE; //8.开启车辆特征提取 22 + param.vehicle_color_config= SY_CONFIG_OPEN; //3.开启车颜色识别
  23 + param.vehicle_feature_config= SY_CONFIG_OPEN; //8.开启车辆特征提取
24 24
25 param.gpuid=devId; 25 param.gpuid=devId;
26 26
src/ai_engine_module/VehicleHeadTail.h
@@ -19,7 +19,7 @@ typedef struct head_tail_param @@ -19,7 +19,7 @@ typedef struct head_tail_param
19 } head_tail_param; 19 } head_tail_param;
20 20
21 struct HeadTailResult { 21 struct HeadTailResult {
22 - int cls; 22 + int cls; // {'车尾': 0, '车侧': 1, '车头': 2}
23 float confidence; 23 float confidence;
24 }; 24 };
25 25
src/common/sy_errorinfo.h
@@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
4 4
5 //--------------------------------通用------------------------------------// 5 //--------------------------------通用------------------------------------//
6 6
7 -#define SY_SUCCESS 0 //成功  
8 #define SY_FAILED -1 //失败 7 #define SY_FAILED -1 //失败
  8 +#define SY_SUCCESS 0 //成功
9 9
10 //1.通用错误 预留编号:(-199) - (-100) 10 //1.通用错误 预留编号:(-199) - (-100)
11 #define SY_PARAMS_NULL_ERROR -100 //参数为空 11 #define SY_PARAMS_NULL_ERROR -100 //参数为空
src/village_inc.h
@@ -28,10 +28,10 @@ struct VillageParam { @@ -28,10 +28,10 @@ struct VillageParam {
28 typedef struct pendant_info 28 typedef struct pendant_info
29 { 29 {
30 sy_rect rect; 30 sy_rect rect;
31 - int index; //���� 0-driver 1-face 2-belt 3-sunshield 4-tag 5-decoration 6-napkinbox 7-zhuanjt 8-callPhone 9-sunRoof 10-holder 11-smoke  
32 - float confidence; 31 + int index{-1}; //���� 0-driver 1-face 2-belt 3-sunshield 4-tag 5-decoration 6-napkinbox 7-zhuanjt 8-callPhone 9-sunRoof 10-holder 11-smoke
  32 + float confidence{0.0};
33 int driver_copilot_info; 33 int driver_copilot_info;
34 - int iColor; // "棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", ,"多色", "其他" 34 + int iColor{14}; // "棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", ,"多色", "其他"
35 } pendant_info; 35 } pendant_info;
36 36
37 typedef struct VehicleInfo { 37 typedef struct VehicleInfo {