From 28eadcc464db1351ae68e3eeeb055ffd4e6f55ee Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Fri, 7 Jun 2024 16:27:52 +0800 Subject: [PATCH] 修复进度值错误问题 --- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp | 3 ++- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp | 4 ++++ vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h | 4 +++- vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 2 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 671c82c..3bca52d 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 @@ -356,7 +356,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh new_task.taskState = PLAY; new_task.taskFrameCount = 0; - new_task.taskLastFrameCount = 0; + new_task.taskLastFrameCount = 1; new_task.taskObjCallbackFunc = nullptr; if (objCallbackFunc != nullptr) @@ -684,6 +684,7 @@ void CMutliSourceVideoProcess::algorthim_process() } if(task.taskTotalFrameCount <= 1) { task.taskTotalFrameCount = task.taskTcuvid->DxGetFrameCount(); + m_snaphot_helper.update_taotal_frame_count(task.taskID, task.taskTotalFrameCount); } task.taskFrameCount = dxFrame.timestamp; 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 5e85a0e..30756b9 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 @@ -196,6 +196,10 @@ void snapshot_helper::add_task_info(int new_task_id, TASK_INFO new_task_info) m_task_info[new_task_id] = new_task_info; } +void snapshot_helper::update_taotal_frame_count(int task_id, int total_frame_count) { + m_task_info[task_id].task_total_framecount = total_frame_count; +} + void snapshot_helper::delete_task_info(int new_task_id, TASK_INFO new_task_info) { m_task_info[new_task_id].image_folder = nullptr; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h index fa4f874..48fd245 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h @@ -95,7 +95,7 @@ struct TASK_INFO { char* snapshot_folder_face; bool _on_image_display; int jpeg_quality_; //debug by zsh - int task_total_framecount; + int task_total_framecount{1}; SNAPSHOT_CALLBACK obj_callback; //TASK_INFO() :image_folder(NULL), snapshot_folder(NULL), snapshot_folder_face(NULL),_on_image_display(true), obj_callback(nullptr) {} @@ -172,6 +172,8 @@ public: void snapshot_helper_release(); void add_task_info(int new_task_id, TASK_INFO new_task_info); void delete_task_info(int new_task_id, TASK_INFO new_task_info); + + void update_taotal_frame_count(int new_task_id, int total_frame_count); int SaveResultInFile(OBJ_KEY deleteObj); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp index 631e4c0..2e43226 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp @@ -672,6 +672,8 @@ void log_all(void * userPtr, int log_level, const char* log, unsigned int logLen void *handle; static int total_index = 0; +static bool bExit = false; + void create_task(const char * videoFileName, int total_index) { //指定检测目标视频抽帧图片(保存时显存占用很大) char resultFolder[256]; @@ -712,6 +714,21 @@ void create_task(const char * videoFileName, int total_index) { cur_task_status_.insert(make_pair(newTaskID, FALSE)); } + +static void print_progress() { + while (!bExit) + { + for (auto it = cur_task_status_.begin(); it != cur_task_status_.end(); it++) + { + double progress = 0; + get_task_progress(handle, it->first, progress); + cout << "task " << it->first << " progress: " << progress << endl; + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } +} + + int main(int argc, char* argv[]) { if (argc<4) @@ -767,6 +784,8 @@ int main(int argc, char* argv[]) int time_count = 0; + thread print_progress_trd(print_progress); + printf("begin add task\n"); do { if(get_running_task_number(handle) > 0){ -- libgit2 0.21.4