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,7 +129,7 @@ cv::Mat Road3clsSegProcess::seg_post_process(bool large_resolution, unsigned cha
129 129
130 /* 求背景区域--mask车道区域,场景变化用 130 /* 求背景区域--mask车道区域,场景变化用
131 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/ 131 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/
132 -#if 0 132 +#if 1
133 //--mask远处区域------------------------------------------------ 133 //--mask远处区域------------------------------------------------
134 cv::Mat mask_black = mask_rmlane.clone(); 134 cv::Mat mask_black = mask_rmlane.clone();
135 if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0; 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,7 +21,8 @@ namespace ai_engine_module
21 algorithm_type_t::NONMOTOR_WRONGDIRECTION, 21 algorithm_type_t::NONMOTOR_WRONGDIRECTION,
22 algorithm_type_t::VEHICLE_WRONGDIRECTION, 22 algorithm_type_t::VEHICLE_WRONGDIRECTION,
23 algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, 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,7 +582,7 @@ namespace ai_engine_module
581 582
582 stream_idx_and_algor_seq.algors.emplace(algor_type); 583 stream_idx_and_algor_seq.algors.emplace(algor_type);
583 if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || 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 if (stream_idx_and_algor_seq.algors.empty()) 588 if (stream_idx_and_algor_seq.algors.empty())
@@ -729,7 +730,8 @@ namespace ai_engine_module @@ -729,7 +730,8 @@ namespace ai_engine_module
729 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 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 continue; 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 continue; 735 continue;
734 736
735 auto& e = id_to_mn_[obj_key]; 737 auto& e = id_to_mn_[obj_key];
@@ -742,6 +744,10 @@ namespace ai_engine_module @@ -742,6 +744,10 @@ namespace ai_engine_module
742 // 行人/非机动车占用机动车道 744 // 行人/非机动车占用机动车道
743 if (algor_type == algorithm_type_t::PERSON_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE) { 745 if (algor_type == algorithm_type_t::PERSON_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE) {
744 bool isalarm = false; 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 for (auto region : vehiclelanes_regions) { 751 for (auto region : vehiclelanes_regions) {
746 vector<tr_point> tr_boxes = Mbuild_area(region); 752 vector<tr_point> tr_boxes = Mbuild_area(region);
747 bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内 753 bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内
@@ -863,6 +869,25 @@ namespace ai_engine_module @@ -863,6 +869,25 @@ namespace ai_engine_module
863 if (!isalarm) continue; 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 if (++e.n_frame == algor_param->n || 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,7 +142,7 @@ cv::Mat RoadSegProcess::seg_post_process(bool large_resolution, unsigned char *s
142 142
143 /* 求背景区域--mask车道区域,场景变化用 143 /* 求背景区域--mask车道区域,场景变化用
144 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/ 144 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/
145 -#if 0 145 +#if 1
146 //--mask远处区域------------------------------------------------ 146 //--mask远处区域------------------------------------------------
147 cv::Mat mask_black = mask_rmlane.clone(); 147 cv::Mat mask_black = mask_rmlane.clone();
148 if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0; 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,7 +526,7 @@ void CMultiSourceProcess::decoded_cbk(DeviceMemory* devFrame){
526 break; 526 break;
527 } 527 }
528 m_DataListMtx.lock(); 528 m_DataListMtx.lock();
529 - if(m_RgbDataList.size() >= 30){ 529 + if(m_RgbDataList.size() >= 100){ //缓存100帧
530 m_DataListMtx.unlock(); 530 m_DataListMtx.unlock();
531 std::this_thread::sleep_for(std::chrono::milliseconds(3)); 531 std::this_thread::sleep_for(std::chrono::milliseconds(3));
532 continue; 532 continue;
@@ -1648,7 +1648,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector&lt;string&gt;&amp; @@ -1648,7 +1648,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector&lt;string&gt;&amp;
1648 algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() || 1648 algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() ||
1649 algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() || 1649 algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() ||
1650 algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() || 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 m_RoadSegTaskMtx.lock(); 1655 m_RoadSegTaskMtx.lock();
@@ -1846,7 +1847,7 @@ void CMultiSourceProcess::village_snapshot(vector&lt;string&gt;&amp; vpt_interest_task_id, @@ -1846,7 +1847,7 @@ void CMultiSourceProcess::village_snapshot(vector&lt;string&gt;&amp; vpt_interest_task_id,
1846 } 1847 }
1847 1848
1848 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 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 for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) { 1851 for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) {
1851 if (algor_param[task_id].count(roadseg_algor.at(idx))) { 1852 if (algor_param[task_id].count(roadseg_algor.at(idx))) {
1852 const auto &algor_other_params = task_other_params->find(roadseg_algor.at(idx)); 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,6 +91,9 @@ bool copy_algor_param_aux(const algorithm_type_t &amp;algor_type, const std::string
91 case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: 91 case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND:
92 m_algor_config_params[task_id].vehicle_algors.insert(algor_type); 92 m_algor_config_params[task_id].vehicle_algors.insert(algor_type);
93 goto _manned_param_copy; 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 case algorithm_type_t::TRUCK_MANNED: { 97 case algorithm_type_t::TRUCK_MANNED: {
95 m_algor_config_params[task_id].vehicle_algors.insert(algor_type); 98 m_algor_config_params[task_id].vehicle_algors.insert(algor_type);
96 _manned_param_copy : { 99 _manned_param_copy : {
src/decoder/dvpp/DvppDecoder.cpp
@@ -594,7 +594,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o @@ -594,7 +594,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o
594 } 594 }
595 595
596 if(!bCached) { 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 acldvppFree(outputDataDev); 598 acldvppFree(outputDataDev);
599 outputDataDev = nullptr; 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,6 +416,27 @@ void set_task_params(task_param &amp;tparam, const unsigned &amp;idx, const algorithm_ty
416 algor_init_params->algor_param = algor_params; 416 algor_init_params->algor_param = algor_params;
417 algor_init_params->basic_param = basic_params; 417 algor_init_params->basic_param = basic_params;
418 } break; 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 case algorithm_type_t::FACE_SNAPSHOT: { 442 case algorithm_type_t::FACE_SNAPSHOT: {
@@ -1058,10 +1079,11 @@ void test_gpu(int gpuID){ @@ -1058,10 +1079,11 @@ void test_gpu(int gpuID){
1058 1079
1059 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, 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 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, 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 // 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, 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 // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; 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 int repeat_num = 1000; 1089 int repeat_num = 1000;
@@ -1088,8 +1110,8 @@ void test_gpu(int gpuID){ @@ -1088,8 +1110,8 @@ void test_gpu(int gpuID){
1088 createTask(handle, algor_vec3, 6); 1110 createTask(handle, algor_vec3, 6);
1089 createTask(handle, algor_vec3, 7); 1111 createTask(handle, algor_vec3, 7);
1090 createTask(handle, algor_vec3, 8); 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 // createTask(handle, algor_vec3, 11); 1115 // createTask(handle, algor_vec3, 11);
1094 // createTask(handle, algor_vec3, 12); 1116 // createTask(handle, algor_vec3, 12);
1095 // createTask(handle, algor_vec3, 13); 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,6 +391,9 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter
391 case algorithm_type_t::PERSON_RUNNING_REDLIGHTS: 391 case algorithm_type_t::PERSON_RUNNING_REDLIGHTS:
392 case algorithm_type_t::TRICYCLE_MANNED: 392 case algorithm_type_t::TRICYCLE_MANNED:
393 case algorithm_type_t::VEHICLE_WRONGDIRECTION: 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 case algorithm_type_t::TRUCK_MANNED: { 397 case algorithm_type_t::TRUCK_MANNED: {
395 jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "hs_threshold", "I"); 398 jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "hs_threshold", "I");
396 jint j_hs_threshold = env->GetIntField(algorConfigParam_algorInitParam, fid); 399 jint j_hs_threshold = env->GetIntField(algorConfigParam_algorInitParam, fid);