Commit b944fdeb452972c30d853dfe5e02110427c343b9

Authored by Hu Chunming
1 parent dce94814

同步代码

vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
@@ -182,7 +182,7 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN @@ -182,7 +182,7 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN
182 182
183 m_face_det_config = vptParam.face_det_config; 183 m_face_det_config = vptParam.face_det_config;
184 184
185 - m_snaphot_helper.snapshot_helper_init(vptParam.gpuid, gpu_total_memory, vptParam.vrdbpath, vptParam.auth_license, vptParam.wait_framecount, cmdConfig); 185 + m_snaphot_helper.snapshot_helper_init(vptParam.gpuid, gpu_total_memory, vptParam.vrdbpath, AUTH_LICENSE, vptParam.wait_framecount, cmdConfig);
186 186
187 m_bProcessExit = false; 187 m_bProcessExit = false;
188 ProcessThread = std::thread(algorthim_process_thread, this); 188 ProcessThread = std::thread(algorthim_process_thread, this);
@@ -202,7 +202,12 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN @@ -202,7 +202,12 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN
202 202
203 void CMutliSourceVideoProcess::FinishTask(const int taskID) 203 void CMutliSourceVideoProcess::FinishTask(const int taskID)
204 { 204 {
205 - if (m_taskMap.find(taskID) == m_taskMap.end()){ 205 + task_over(taskID, true);
  206 +}
  207 +
  208 +void CMutliSourceVideoProcess::task_over(const int taskID, bool bOver) {
  209 +
  210 + if (m_taskMap.find(taskID) == m_taskMap.end()) {
206 return; 211 return;
207 } 212 }
208 213
@@ -235,18 +240,20 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) @@ -235,18 +240,20 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID)
235 240
236 m_snaphot_helper.waitSaveAnalysisInfo(task.taskID); 241 m_snaphot_helper.waitSaveAnalysisInfo(task.taskID);
237 242
238 - task.taskTcuvid->DxCloseDecoder();  
239 - delete task.taskTcuvid;  
240 - task.taskTcuvid = NULL; 243 + if (task.taskTcuvid)
  244 + {
  245 + task.taskTcuvid->DxCloseDecoder();
  246 + delete task.taskTcuvid;
  247 + task.taskTcuvid = NULL;
  248 + }
