Commit 7c9628656d3a82deb846a592262c913a12a71233

Authored by Zhao Shuaihua
1 parent 8c495cc9

增加不减速(517)功能, mask远处车道线区域

bin/libSYTSLSystemInfoNativeJNI.so
No preview for this file type
src/ai_engine_module/road_seg_3cls_statistics.cpp
... ... @@ -129,7 +129,7 @@ cv::Mat Road3clsSegProcess::seg_post_process(bool large_resolution, unsigned cha
129 129  
130 130 /* 求背景区域--mask车道区域,场景变化用
131 131 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/
132   -#if 0
  132 +#if 1
133 133 //--mask远处区域------------------------------------------------
134 134 cv::Mat mask_black = mask_rmlane.clone();
135 135 if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0;
... ...
src/ai_engine_module/road_seg_correlation_algor.cpp
... ... @@ -21,7 +21,8 @@ namespace ai_engine_module
21 21 algorithm_type_t::NONMOTOR_WRONGDIRECTION,
22 22 algorithm_type_t::VEHICLE_WRONGDIRECTION,
23 23 algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND,
24   - algorithm_type_t::VEHICLE_NOTGIVEWAY,
  24 + algorithm_type_t::VEHICLE_NOTGIVEWAY,
  25 + algorithm_type_t::VEHICLE_NOTDECELERATION,
25 26 };
26 27  
27 28 // 判断是否是机动车
... ... @@ -581,7 +582,7 @@ namespace ai_engine_module
581 582  
582 583 stream_idx_and_algor_seq.algors.emplace(algor_type);
583 584 if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND ||
584   - algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) has_vehicle_algor = true;
  585 + algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY || algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) has_vehicle_algor = true;
585 586 }
586 587  
587 588 if (stream_idx_and_algor_seq.algors.empty())
... ... @@ -729,7 +730,8 @@ namespace ai_engine_module
729 730 if ((algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::NONMOTOR_WRONGDIRECTION) && !is_valid_nomotor(static_cast<det_class_label_t>(det_result.box.cls)))
730 731 continue;
731 732  
732   - if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) && !is_valid_car(static_cast<det_class_label_t>(det_result.box.cls)))
  733 + if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY ||
  734 + algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) && !is_valid_car(static_cast<det_class_label_t>(det_result.box.cls)))
733 735 continue;
734 736  
735 737 auto& e = id_to_mn_[obj_key];
... ... @@ -742,6 +744,10 @@ namespace ai_engine_module
742 744 // 行人/非机动车占用机动车道
743 745 if (algor_type == algorithm_type_t::PERSON_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE) {
744 746 bool isalarm = false;
  747 + float res_max_dist = 0;
  748 + int check_frames = m_total_obj_info[trace_obj_key].center_points.size();
  749 + float total_dist = diff_car_pos(m_total_obj_info[trace_obj_key].center_points, check_frames, res_max_dist);
  750 + if (total_dist < 40*(src_img->getWidth()/1920.0)) continue; // 位移限制
745 751 for (auto region : vehiclelanes_regions) {
746 752 vector<tr_point> tr_boxes = Mbuild_area(region);
747 753 bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内
... ... @@ -863,6 +869,25 @@ namespace ai_engine_module
863 869 if (!isalarm) continue;
864 870 }
865 871  
  872 + // 机动车不减速:针对路口处不减速的情形
  873 + if (algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) {
  874 + bool isalarm = false;
  875 + int check_frames = 10; // 2s
  876 + float stop_min_move = 600*(src_img->getWidth()/1920.0);
  877 + if (m_total_obj_info[trace_obj_key].center_points.size() > check_frames) { //忽略太短的轨迹
  878 + for (auto region : crosswalk_regions) {
  879 + vector<tr_point> tr_boxes = Mbuild_area(region);
  880 + bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内
  881 + if (cur_flag) {
  882 + float res_max_dist = 0;
  883 + float total_dist = diff_car_pos(m_total_obj_info[trace_obj_key].center_points, check_frames, res_max_dist);
  884 + if (res_max_dist > stop_min_move) { isalarm = true; break; } // 未减速
  885 + }
  886 + }
  887 + }
  888 + if (!isalarm) continue;
  889 + }
  890 +
866 891  
867 892 {
868 893 if (++e.n_frame == algor_param->n ||
... ...
src/ai_engine_module/road_seg_statistics.cpp
... ... @@ -142,7 +142,7 @@ cv::Mat RoadSegProcess::seg_post_process(bool large_resolution, unsigned char *s
142 142  
143 143 /* 求背景区域--mask车道区域,场景变化用
144 144 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/
145   -#if 0
  145 +#if 1
146 146 //--mask远处区域------------------------------------------------
147 147 cv::Mat mask_black = mask_rmlane.clone();
148 148 if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0;
... ...
src/ai_platform/MultiSourceProcess.cpp
... ... @@ -526,7 +526,7 @@ void CMultiSourceProcess::decoded_cbk(DeviceMemory* devFrame){
526 526 break;
527 527 }
528 528 m_DataListMtx.lock();
529   - if(m_RgbDataList.size() >= 30){
  529 + if(m_RgbDataList.size() >= 100){ //缓存100帧
530 530 m_DataListMtx.unlock();
531 531 std::this_thread::sleep_for(std::chrono::milliseconds(3));
532 532 continue;
... ... @@ -1648,7 +1648,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector&lt;string&gt;&amp;
1648 1648 algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() ||
1649 1649 algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() ||
1650 1650 algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() ||
1651   - algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end()
  1651 + algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end() ||
  1652 + algor_map->find(algorithm_type_t::VEHICLE_NOTDECELERATION) != algor_map->end()
1652 1653 ) {
1653 1654  
1654 1655 m_RoadSegTaskMtx.lock();
... ... @@ -1846,7 +1847,7 @@ void CMultiSourceProcess::village_snapshot(vector&lt;string&gt;&amp; vpt_interest_task_id,
1846 1847 }
1847 1848  
1848 1849 vector<algo_type> roadseg_algor = {algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_CEOSSPARKLINE,
1849   - algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND };
  1850 + algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION };
1850 1851 for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) {
1851 1852 if (algor_param[task_id].count(roadseg_algor.at(idx))) {
1852 1853 const auto &algor_other_params = task_other_params->find(roadseg_algor.at(idx));
... ...
src/ai_platform/task_param_manager.cpp
... ... @@ -91,6 +91,9 @@ bool copy_algor_param_aux(const algorithm_type_t &amp;algor_type, const std::string
91 91 case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND:
92 92 m_algor_config_params[task_id].vehicle_algors.insert(algor_type);
93 93 goto _manned_param_copy;
  94 + case algorithm_type_t::VEHICLE_NOTDECELERATION:
  95 + m_algor_config_params[task_id].vehicle_algors.insert(algor_type);
  96 + goto _manned_param_copy;
94 97 case algorithm_type_t::TRUCK_MANNED: {
95 98 m_algor_config_params[task_id].vehicle_algors.insert(algor_type);
96 99 _manned_param_copy : {
... ...
src/decoder/dvpp/DvppDecoder.cpp
... ... @@ -594,7 +594,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o
594 594 }
595 595  
596 596 if(!bCached) {
597   - LOG_WARN("[{}]- decode result error, width:{} width_stride:{} height:{} height_stride:{} size:{}", m_dec_name, width, width_stride, height, height_stride, outputSize);
  597 + LOG_WARN("[{}]- decode result warning, width:{} width_stride:{} height:{} height_stride:{} size:{}", m_dec_name, width, width_stride, height, height_stride, outputSize);
598 598 acldvppFree(outputDataDev);
599 599 outputDataDev = nullptr;
600 600 }
... ...
src/demo/demo.cpp
... ... @@ -416,6 +416,27 @@ void set_task_params(task_param &amp;tparam, const unsigned &amp;idx, const algorithm_ty
416 416 algor_init_params->algor_param = algor_params;
417 417 algor_init_params->basic_param = basic_params;
418 418 } break;
  419 +
  420 + case algorithm_type_t::VEHICLE_NOTDECELERATION: {
  421 + auto algor_params = new algor_config_param_manned_incident;
  422 + {
  423 + algor_params->m = 10;
  424 + algor_params->n = 8;
  425 + algor_params->obj_confidence_threshold = 0.5f;
  426 + algor_params->obj_min_height = 40;
  427 + algor_params->obj_min_width = 40;
  428 + }
  429 +
  430 + auto basic_params = new algor_basic_config_param_t;
  431 + {
  432 + basic_params->video_folder = "res/video_recode";
  433 + basic_params->result_folder = "res/vehicle_not_deceleration";
  434 + basic_params->result_folder_little = "res/vehicle_not_deceleration_little";
  435 + }
  436 +
  437 + algor_init_params->algor_param = algor_params;
  438 + algor_init_params->basic_param = basic_params;
  439 + } break;
419 440  
420 441  
421 442 case algorithm_type_t::FACE_SNAPSHOT: {
... ... @@ -1058,10 +1079,11 @@ void test_gpu(int gpuID){
1058 1079  
1059 1080 std::vector<algorithm_type_t> algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE,
1060 1081 algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS, algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_IN_VEHICLELANE,
1061   - algorithm_type_t::NONMOTOR_CEOSSPARKLINE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND};
  1082 + algorithm_type_t::NONMOTOR_CEOSSPARKLINE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY,
  1083 + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION};
1062 1084 // std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE,
1063 1085 // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS};
1064   - std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND};
  1086 + std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION};
1065 1087  
1066 1088 /*
1067 1089 int repeat_num = 1000;
... ... @@ -1088,8 +1110,8 @@ void test_gpu(int gpuID){
1088 1110 createTask(handle, algor_vec3, 6);
1089 1111 createTask(handle, algor_vec3, 7);
1090 1112 createTask(handle, algor_vec3, 8);
1091   - createTask(handle, algor_vec3, 9);
1092   - createTask(handle, algor_vec3, 10);
  1113 + // createTask(handle, algor_vec3, 9);
  1114 + // createTask(handle, algor_vec3, 10);
1093 1115 // createTask(handle, algor_vec3, 11);
1094 1116 // createTask(handle, algor_vec3, 12);
1095 1117 // createTask(handle, algor_vec3, 13);
... ...
src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp
... ... @@ -391,6 +391,9 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter
391 391 case algorithm_type_t::PERSON_RUNNING_REDLIGHTS:
392 392 case algorithm_type_t::TRICYCLE_MANNED:
393 393 case algorithm_type_t::VEHICLE_WRONGDIRECTION:
  394 + case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND:
  395 + case algorithm_type_t::VEHICLE_NOTGIVEWAY:
  396 + case algorithm_type_t::VEHICLE_NOTDECELERATION:
394 397 case algorithm_type_t::TRUCK_MANNED: {
395 398 jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "hs_threshold", "I");
396 399 jint j_hs_threshold = env->GetIntField(algorConfigParam_algorInitParam, fid);
... ...