From 1d41673e4d71790b3556ef06242c5580f4b1fd50 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Sun, 8 Oct 2023 15:46:25 +0800 Subject: [PATCH] 完全版 --- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp | 2 +- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------- 2 files changed, 145 insertions(+), 156 deletions(-) diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp index 8669eae..2b1e6f5 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp @@ -395,7 +395,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) tasks[i].taskRealTimeCallbackFunc = nullptr; - // m_snaphot_helper.finish_task_ss_analysis(taskID, m_hp_analysis_config, m_hcp_analysis_config, m_vehicle_analysis_config, m_hf_recg_config, m_hcf_recg_config, m_vcf_recg_config); //�Ƿ�����������ʶ��); + m_snaphot_helper.finish_task_ss_analysis(taskID, m_hp_analysis_config, m_hcp_analysis_config, m_vehicle_analysis_config, m_hf_recg_config, m_hcf_recg_config, m_vcf_recg_config); //�Ƿ�����������ʶ��); if (tasks[i].folderName) { diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp index f9eaa16..5353d31 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp @@ -697,165 +697,154 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi } } - // if (!vehicle_keys.empty()) - // { - // const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE; - // const int vehicle_batch_size = vehicle_keys.size(); - // int vehicle_batch_count = obj_batch_count; - // for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i) - // { - // if (i == (vehicle_batch_size / obj_batch_count)) - // vehicle_batch_count = vehicle_batch_size % obj_batch_count; - - // if (vehicle_batch_count == 0) continue; - - // sy_img* finish_vehicle_img = new sy_img[vehicle_batch_count]{}; - - // for (int j = 0; j < vehicle_batch_count; j++) - // { - // OBJ_KEY cur_obj_key = vehicle_keys[j]; - // finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); - // } - - // vc_result *vcresult = new vc_result[vehicle_batch_count]{}; - // vplate_result *vp_result = new vplate_result[vehicle_batch_count]{}; - // vr_result *vrresult = new vr_result[vehicle_batch_count]{}; - // if (vehicle_analysis_config == SY_CONFIG_OPEN) - // { - // { - // //TimeCounting t("VehicleColor_Process"); - // VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult); - // } - - // { - // //TimeCounting t("VehiclePlateDetectRecog_Process"); - // VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result); - // } - - // { - // //TimeCounting t("VehicleRecog_Process"); - // // VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count); - // } - // } - - // int8 ** fea = nullptr; - // if (vcf_recg_config == SY_CONFIG_OPEN) - // { + if (!vehicle_keys.empty()) + { + const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE; + const int vehicle_batch_size = vehicle_keys.size(); + int vehicle_batch_count = obj_batch_count; + for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i) + { + if (i == (vehicle_batch_size / obj_batch_count)) + vehicle_batch_count = vehicle_batch_size % obj_batch_count; + + if (vehicle_batch_count == 0) continue; + + sy_img* finish_vehicle_img = new sy_img[vehicle_batch_count]{}; + + for (int j = 0; j < vehicle_batch_count; j++) + { + OBJ_KEY cur_obj_key = vehicle_keys[j]; + finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); + } + + vc_result *vcresult = new vc_result[vehicle_batch_count]{}; + vplate_result *vp_result = new vplate_result[vehicle_batch_count]{}; + vr_result *vrresult = new vr_result[vehicle_batch_count]{}; + if (vehicle_analysis_config == SY_CONFIG_OPEN) + { + VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult); + VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result); + VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count); + } + + int8 ** fea = nullptr; + if (vcf_recg_config == SY_CONFIG_OPEN) + { - // fea = new int8*[vehicle_batch_count] {}; - // for (int ii = 0; ii < vehicle_batch_count; ++ii) - // { - // fea[ii] = new int8[FEATURESIZE]{}; - // } + fea = new int8*[vehicle_batch_count] {}; + for (int ii = 0; ii < vehicle_batch_count; ++ii) + { + fea[ii] = new int8[FEATURESIZE]{}; + } - // //TimeCounting t("vf_features_process"); - // vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea); - // } + //TimeCounting t("vf_features_process"); + vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea); + } - // int resIndex = 0; - // int feaIndex = 0; - // for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++) - // { - // auto iter = snapShotInfo.find(vehicle_keys[vc_idx]); - - // if (iter == snapShotInfo.end()) - // resIndex++; //cout << iter_key.videoID << " " <::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); ) - // { - // if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID) - // iter = count_vehicle_v.erase(iter); - // else - // { - // ++iter; - // } - // } - - // if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里 - // { - // save_snapshot(vehicle_keys[vc_idx]); - // } - - // if (iter->second.snapShotLittle.frame) - // { - // cudaFree(iter->second.snapShotLittle.frame); - // iter->second.snapShotLittle.frame = NULL; - // } - // snapShotInfo.erase(iter);//modified by dyq - // } - // } - - // vehicle_result_v.clear(); - // vector().swap(vehicle_result_v); - - - // if (fea != nullptr) - // { - // for (int ii = 0; ii < vehicle_batch_count; ++ii) - // { - // delete[] fea[ii]; - // } - // delete[] fea; - // fea = nullptr; - // } - // if (vcresult != NULL) - // { - // delete[] vcresult; - // vcresult = NULL; - // } - - // if (vp_result != NULL) - // { - // delete[] vp_result; - // vp_result = NULL; - // } - - // if (vrresult != NULL) - // { - // delete[] vrresult; - // vrresult = NULL; - // } - - // if (finish_vehicle_img != NULL) - // { - // delete[] finish_vehicle_img; - // finish_vehicle_img = NULL; - // } - - // vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count); - // } - - // v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS; - // } + int resIndex = 0; + int feaIndex = 0; + for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++) + { + auto iter = snapShotInfo.find(vehicle_keys[vc_idx]); + + if (iter == snapShotInfo.end()) + resIndex++; //cout << iter_key.videoID << " " <::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); ) + { + if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID) + iter = count_vehicle_v.erase(iter); + else + { + ++iter; + } + } + + if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里 + { + save_snapshot(vehicle_keys[vc_idx]); + } + + if (iter->second.snapShotLittle.frame) + { + cudaFree(iter->second.snapShotLittle.frame); + iter->second.snapShotLittle.frame = NULL; + } + snapShotInfo.erase(iter);//modified by dyq + } + } + + vehicle_result_v.clear(); + vector().swap(vehicle_result_v); + + + if (fea != nullptr) + { + for (int ii = 0; ii < vehicle_batch_count; ++ii) + { + delete[] fea[ii]; + } + delete[] fea; + fea = nullptr; + } + if (vcresult != NULL) + { + delete[] vcresult; + vcresult = NULL; + } + + if (vp_result != NULL) + { + delete[] vp_result; + vp_result = NULL; + } + + if (vrresult != NULL) + { + delete[] vrresult; + vrresult = NULL; + } + + if (finish_vehicle_img != NULL) + { + delete[] finish_vehicle_img; + finish_vehicle_img = NULL; + } + + vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count); + } + + v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS; + } if (!vehicle_else.empty()) { -- libgit2 0.21.4