241 249
242 //回调通知上层任务结束 250 //回调通知上层任务结束
243 - if (task.taskFinishCallbackFunc != nullptr) { 251 + if (bOver && task.taskFinishCallbackFunc != nullptr) {
244 std::lock_guard<std::mutex> l(m_snaphot_helper.callback_tx); 252 std::lock_guard<std::mutex> l(m_snaphot_helper.callback_tx);
245 task.taskFinishCallbackFunc(task.taskID); 253 task.taskFinishCallbackFunc(task.taskID);
246 } 254 }
247 255
248 LOG_INFO("task {} is finished. timeusing: {}", taskID, get_cur_time_ms() - task.timestamp); 256 LOG_INFO("task {} is finished. timeusing: {}", taskID, get_cur_time_ms() - task.timestamp);
249 -  
250 } 257 }
251 258
252 void CMutliSourceVideoProcess::PauseTask(const int taskID) 259 void CMutliSourceVideoProcess::PauseTask(const int taskID)
@@ -327,8 +334,6 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh @@ -327,8 +334,6 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh
327 return false; 334 return false;
328 } 335 }
329 336
330 - cout << "AddTask: " << new_task.taskFileSource << endl;  
331 -  
332 DxConfig cfg = { 0 }; 337 DxConfig cfg = { 0 };
333 cfg.devId = mgpuid; 338 cfg.devId = mgpuid;
334 cfg.forceTcp = false; 339 cfg.forceTcp = false;
@@ -471,8 +476,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) @@ -471,8 +476,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam)
471 memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); 476 memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE);
472 TaskOperatorQ.push_back(newOper); 477 TaskOperatorQ.push_back(newOper);
473 taskCondVar.wait_for(l, std::chrono::seconds(20)); 478 taskCondVar.wait_for(l, std::chrono::seconds(20));
474 -  
475 - cout << "AddOperator: " << newOper.videoFileName << endl;  
476 } 479 }
477 480
478 int addRes = -1; 481 int addRes = -1;
@@ -494,7 +497,7 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) @@ -494,7 +497,7 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam)
494 { 497 {
495 TaskOperatorQ.pop_back(); 498 TaskOperatorQ.pop_back();
496 } 499 }
497 - cout << "Failed Add New Task! Algorithm Process Error! " << endl; 500 + LOG_ERROR("Failed Add New Task! Algorithm Process Error: {}", tparam.video_filename);
498 } 501 }
499 502
500 return addRes; 503 return addRes;
@@ -550,8 +553,6 @@ void CMutliSourceVideoProcess::OperatorTask() @@ -550,8 +553,6 @@ void CMutliSourceVideoProcess::OperatorTask()
550 tparam.log = newOperator.taskSfxLogFunc; 553 tparam.log = newOperator.taskSfxLogFunc;
551 tparam.userPtr = newOperator.logUserPtr; 554 tparam.userPtr = newOperator.logUserPtr;
552 555
553 - cout << "before AddTask: " << tparam.video_filename << endl;  
554 -  
555 AddTask(tparam); 556 AddTask(tparam);
556 } 557 }
557 break; 558 break;
@@ -568,7 +569,6 @@ void CMutliSourceVideoProcess::OperatorTask() @@ -568,7 +569,6 @@ void CMutliSourceVideoProcess::OperatorTask()
568 if (iter != m_taskMap.end()) { 569 if (iter != m_taskMap.end()) {
569 m_taskMap.erase(iter); 570 m_taskMap.erase(iter);
570 } 571 }
571 -  
572 } 572 }
573 break; 573 break;
574 default: 574 default:
@@ -639,7 +639,7 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -639,7 +639,7 @@ void CMutliSourceVideoProcess::algorthim_process()
639 while (!m_bProcessExit) { 639 while (!m_bProcessExit) {
640 640
641 if (licence_status <= -3) { 641 if (licence_status <= -3) {
642 - printf("authority failed!\n"); 642 + LOG_ERROR("authority failed!\n");
643 break; 643 break;
644 } 644 }
645 645
@@ -653,7 +653,14 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -653,7 +653,14 @@ void CMutliSourceVideoProcess::algorthim_process()
653 for (auto it=m_taskMap.begin(); it!=m_taskMap.end(); ) { 653 for (auto it=m_taskMap.begin(); it!=m_taskMap.end(); ) {
654 Task& task = it->second; 654 Task& task = it->second;
655 if (!task.taskTcuvid->DxDecoderIsRun() && task.taskTcuvid->DxFrameIsEmpty()) { 655 if (!task.taskTcuvid->DxDecoderIsRun() && task.taskTcuvid->DxFrameIsEmpty()) {
656 - FinishTask(task.taskID); 656 + //if (task.taskTcuvid->IsHandleClose())
  657 + //{
  658 + // task_over(task.taskID, false);
  659 + //}
  660 + //else
  661 + {
  662 + task_over(task.taskID, true);
  663 + }
657 it = m_taskMap.erase(it); 664 it = m_taskMap.erase(it);
658 } else { 665 } else {
659 ++it; 666 ++it;
@@ -678,6 +685,8 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -678,6 +685,8 @@ void CMutliSourceVideoProcess::algorthim_process()
678 if(task.taskTotalFrameCount <= 1) { 685 if(task.taskTotalFrameCount <= 1) {
679 task.taskTotalFrameCount = task.taskTcuvid->DxGetFrameCount(); 686 task.taskTotalFrameCount = task.taskTcuvid->DxGetFrameCount();
680 } 687 }
  688 +
  689 + task.taskFrameCount = dxFrame.timestamp;
681 } 690 }
682 691
683 if (vec_dxGpuFrame.size() <= 0) { 692 if (vec_dxGpuFrame.size() <= 0) {
@@ -710,9 +719,7 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -710,9 +719,7 @@ void CMutliSourceVideoProcess::algorthim_process()
710 719
711 vector<VPTProcessResult> vec_vptResult = m_vptProcess.process(vec_data); 720 vector<VPTProcessResult> vec_vptResult = m_vptProcess.process(vec_data);
712 721
713 -#ifdef LOG_INFO2  
714 - std::cout << "VPT_Process_GPU time_using: " << get_cur_time_ms() - start_time_vpt << std::endl;  
715 -#endif 722 + //LOG_DEBUG("VPT_Process_GPU time_using: {}", get_cur_time_ms() - start_time_vpt);
716 723
717 long long result_analysis_time = get_cur_time_ms(); 724 long long result_analysis_time = get_cur_time_ms();
718 725
@@ -722,8 +729,6 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -722,8 +729,6 @@ void CMutliSourceVideoProcess::algorthim_process()
722 Task& task = m_taskMap[task_id]; 729 Task& task = m_taskMap[task_id];
723 730
724 DxGPUFrame& task_algorithm_data = vec_dxGpuFrame[i]; 731 DxGPUFrame& task_algorithm_data = vec_dxGpuFrame[i];
725 -  
726 - task.taskFrameCount = task_algorithm_data.timestamp;  
727 732
728 //实时查看模块,若存在实时查看,把当前视频画面cp回内存 733 //实时查看模块,若存在实时查看,把当前视频画面cp回内存
729 bool view = false; 734 bool view = false;
@@ -841,17 +846,21 @@ void CMutliSourceVideoProcess::algorthim_process() @@ -841,17 +846,21 @@ void CMutliSourceVideoProcess::algorthim_process()
841 { 846 {
842 //需要做人脸检测 847 //需要做人脸检测
843 int human_count = human_idx.size(); 848 int human_count = human_idx.size();
844 - sy_img human_img[human_count];  
845 - sy_point ori_points[human_count]; 849 + vector<sy_img> vec_human_img;
  850 + vector< sy_point> vec_points;
846 for (int idx = 0; idx < human_count; idx++) 851 for (int idx = 0; idx < human_count; idx++)
847 { 852 {
848 int ii = human_idx[idx]; 853 int ii = human_idx[idx];
849 - human_img[idx].set_data(snapshot_dst_width[ii], snapshot_dst_height[ii], 3, snapshot_image_data[ii]);  
850 - ori_points[idx].x_ = (snapshot_right[ii] - snapshot_left[ii]);  
851 - ori_points[idx].y_ = (snapshot_bottom[ii] - snapshot_top[ii]); 854 + sy_img human_img;
  855 + human_img.set_data(snapshot_dst_width[ii], snapshot_dst_height[ii], 3, snapshot_image_data[ii]);
  856 + sy_point ori_point;
  857 + ori_point.x_ = (snapshot_right[ii] - snapshot_left[ii]);
  858 + ori_point.y_ = (snapshot_bottom[ii] - snapshot_top[ii]);
  859 + vec_points.push_back(ori_point);
  860 + vec_human_img.push_back(human_img);
852 } 861 }
853 862
854 - m_snaphot_helper.cacheFaceSnapshotInfo(human_img, human_count, ori_points, human_idx, human_obj_keys, snapshot_left, snapshot_top, task_algorithm_data); 863 + 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);
855 } 864 }
856 } 865 }
857 866
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 #include "time.h" 10 #include "time.h"
11 #include "opencv2/opencv.hpp" 11 #include "opencv2/opencv.hpp"
12 #include "opencv2/highgui/highgui.hpp" 12 #include "opencv2/highgui/highgui.hpp"
13 -#include "VPTProcess.h"  
14 #include <queue> 13 #include <queue>
15 #include <set> 14 #include <set>
16 #include <map> 15 #include <map>
@@ -18,7 +17,8 @@ @@ -18,7 +17,8 @@
18 #include "../cuda_src/ImageSaveGPU.h" 17 #include "../cuda_src/ImageSaveGPU.h"
19 18
20 #include "mvpt_process_assist.h" 19 #include "mvpt_process_assist.h"
21 -#include "snapshot_helper.h" 20 +#include "./snapshot_analysis/VPTProcess.h"
  21 +#include "./snapshot_analysis/snapshot_helper.h"
22 22
23 #include <atomic> 23 #include <atomic>
24 24
@@ -132,6 +132,9 @@ public: @@ -132,6 +132,9 @@ public:
132 132
133 void algorthim_process(); 133 void algorthim_process();
134 134
  135 +private:
  136 + void task_over(const int taskID, bool bOver);
  137 +
135 public: 138 public:
136 int section_batch_size; 139 int section_batch_size;
137 int licence_status; 140 int licence_status;
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp renamed to vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.cpp
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.h renamed to vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VPTProcess.h