diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp index 0f022cc..b368aeb 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp @@ -7,14 +7,14 @@ void decoded_cbk(const void * userPtr, GPUFrame * gpuFrame){ DxDecoderWrap* _this = (DxDecoderWrap*)userPtr; if(nullptr != _this){ - _this->post_decode_thread(gpuFrame); + _this->post_decode_callback(gpuFrame); } } void decode_finished_cbk(const void * userPtr){ DxDecoderWrap* _this = (DxDecoderWrap*)userPtr; if(nullptr != _this){ - _this->decode_finished_thread(); + _this->decode_finished_callback(); } } @@ -145,7 +145,7 @@ int DxDecoderWrap::ResumeDecoder() bool DxDecoderWrap::DxDecoderIsRun() const { if(m_pDec) { - return m_pDec->isRunning(); + return !m_pDec->isFinished(); } return false; @@ -175,7 +175,7 @@ int DxDecoderWrap::DxLockFrame(DxGPUFrame& frame) return 0; } -void DxDecoderWrap::post_decode_thread(GPUFrame * decodedFrame) { +void DxDecoderWrap::post_decode_callback(GPUFrame * decodedFrame) { while(!m_bClose) { m_queue_frames_mutex.lock(); if(m_queue_frames.size() < 3) { @@ -205,9 +205,6 @@ void DxDecoderWrap::post_decode_thread(GPUFrame * decodedFrame) { frame.frame = pHwData; frame.timestamp = decodedFrame->ts; - delete decodedFrame; - decodedFrame = nullptr; - m_queue_frames.push(frame); m_queue_frames_mutex.unlock(); break; @@ -218,6 +215,6 @@ void DxDecoderWrap::post_decode_thread(GPUFrame * decodedFrame) { } } -void DxDecoderWrap::decode_finished_thread() { +void DxDecoderWrap::decode_finished_callback() { m_bClose = true; } \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h index b381508..c12c745 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h @@ -66,8 +66,8 @@ public: public: string GetName() {return m_name;}; - void post_decode_thread(GPUFrame * gpuFrame); - void decode_finished_thread(); + void post_decode_callback(GPUFrame * gpuFrame); + void decode_finished_callback(); private: bool m_bClose; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp index a996777..5bb1865 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp @@ -8,6 +8,8 @@ #include "logger.hpp" +#define MAX_QUEUE_SIZE 3 + using namespace std; // 参考博客: https://blog.csdn.net/qq_40116098/article/details/120704340 @@ -214,7 +216,7 @@ void FFNvDecoder::decode_thread() } m_queue_mutex.lock(); - if(mFrameQueue.size() >= 10){ + if(mFrameQueue.size() >= MAX_QUEUE_SIZE){ m_queue_mutex.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; @@ -270,7 +272,7 @@ void FFNvDecoder::decode_thread() if(gpuFrame != nullptr){ m_queue_mutex.lock(); - if(mFrameQueue.size() <= 10){ + if(mFrameQueue.size() <= MAX_QUEUE_SIZE){ GPUFrame* frame = new GPUFrame(); frame->ts = index; frame->gpuFrame = gpuFrame; @@ -301,6 +303,7 @@ void FFNvDecoder::decode_thread() // 清空队列 while(mFrameQueue.size() > 0){ GPUFrame * frame = mFrameQueue.front(); + av_frame_free(&frame->gpuFrame); delete frame; frame = nullptr; mFrameQueue.pop(); @@ -316,10 +319,6 @@ void FFNvDecoder::decode_thread() void FFNvDecoder::decode_finished(){ if (avctx) { - // if (avctx->hw_device_ctx) { - // av_buffer_unref(&avctx->hw_device_ctx); - // avctx->hw_device_ctx = nullptr; - // } avcodec_free_context(&avctx); avctx = nullptr; } @@ -358,7 +357,9 @@ void FFNvDecoder::post_decode_thread(){ frame_count++; } - // av_frame_free(&gpuFrame); + av_frame_free(&frame->gpuFrame); + delete frame; + frame = nullptr; index++; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp index f14fba6..01a5fe1 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp @@ -38,7 +38,7 @@ void ImageSaveCache::show() } //#include //std::ofstream os1("./mp_frameSize.txt", std::ofstream::out | std::ofstream::trunc); -void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_id, const DxGPUFrame & frame) +void ImageSaveCache::add_frame(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_id, const DxGPUFrame & frame) { //std::lock_guard l(tx); //os1 << std::unitbuf; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.h index 0e89424..dca2d8d 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.h @@ -10,7 +10,7 @@ class ImageSaveCache { public: - void insert(const OBJ_KEY & snaphot_id, const FRAME_KEY & frame_id, const DxGPUFrame & frame); + void add_frame(const OBJ_KEY & snaphot_id, const FRAME_KEY & frame_id, const DxGPUFrame & frame); void release(const OBJ_KEY & snaphot_id); DxGPUFrame* get_frame(const OBJ_KEY & snaphot_id); void show(); 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 46177e6..d11c2dd 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 @@ -276,6 +276,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) if (viewTaskID == taskID) viewTaskID = -1; + LOG_INFO("task {} is finished. timeusing: {}", taskID, get_cur_time_ms() - tasks[i].timestamp); break; } @@ -452,6 +453,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh CreateResultFolder(new_task.folderNameFace, ""); } + new_task.timestamp = get_cur_time_ms(); TASK_INFO new_task_info = {}; new_task_info.image_folder = new_task.folderName; @@ -471,7 +473,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh AddTaskSucFlag = 1; - LOG_INFO("add task: {}", new_task.taskID); + LOG_INFO("add task: {} succeed. timestamp: {} ", new_task.taskID, get_cur_time_ms()); return true; } @@ -690,7 +692,6 @@ void CMutliSourceVideoProcess::algorthim_process() printf("begin finish last error: %s\n", cudaGetErrorString(cudaStatus)); } - cout << "***************** Task " << i << " is Finished *****************" << endl; tasks[i].taskState = FINISH; FinishTask(tasks[i].taskID); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/common.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/common.h index 5474617..473d1d2 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/common.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/common.h @@ -91,6 +91,8 @@ struct Task{ char* folderName; char* folderNameFace; sy_rect task_min_boxsize[DETECTTYPE]; + + unsigned long long timestamp; }; typedef struct VPT_ObjInfo //����ṹ�� diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp index 818e08b..27fc0e8 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp @@ -73,7 +73,7 @@ int HumanCarParsing::init(int gpuid, char* auth_license) int HumanCarParsing::process(sy_img * batch_img, int batch_size, hcp_analysis_result *result) { - LOG_DEBUG("batch_size: {}", batch_size); + // LOG_DEBUG("batch_size: {}", batch_size); hcp_batch(handle, batch_img, batch_size, result); for (int b = 0; b < batch_size; b++) 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 4f81201..331421a 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 @@ -456,6 +456,8 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //是 if (!hp_keys.empty()) { + LOG_DEBUG("hp_keys size: {}", hp_keys.size()); + const int obj_batch_count = OBJ_BATCH_COUNT / OBJ_SCALE; const int hp_batch_size = hp_keys.size(); int hp_batch_count = obj_batch_count; @@ -637,6 +639,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //是 if (!vehicle_keys.empty()) { + LOG_DEBUG("vehicle_keys size: {}", vehicle_keys.size()); int det_batch_size = 10; while (!vehicle_keys.empty()) { @@ -756,6 +759,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //是 if (!vehicle_else.empty()) { + LOG_DEBUG("vehicle_else size: {}", vehicle_else.size()); const int else_size = vehicle_else.size(); for (int k = 0; k < else_size; k++) @@ -1983,6 +1987,7 @@ int snapshot_helper::SaveResultInFile(OBJ_KEY deleteObj) const OBJ_KEY & obj_key = it->first; const OBJ_VALUE & obj_value = it->second; + // LOG_DEBUG("({}, {})", obj_key.videoID, obj_key.objID); if (0 == obj_value.index.index && obj_value.snapShotLittle.width == HP_WIDTH && obj_value.snapShotLittle.height == HP_HEIGHT) { if (face_detect_cf == SY_CONFIG_OPEN) @@ -2004,7 +2009,6 @@ int snapshot_helper::SaveResultInFile(OBJ_KEY deleteObj) { if (hcp_analysis_cf == SY_CONFIG_OPEN || hcf_recg_cf == SY_CONFIG_OPEN) { - LOG_DEBUG("({}, {})", obj_key.videoID, obj_key.objID); save_snapshot(obj_key); hcp_analysis(obj_key); } @@ -2090,7 +2094,7 @@ CropInfo snapshot_helper::cacheSnapShotInfo(OBJ_KEY newObj, VPT_ObjInfo obj, Tas if (task.folderName != NULL){ FRAME_KEY frame_id = { newObj.videoID, task.taskFrameCount }; - ImgSaveCache.insert(newObj, frame_id, task.task_algorithm_data); + ImgSaveCache.add_frame(newObj, frame_id, task.task_algorithm_data); snapShotInfo[newObj].snapShot.height = frameHeight; snapShotInfo[newObj].snapShot.width = frameWidth; @@ -2208,7 +2212,7 @@ CropInfo snapshot_helper::cacheSnapShotInfo(OBJ_KEY newObj, VPT_ObjInfo obj, Tas if (task.folderName != NULL) { FRAME_KEY frame_id = { newObj.videoID, task.taskFrameCount }; - ImgSaveCache.insert(newObj, frame_id, task.task_algorithm_data); + ImgSaveCache.add_frame(newObj, frame_id, task.task_algorithm_data); } //--------------------- 保存快照抠图 -----------------------------// @@ -2464,9 +2468,10 @@ void snapshot_helper::clearSnapshotInfo() { } void snapshot_helper::erase_snapshot_info(OBJ_KEY& objKey){ - if (5 == objKey.videoID) { - LOG_DEBUG("task:{} objId: {}", objKey.videoID, objKey.objID); - } + // if (5 == objKey.videoID) + // { + // LOG_DEBUG("task:{} objId: {}", objKey.videoID, objKey.objID); + // } snapShotInfo.erase(objKey); } \ No newline at end of file