From 3d1ce1297ec7122bebe6ea5ef2de6bb92070604d Mon Sep 17 00:00:00 2001 From: fiss <2657262686@qq.com> Date: Wed, 30 Aug 2023 16:53:50 +0800 Subject: [PATCH] 修正抠图失败还会保存原图的问题; 修复人脸轨迹结束后抠图信息没删除的问题 --- src/ai_platform/MultiSourceProcess.cpp | 35 +++++++++++++---------------------- src/reprocessing_module/snapshot_reprocessing.cpp | 35 +++++++++++++++++++++++++++++++++++ src/reprocessing_module/snapshot_reprocessing.h | 1 + 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 2febdf7..7262bdf 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -693,6 +693,7 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna m_task_param_manager->delete_task_param(taskID); #endif m_snapshot_reprocessing->release_finished_locus_snapshot(taskID); + m_snapshot_reprocessing->release_finished_face_locus_snapshot(taskID); m_snapshot_reprocessing->release_village_finished_locus_snapshot(taskID); return true; @@ -879,9 +880,6 @@ int CMultiSourceProcess::algorthim_vpt(vector vec_gpuMem){ manned_snapshot(vpt_interest_task_id, vec_vptMem, deleteObjectID); #endif - // if(vptResult.size() > 0){ - // cout << vptResult[0].obj_count<< endl; - // } vptResult.clear(); unUsedResult.clear(); deleteObjectID.clear(); @@ -910,6 +908,14 @@ int CMultiSourceProcess::algorithm_vehicle_relult(vector vec_devM LOG_ERROR("taskId {} not found algor {}", task_id.c_str(), (int)algorithm_type_t::VEHICLE_SNAPSHOT); continue; } + + vector vec_obj_info_list = pVPCUtil->crop_batch(result.memPtr, result.objs); + if(vec_obj_info_list.size() != result.objs.size()){ + LOG_ERROR("vpc_crop size error !"); + VPCUtil::vpc_imgList_release(vec_obj_info_list); + continue; + } + const algor_basic_config_param_t *basic_param = algor_other_params->second->basic_param; std::string cur_timestamp_ms = std::to_string(helpers::timer::get_cur_time_ms()); @@ -921,13 +927,6 @@ int CMultiSourceProcess::algorithm_vehicle_relult(vector vec_devM saveInfo.img_info = VPCUtil::vpc_devMem2vpcImg(result.memPtr); m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(saveInfo); - vector vec_obj_info_list = pVPCUtil->crop_batch(result.memPtr, result.objs); - if(vec_obj_info_list.size() != result.objs.size()){ - LOG_ERROR("vpc_crop size error !"); - VPCUtil::vpc_imgList_release(vec_obj_info_list); - continue; - } - // 保存抠图并发MQ for(int i =0; i < result.objs.size(); i++){ video_object_info obj = result.objs[i]; @@ -1013,7 +1012,7 @@ void CMultiSourceProcess::vehicle_snapshot(vector& vpt_interest_task_id, } void CMultiSourceProcess::vehicle_locus_finished(const OBJ_KEY obj_key) { - LOG_DEBUG("vehicle_locus_finished in"); + auto task_param_ptr = m_task_param_manager->get_task_algor_param(obj_key.video_id); if (task_param_ptr == nullptr){ return; @@ -1050,8 +1049,6 @@ void CMultiSourceProcess::vehicle_locus_finished(const OBJ_KEY obj_key) { LOG_DEBUG("algor_type"); auto algor_type = index_to_algo_type[obj_value.index.index]; - - LOG_DEBUG("task_other_param"); auto it_algor_type = task_other_param.find(algor_type); if(it_algor_type == task_other_param.end()) { @@ -1060,11 +1057,6 @@ void CMultiSourceProcess::vehicle_locus_finished(const OBJ_KEY obj_key) { LOG_DEBUG("algor_param"); auto algor_param = (algor_config_param_snapshot *)it_algor_type->second->algor_param; - - - - - // auto algor_param = (algor_config_param_snapshot *)task_other_param[algor_type]->algor_param; if(algor_param == nullptr) { return; } @@ -1137,7 +1129,7 @@ void CMultiSourceProcess::timing_snapshot_thread(){ DecoderManager* pDecManager = DecoderManager::getInstance(); while(!m_bfinish){ vector vec_devMem = pDecManager->timing_snapshot_all(); - for (auto devMem : vec_devMem){ + for (auto devMem : vec_devMem) { auto task_id = devMem->getId(); auto task_other_params = m_task_param_manager->get_task_other_param(task_id); if (task_other_params == nullptr) @@ -1803,9 +1795,8 @@ void CMultiSourceProcess::face_locus_finished(const OBJ_KEY obj_key) { roi_save_info.json_str = json_str; m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(roi_save_info); - - _total_face_snapshot_info.erase(obj_key); - + // 删除结束轨迹的数据 + m_snapshot_reprocessing->release_finished_face_locus_snapshot(obj_key.video_id, obj_key.obj_id, false); } int CMultiSourceProcess::recode_thread() { diff --git a/src/reprocessing_module/snapshot_reprocessing.cpp b/src/reprocessing_module/snapshot_reprocessing.cpp index 3bd6e40..95e31f7 100755 --- a/src/reprocessing_module/snapshot_reprocessing.cpp +++ b/src/reprocessing_module/snapshot_reprocessing.cpp @@ -819,4 +819,39 @@ void snapshot_reprocessing::release_village_finished_locus_snapshot(const string map snapshot_reprocessing::get_total_face_snapshot_info(){ return total_face_snapshot_info; +} + +void snapshot_reprocessing::release_finished_face_locus_snapshot(const string taskid, const int obj_id, bool bRelease) { + + LOG_DEBUG("[info] task_id {} delete obj_id {}", taskid, obj_id); //221026 + if (obj_id != -1) { + OBJ_KEY cur_key = { taskid , obj_id }; + auto it = total_face_snapshot_info.find(cur_key); + if (it == total_face_snapshot_info.end()){ + return; + } + + if (bRelease){ + OBJ_VALUE ss = total_face_snapshot_info[cur_key]; + + VPCUtil::vpc_img_release(ss.snapShot); + VPCUtil::vpc_img_release(ss.snapShotLittle); + } + + total_face_snapshot_info.erase(cur_key); + return; + } + + for(auto ss = total_face_snapshot_info.begin(); ss != total_face_snapshot_info.end(); ss++) + { + if (strcmp(ss->first.video_id.c_str(), taskid.c_str()) == 0) + { + if (bRelease){ + VPCUtil::vpc_img_release(ss->second.snapShot); + VPCUtil::vpc_img_release(ss->second.snapShotLittle); + } + total_face_snapshot_info.erase(ss); + return; + } + } } \ No newline at end of file diff --git a/src/reprocessing_module/snapshot_reprocessing.h b/src/reprocessing_module/snapshot_reprocessing.h index d513316..3171da8 100755 --- a/src/reprocessing_module/snapshot_reprocessing.h +++ b/src/reprocessing_module/snapshot_reprocessing.h @@ -84,6 +84,7 @@ public: void release_finished_locus_snapshot(const string taskid, const int objid = -1, bool bRelease = true); //-1为删除该路所有任务的快照图 void release_village_finished_locus_snapshot(const string taskid, const int objid = -1, bool bRelease = true); + void release_finished_face_locus_snapshot(const string taskid, const int objid = -1, bool bRelease = true); private: bool best_snapshot_judge_algor(const OBJ_KEY& obj_key, const OBJ_VALUE& obj_value, int left, int top, int width, int height, int image_width, int image_height); -- libgit2 0.21.4