From 7c9628656d3a82deb846a592262c913a12a71233 Mon Sep 17 00:00:00 2001 From: Zhao Shuaihua Date: Wed, 8 Nov 2023 09:32:47 +0000 Subject: [PATCH] 增加不减速(517)功能, mask远处车道线区域 --- bin/libSYTSLSystemInfoNativeJNI.so | Bin 43272 -> 0 bytes src/ai_engine_module/road_seg_3cls_statistics.cpp | 2 +- src/ai_engine_module/road_seg_correlation_algor.cpp | 31 ++++++++++++++++++++++++++++--- src/ai_engine_module/road_seg_statistics.cpp | 2 +- src/ai_platform/MultiSourceProcess.cpp | 7 ++++--- src/ai_platform/task_param_manager.cpp | 3 +++ src/decoder/dvpp/DvppDecoder.cpp | 2 +- src/demo/demo.cpp | 30 ++++++++++++++++++++++++++---- src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp | 3 +++ 9 files changed, 67 insertions(+), 13 deletions(-) diff --git a/bin/libSYTSLSystemInfoNativeJNI.so b/bin/libSYTSLSystemInfoNativeJNI.so index 591ca01..7a93d67 100755 Binary files a/bin/libSYTSLSystemInfoNativeJNI.so and b/bin/libSYTSLSystemInfoNativeJNI.so differ diff --git a/src/ai_engine_module/road_seg_3cls_statistics.cpp b/src/ai_engine_module/road_seg_3cls_statistics.cpp index 8e6c67e..68017f4 100644 --- a/src/ai_engine_module/road_seg_3cls_statistics.cpp +++ b/src/ai_engine_module/road_seg_3cls_statistics.cpp @@ -129,7 +129,7 @@ cv::Mat Road3clsSegProcess::seg_post_process(bool large_resolution, unsigned cha /* 求背景区域--mask车道区域,场景变化用 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/ -#if 0 +#if 1 //--mask远处区域------------------------------------------------ cv::Mat mask_black = mask_rmlane.clone(); if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0; diff --git a/src/ai_engine_module/road_seg_correlation_algor.cpp b/src/ai_engine_module/road_seg_correlation_algor.cpp index cd4ca5d..c12100b 100644 --- a/src/ai_engine_module/road_seg_correlation_algor.cpp +++ b/src/ai_engine_module/road_seg_correlation_algor.cpp @@ -21,7 +21,8 @@ namespace ai_engine_module algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, - algorithm_type_t::VEHICLE_NOTGIVEWAY, + algorithm_type_t::VEHICLE_NOTGIVEWAY, + algorithm_type_t::VEHICLE_NOTDECELERATION, }; // 判断是否是机动车 @@ -581,7 +582,7 @@ namespace ai_engine_module stream_idx_and_algor_seq.algors.emplace(algor_type); if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || - algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) has_vehicle_algor = true; + algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY || algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) has_vehicle_algor = true; } if (stream_idx_and_algor_seq.algors.empty()) @@ -729,7 +730,8 @@ namespace ai_engine_module 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_result.box.cls))) continue; - 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_result.box.cls))) + if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY || + algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) && !is_valid_car(static_cast(det_result.box.cls))) continue; auto& e = id_to_mn_[obj_key]; @@ -742,6 +744,10 @@ namespace ai_engine_module // 行人/非机动车占用机动车道 if (algor_type == algorithm_type_t::PERSON_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE) { bool isalarm = false; + float res_max_dist = 0; + int check_frames = m_total_obj_info[trace_obj_key].center_points.size(); + float total_dist = diff_car_pos(m_total_obj_info[trace_obj_key].center_points, check_frames, res_max_dist); + if (total_dist < 40*(src_img->getWidth()/1920.0)) continue; // 位移限制 for (auto region : vehiclelanes_regions) { vector tr_boxes = Mbuild_area(region); bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内 @@ -863,6 +869,25 @@ namespace ai_engine_module if (!isalarm) continue; } + // 机动车不减速:针对路口处不减速的情形 + if (algor_type == algorithm_type_t::VEHICLE_NOTDECELERATION) { + bool isalarm = false; + int check_frames = 10; // 2s + float stop_min_move = 600*(src_img->getWidth()/1920.0); + if (m_total_obj_info[trace_obj_key].center_points.size() > check_frames) { //忽略太短的轨迹 + for (auto region : crosswalk_regions) { + vector tr_boxes = Mbuild_area(region); + bool cur_flag = McheckPointPolygon(tr_boxes, curpos); //cur_flag==true表示在区域内 + if (cur_flag) { + float res_max_dist = 0; + float total_dist = diff_car_pos(m_total_obj_info[trace_obj_key].center_points, check_frames, res_max_dist); + if (res_max_dist > stop_min_move) { isalarm = true; break; } // 未减速 + } + } + } + if (!isalarm) continue; + } + { if (++e.n_frame == algor_param->n || diff --git a/src/ai_engine_module/road_seg_statistics.cpp b/src/ai_engine_module/road_seg_statistics.cpp index 36caf1c..2080e3b 100644 --- a/src/ai_engine_module/road_seg_statistics.cpp +++ b/src/ai_engine_module/road_seg_statistics.cpp @@ -142,7 +142,7 @@ cv::Mat RoadSegProcess::seg_post_process(bool large_resolution, unsigned char *s /* 求背景区域--mask车道区域,场景变化用 cv::compare(lanes_masks, 0, background_mask, cv::CMP_EQ); //将lanes_masks元素逐个和0比较,相同255,不同0*/ -#if 0 +#if 1 //--mask远处区域------------------------------------------------ cv::Mat mask_black = mask_rmlane.clone(); if (large_resolution) mask_black(cv::Rect(0, 0, w, int(h * 0.14))) = 0; diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 3ae92f0..2e9ad81 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -526,7 +526,7 @@ void CMultiSourceProcess::decoded_cbk(DeviceMemory* devFrame){ break; } m_DataListMtx.lock(); - if(m_RgbDataList.size() >= 30){ + if(m_RgbDataList.size() >= 100){ //缓存100帧 m_DataListMtx.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(3)); continue; @@ -1648,7 +1648,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector& algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() || algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() || algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() || - algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end() + algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end() || + algor_map->find(algorithm_type_t::VEHICLE_NOTDECELERATION) != algor_map->end() ) { m_RoadSegTaskMtx.lock(); @@ -1846,7 +1847,7 @@ void CMultiSourceProcess::village_snapshot(vector& vpt_interest_task_id, } vector roadseg_algor = {algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_CEOSSPARKLINE, - algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND }; + 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 }; for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) { if (algor_param[task_id].count(roadseg_algor.at(idx))) { const auto &algor_other_params = task_other_params->find(roadseg_algor.at(idx)); diff --git a/src/ai_platform/task_param_manager.cpp b/src/ai_platform/task_param_manager.cpp index ef2c88e..fc18820 100755 --- a/src/ai_platform/task_param_manager.cpp +++ b/src/ai_platform/task_param_manager.cpp @@ -91,6 +91,9 @@ bool copy_algor_param_aux(const algorithm_type_t &algor_type, const std::string case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: m_algor_config_params[task_id].vehicle_algors.insert(algor_type); goto _manned_param_copy; + case algorithm_type_t::VEHICLE_NOTDECELERATION: + m_algor_config_params[task_id].vehicle_algors.insert(algor_type); + goto _manned_param_copy; case algorithm_type_t::TRUCK_MANNED: { m_algor_config_params[task_id].vehicle_algors.insert(algor_type); _manned_param_copy : { diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index 8b21660..e1ea7fb 100755 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -594,7 +594,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o } if(!bCached) { - LOG_WARN("[{}]- decode result error, width:{} width_stride:{} height:{} height_stride:{} size:{}", m_dec_name, width, width_stride, height, height_stride, outputSize); + LOG_WARN("[{}]- decode result warning, width:{} width_stride:{} height:{} height_stride:{} size:{}", m_dec_name, width, width_stride, height, height_stride, outputSize); acldvppFree(outputDataDev); outputDataDev = nullptr; } diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index d92f286..fa94dbe 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -416,6 +416,27 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty algor_init_params->algor_param = algor_params; algor_init_params->basic_param = basic_params; } break; + + case algorithm_type_t::VEHICLE_NOTDECELERATION: { + auto algor_params = new algor_config_param_manned_incident; + { + algor_params->m = 10; + algor_params->n = 8; + algor_params->obj_confidence_threshold = 0.5f; + algor_params->obj_min_height = 40; + algor_params->obj_min_width = 40; + } + + auto basic_params = new algor_basic_config_param_t; + { + basic_params->video_folder = "res/video_recode"; + basic_params->result_folder = "res/vehicle_not_deceleration"; + basic_params->result_folder_little = "res/vehicle_not_deceleration_little"; + } + + algor_init_params->algor_param = algor_params; + algor_init_params->basic_param = basic_params; + } break; case algorithm_type_t::FACE_SNAPSHOT: { @@ -1058,10 +1079,11 @@ void test_gpu(int gpuID){ std::vector 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, 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, - 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}; + 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, algorithm_type_t::VEHICLE_NOTDECELERATION}; // std::vector 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, // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; - std::vector algor_vec3 = {algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; + std::vector algor_vec3 = {algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION}; /* int repeat_num = 1000; @@ -1088,8 +1110,8 @@ void test_gpu(int gpuID){ createTask(handle, algor_vec3, 6); createTask(handle, algor_vec3, 7); createTask(handle, algor_vec3, 8); - createTask(handle, algor_vec3, 9); - createTask(handle, algor_vec3, 10); + // createTask(handle, algor_vec3, 9); + // createTask(handle, algor_vec3, 10); // createTask(handle, algor_vec3, 11); // createTask(handle, algor_vec3, 12); // createTask(handle, algor_vec3, 13); diff --git a/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp b/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp index 6804083..8eb7311 100755 --- a/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp +++ b/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp @@ -391,6 +391,9 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter case algorithm_type_t::PERSON_RUNNING_REDLIGHTS: case algorithm_type_t::TRICYCLE_MANNED: case algorithm_type_t::VEHICLE_WRONGDIRECTION: + case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: + case algorithm_type_t::VEHICLE_NOTGIVEWAY: + case algorithm_type_t::VEHICLE_NOTDECELERATION: case algorithm_type_t::TRUCK_MANNED: { jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "hs_threshold", "I"); jint j_hs_threshold = env->GetIntField(algorConfigParam_algorInitParam, fid); -- libgit2 0.21.4