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 f00b4b5..d35fab9 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 @@ -182,7 +182,7 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN m_face_det_config = vptParam.face_det_config; - m_snaphot_helper.snapshot_helper_init(vptParam.gpuid, gpu_total_memory, vptParam.vrdbpath, vptParam.auth_license, vptParam.wait_framecount, cmdConfig); + m_snaphot_helper.snapshot_helper_init(vptParam.gpuid, gpu_total_memory, vptParam.vrdbpath, AUTH_LICENSE, vptParam.wait_framecount, cmdConfig); m_bProcessExit = false; ProcessThread = std::thread(algorthim_process_thread, this); @@ -202,7 +202,12 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN void CMutliSourceVideoProcess::FinishTask(const int taskID) { - if (m_taskMap.find(taskID) == m_taskMap.end()){ + task_over(taskID, true); +} + +void CMutliSourceVideoProcess::task_over(const int taskID, bool bOver) { + + if (m_taskMap.find(taskID) == m_taskMap.end()) { return; } @@ -235,18 +240,20 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) m_snaphot_helper.waitSaveAnalysisInfo(task.taskID); - task.taskTcuvid->DxCloseDecoder(); - delete task.taskTcuvid; - task.taskTcuvid = NULL; + if (task.taskTcuvid) + { + task.taskTcuvid->DxCloseDecoder(); + delete task.taskTcuvid; + task.taskTcuvid = NULL; + } //回调通知上层任务结束 - if (task.taskFinishCallbackFunc != nullptr) { + if (bOver && task.taskFinishCallbackFunc != nullptr) { std::lock_guard l(m_snaphot_helper.callback_tx); task.taskFinishCallbackFunc(task.taskID); } LOG_INFO("task {} is finished. timeusing: {}", taskID, get_cur_time_ms() - task.timestamp); - } void CMutliSourceVideoProcess::PauseTask(const int taskID) @@ -327,8 +334,6 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh return false; } - cout << "AddTask: " << new_task.taskFileSource << endl; - DxConfig cfg = { 0 }; cfg.devId = mgpuid; cfg.forceTcp = false; @@ -471,8 +476,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); TaskOperatorQ.push_back(newOper); taskCondVar.wait_for(l, std::chrono::seconds(20)); - - cout << "AddOperator: " << newOper.videoFileName << endl; } int addRes = -1; @@ -494,7 +497,7 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) { TaskOperatorQ.pop_back(); } - cout << "Failed Add New Task! Algorithm Process Error! " << endl; + LOG_ERROR("Failed Add New Task! Algorithm Process Error: {}", tparam.video_filename); } return addRes; @@ -550,8 +553,6 @@ void CMutliSourceVideoProcess::OperatorTask() tparam.log = newOperator.taskSfxLogFunc; tparam.userPtr = newOperator.logUserPtr; - cout << "before AddTask: " << tparam.video_filename << endl; - AddTask(tparam); } break; @@ -568,7 +569,6 @@ void CMutliSourceVideoProcess::OperatorTask() if (iter != m_taskMap.end()) { m_taskMap.erase(iter); } - } break; default: @@ -639,7 +639,7 @@ void CMutliSourceVideoProcess::algorthim_process() while (!m_bProcessExit) { if (licence_status <= -3) { - printf("authority failed!\n"); + LOG_ERROR("authority failed!\n"); break; } @@ -653,7 +653,14 @@ void CMutliSourceVideoProcess::algorthim_process() for (auto it=m_taskMap.begin(); it!=m_taskMap.end(); ) { Task& task = it->second; if (!task.taskTcuvid->DxDecoderIsRun() && task.taskTcuvid->DxFrameIsEmpty()) { - FinishTask(task.taskID); + //if (task.taskTcuvid->IsHandleClose()) + //{ + // task_over(task.taskID, false); + //} + //else + { + task_over(task.taskID, true); + } it = m_taskMap.erase(it); } else { ++it; @@ -678,6 +685,8 @@ void CMutliSourceVideoProcess::algorthim_process() if(task.taskTotalFrameCount <= 1) { task.taskTotalFrameCount = task.taskTcuvid->DxGetFrameCount(); } + + task.taskFrameCount = dxFrame.timestamp; } if (vec_dxGpuFrame.size() <= 0) { @@ -710,9 +719,7 @@ void CMutliSourceVideoProcess::algorthim_process() vector vec_vptResult = m_vptProcess.process(vec_data); -#ifdef LOG_INFO2 - std::cout << "VPT_Process_GPU time_using: " << get_cur_time_ms() - start_time_vpt << std::endl; -#endif + //LOG_DEBUG("VPT_Process_GPU time_using: {}", get_cur_time_ms() - start_time_vpt); long long result_analysis_time = get_cur_time_ms(); @@ -722,8 +729,6 @@ void CMutliSourceVideoProcess::algorthim_process() Task& task = m_taskMap[task_id]; DxGPUFrame& task_algorithm_data = vec_dxGpuFrame[i]; - - task.taskFrameCount = task_algorithm_data.timestamp; //实时查看模块,若存在实时查看,把当前视频画面cp回内存 bool view = false; @@ -841,17 +846,21 @@ void CMutliSourceVideoProcess::algorthim_process() { //需要做人脸检测 int human_count = human_idx.size(); - sy_img human_img[human_count]; - sy_point ori_points[human_count]; + vector vec_human_img; + vector< sy_point> vec_points; for (int idx = 0; idx < human_count; idx++) { int ii = human_idx[idx]; - human_img[idx].set_data(snapshot_dst_width[ii], snapshot_dst_height[ii], 3, snapshot_image_data[ii]); - ori_points[idx].x_ = (snapshot_right[ii] - snapshot_left[ii]); - ori_points[idx].y_ = (snapshot_bottom[ii] - snapshot_top[ii]); + sy_img human_img; + human_img.set_data(snapshot_dst_width[ii], snapshot_dst_height[ii], 3, snapshot_image_data[ii]); + sy_point ori_point; + ori_point.x_ = (snapshot_right[ii] - snapshot_left[ii]); + ori_point.y_ = (snapshot_bottom[ii] - snapshot_top[ii]); + vec_points.push_back(ori_point); + vec_human_img.push_back(human_img); } - m_snaphot_helper.cacheFaceSnapshotInfo(human_img, human_count, ori_points, human_idx, human_obj_keys, snapshot_left, snapshot_top, task_algorithm_data); + m_snaphot_helper.cacheFaceSnapshotInfo(vec_human_img.data(), human_count, vec_points.data(), human_idx, human_obj_keys, snapshot_left, snapshot_top, task_algorithm_data); } } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h index 6f2b4da..5856955 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h @@ -10,7 +10,6 @@ #include "time.h" #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" -#include "VPTProcess.h" #include #include #include @@ -18,7 +17,8 @@ #include "../cuda_src/ImageSaveGPU.h" #include "mvpt_process_assist.h" -#include "snapshot_helper.h" +#include "./snapshot_analysis/VPTProcess.h" +#include "./snapshot_analysis/snapshot_helper.h" #include @@ -132,6 +132,9 @@ public: void algorthim_process(); +private: + void task_over(const int taskID, bool bOver); + public: int section_batch_size; int licence_status; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.cpp index 60bfcd2..60bfcd2 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.cpp diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.h index c757b12..c757b12 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.h