Commit 922efde74e8bb441dbf38fe529248e911762c2c7

Authored by Hu Chunming
1 parent 99b91853

子库全部重新编译

Showing 21 changed files with 339 additions and 561 deletions
.vscode/launch.json
... ... @@ -73,6 +73,24 @@
73 73 "ignoreFailures": true
74 74 }
75 75 ]
  76 + },{
  77 + "name": "vpdr_test",
  78 + "type": "cppdbg",
  79 + "request": "launch",
  80 + "program": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512/vpdr_test",
  81 + "args": ["file:///home/cmhu/data/video/Street.uvf?fastdecode=on","6","0","./db/mvpt.bin"],
  82 + "stopAtEntry": false,
  83 + "cwd": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512",
  84 + "environment": [],
  85 + "externalConsole": false,
  86 + "MIMode": "gdb",
  87 + "setupCommands": [
  88 + {
  89 + "description": "Enable pretty-printing for gdb",
  90 + "text": "-enable-pretty-printing",
  91 + "ignoreFailures": true
  92 + }
  93 + ]
76 94 }
77 95 ]
78 96 }
79 97 \ No newline at end of file
... ...
.vscode/settings.json
... ... @@ -60,7 +60,25 @@
60 60 "utility": "cpp",
61 61 "typeindex": "cpp",
62 62 "typeinfo": "cpp",
63   - "valarray": "cpp"
  63 + "valarray": "cpp",
  64 + "bit": "cpp",
  65 + "codecvt": "cpp",
  66 + "compare": "cpp",
  67 + "concepts": "cpp",
  68 + "map": "cpp",
  69 + "set": "cpp",
  70 + "string": "cpp",
  71 + "algorithm": "cpp",
  72 + "iterator": "cpp",
  73 + "memory": "cpp",
  74 + "memory_resource": "cpp",
  75 + "optional": "cpp",
  76 + "random": "cpp",
  77 + "string_view": "cpp",
  78 + "numbers": "cpp",
  79 + "semaphore": "cpp",
  80 + "stop_token": "cpp",
  81 + "variant": "cpp"
64 82 },
65 83 "git.ignoreLimitWarning": true
66 84 }
67 85 \ No newline at end of file
... ...
vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile
... ... @@ -25,11 +25,10 @@ SPDLOG_ROOT = $(DEPEND_DIR)/spdlog-1.9.2/release
25 25  
26 26 TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so
27 27  
28   -DEFS=-DOS_LINUX -DLOG_INFO2
  28 +# DEFS=-DOS_LINUX -DLOG_INFO2
  29 +DEFS=-DOS_LINUX
29 30  
30   -INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \
31   - -I $(DEPEND_DIR)/include \
32   - -I $(OPENCV_ROOT)/include/opencv4 \
  31 +INCLUDE= -I $(OPENCV_ROOT)/include/opencv4 \
33 32 -I $(OPENCV_ROOT)/include/opencv4/opencv2 \
34 33 -I $(UTOOLS_SSD_ROOT) \
35 34 -I $(SRC_ROOT) \
... ... @@ -41,7 +40,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \
41 40 -I $(HIDE_MODEL_TRT) \
42 41 -I $(AUTHORITY_DIR) \
43 42 -I $(FFMPEG_ROOT)/include \
44   - -I $(SDK_ROOT)/face_detect2/face_detect \
  43 + -I $(SDK_ROOT)/face_detect/face_detect \
  44 + -I $(SDK_ROOT)/human_car_parsing_trt/src/human_car_parsing \
  45 + -I $(SDK_ROOT)/human_parsing_trt/src/human_parsing \
  46 + -I $(SDK_ROOT)/non_vehicle_fea_trt/src/non_vehicle_fea_trt \
  47 + -I $(SDK_ROOT)/vehicle_color_trt/src/vehicle_color \
  48 + -I $(SDK_ROOT)/vehicle_fea_int8/vehicle_fea_int8 \
  49 + -I $(SDK_ROOT)/vehicle_plate_dr/vehicle_plate_dr \
  50 + -I $(SDK_ROOT)/vehicle_rear_recognition/src/vehicle_rear_recognition \
  51 + -I $(SDK_ROOT)/vehicle_recognize \
  52 + -I $(SDK_ROOT)/vpd2/vpd2 \
45 53 -I $(SPDLOG_ROOT)/include \
46 54 -I $(FFNVDECODER_ROOT) \
47 55 -I $(FFNVDECODER_ROOT)/common/inc \
... ... @@ -50,14 +58,13 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \
50 58  
51 59 LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \
52 60 -L/usr/lib/x86_64-linux-gnu -lnvcuvid \
53   - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \
54   - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lface_detect -lvehicle_brand_cls -lvr_vehicle_type_10cls -lvr5905cls -lvehicle_recognize -lvehicle_color -lhuman_parsing -lhuman_car_parsing -lnon_vehicle_fea_trt -lvehicle_rear_recognition -lvf_int8 -lvp2_yolo\
  61 + -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler \
  62 + -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lface_detect -lvehicle_recognize -lvehicle_color -lhuman_parsing -lhuman_car_parsing -lnon_vehicle_fea_trt -lvehicle_rear_recognition -lvehicle_fea_int8 -lvehicle_plate_dr -lvpd2 \
55 63 -L$(UTOOLS_SSD_ROOT) -l:libutools.so \
56 64 -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \
57 65 -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \
58 66 -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\
59 67 -L$(AUTHORITY_DIR) -l:libauthority.a \
60   - -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \
61 68 -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \
62 69  
63 70  
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp
... ... @@ -32,10 +32,6 @@ DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg )
32 32 m_name = cfg->name;
33 33 m_decMode = cfg->decMode;
34 34  
35   - CUdevice cuDevice;
36   - cuDeviceGet(&cuDevice, cfg->devId);
37   - cuCtxCreate(&m_cuda_cxt, 0, cuDevice);
38   -
39 35 return;
40 36 }
41 37  
... ... @@ -107,9 +103,6 @@ int DxDecoderWrap::DxCloseDecoder()
107 103 cudaFree(m_pHwData);
108 104 }
109 105  
110   - cuCtxPopCurrent(nullptr);
111   - cuCtxDestroy(m_cuda_cxt);
112   -
113 106 return 0;
114 107 }
115 108  
... ... @@ -190,20 +183,16 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
190 183 AVFrame* gpuFrame = decodedFrame->gpuFrame;
191 184  
192 185 cudaSetDevice(atoi(m_cfg.gpuid.c_str()));
193   - cuCtxPushCurrent(m_cuda_cxt);
194 186 cudaError_t cudaStatus;
195 187 size_t rgbSize = 3 * gpuFrame->width * gpuFrame->height * sizeof(unsigned char);
196   - if(m_pHwData == nullptr){
197   - cudaStatus = cudaMalloc((void **)&m_pHwData, rgbSize);
198   - if (cudaStatus != cudaSuccess) {
199   - LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str());
200   - cuCtxPopCurrent(&m_cuda_cxt);
201   - return -1;
202   - }
  188 + unsigned char *pHwData = nullptr;
  189 + cudaStatus = cudaMalloc((void **)&pHwData, rgbSize);
  190 + if (cudaStatus != cudaSuccess) {
  191 + LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str());
  192 + return -1;
203 193 }
204 194 cuda_common::setColorSpace( ITU_709, 0 );
205   - cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], m_pHwData, gpuFrame->width, gpuFrame->height);
206   - cuCtxPopCurrent(&m_cuda_cxt);
  195 + cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], pHwData, gpuFrame->width, gpuFrame->height);
207 196 if (cudaStatus != cudaSuccess) {
208 197 LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str());
209 198 return -1;
... ... @@ -211,8 +200,8 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
211 200  
212 201 frame->width = gpuFrame->width;
213 202 frame->height = gpuFrame->height;
214   - frame->size = rgbSize;
215   - frame->frame = m_pHwData;
  203 + frame->size = gpuFrame->width;
  204 + frame->frame = pHwData;
216 205 frame->timestamp = decodedFrame->ts;
217 206  
218 207 delete decodedFrame;
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h
... ... @@ -80,7 +80,6 @@ private:
80 80 std::mutex m_queue_frames_mutex;
81 81  
82 82 unsigned char *m_pHwData {nullptr};
83   - CUcontext m_cuda_cxt;
84 83  
85 84 int m_decMode{0};
86 85 };
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp
... ... @@ -199,6 +199,7 @@ void FFNvDecoder::decode_thread()
199 199 // long start_time = get_cur_time();
200 200  
201 201 unsigned long long index = 0;
  202 + unsigned long long decoded_frame_count = 0;
202 203 while (m_bRunning)
203 204 {
204 205 if (!m_bReal)
... ... @@ -262,6 +263,8 @@ void FFNvDecoder::decode_thread()
262 263 }
263 264 av_packet_unref(pkt);
264 265  
  266 + decoded_frame_count++;
  267 +
265 268 if(gpuFrame != nullptr){
266 269 m_queue_mutex.lock();
267 270 if(mFrameQueue.size() <= 10){
... ... @@ -290,8 +293,6 @@ void FFNvDecoder::decode_thread()
290 293  
291 294 decode_finished_cbk(m_finishedDecArg);
292 295  
293   - decode_finished();
294   -
295 296 // 清空队列
296 297 while(mFrameQueue.size() > 0){
297 298 GPUFrame * frame = mFrameQueue.front();
... ... @@ -300,7 +301,9 @@ void FFNvDecoder::decode_thread()
300 301 mFrameQueue.pop();
301 302 }
302 303  
303   - LOG_INFO("[{}] - decode thread exited.", m_dec_name);
  304 + decode_finished();
  305 +
  306 + LOG_INFO("[{}] - decode thread exited, decoded frame count: {}", m_dec_name, decoded_frame_count);
304 307 }
305 308  
306 309 void FFNvDecoder::decode_finished(){
... ... @@ -325,6 +328,7 @@ void FFNvDecoder::post_decode_thread(){
325 328 }
326 329  
327 330 unsigned long long index = 0;
  331 + int frame_count = 0;
328 332 while (m_bRunning)
329 333 {
330 334 std::this_thread::sleep_for(std::chrono::milliseconds(2)); //给m_snapshot_mutex的喘息时间,避免截图一直截不到。避免线程资源占用。
... ... @@ -338,6 +342,7 @@ void FFNvDecoder::post_decode_thread(){
338 342 // 跳帧
339 343 if (skip_frame == 1 || index % skip_frame == 0){
340 344 post_decoded_cbk(m_postDecArg, frame);
  345 + frame_count++;
341 346 }
342 347  
343 348 // av_frame_free(&gpuFrame);
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
... ... @@ -8,6 +8,7 @@
8 8 #include <fstream>
9 9 #include <algorithm>
10 10 #include <thread>
  11 +#include <chrono>
11 12 #include <future>
12 13  
13 14 #include "../FFNvDecoder/logger.hpp"
... ... @@ -25,7 +26,6 @@
25 26 #define AUTHORIZATION
26 27 //#define DQ_AUTHORIZATION
27 28  
28   -#include<boost/thread.hpp>
29 29  
30 30 #ifdef DQ_AUTHORIZATION
31 31 #include "license_validator.h"
... ... @@ -201,12 +201,12 @@ int CMutliSourceVideoProcess::FinishProcessThread()
201 201 {
202 202 if (thrd_status == 0)
203 203 {
204   - thrd.interrupt();
  204 + m_bExit = true;
205 205 thrd.join();
206 206 thrd_status = -1;
207 207 }
208 208  
209   - ProcessThread.interrupt(); //interrupt thread
  209 + m_bProcessExit = true;
210 210 ProcessThread.join(); //waiting thread finish
211 211  
212 212 VPT_Release(VPT_Handle);
... ... @@ -252,7 +252,8 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN
252 252 char wtime[15];
253 253 memset(wtime, 0, 15);
254 254 char * time = wtime;
255   - if (SUCCESS == (ret = sy_licence(productSN, &time)))
  255 + ret = sy_licence(productSN, &time);
  256 + if (SUCCESS == ret)
256 257 #endif
257 258 #else
258 259 ret = license_check(vptParam.auth_license, productSN);// sy_time_check(2022, 2);
... ... @@ -348,8 +349,9 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN
348 349 if (ret == SUCCESS) //�ɹ�
349 350 {
350 351 licence_status = 0;
351   -#ifdef AUTHORIZATION
352   - thrd = boost::thread(check_thread, this);
  352 +#ifdef AUTHORIZATION
  353 + m_bExit = false;
  354 + thrd = std::thread(check_thread, this);
353 355 #endif
354 356 thrd_status = 0;
355 357 }
... ... @@ -374,8 +376,6 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN
374 376  
375 377 void CMutliSourceVideoProcess::FinishDecode(const int taskID)
376 378 {
377   - boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(400));
378   -
379 379 for (int i = 0; i < tasks.size(); i++)
380 380 {
381 381 if (tasks[i].taskID == taskID && tasks[taskID].taskTcuvid != NULL)
... ... @@ -404,7 +404,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID)
404 404 tasks[i].taskObjCallbackFunc = nullptr;
405 405 tasks[i].taskRealTimeCallbackFunc = nullptr;
406 406  
407   - 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); //�Ƿ�����������ʶ��);
  407 + 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);
408 408  
409 409 if (tasks[i].folderName)
410 410 {
... ... @@ -542,7 +542,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh
542 542 int height = 0;
543 543 new_task.taskTcuvid->DxGetResolution(width, height);
544 544  
545   - LOG_INFO("[{}] - finish add codec. w:{} h:{} total_frame:", cfg.name.c_str(), width, height, total_frame);
  545 + LOG_INFO("[{}] - finish add codec. w:{} h:{} total_frame:{}", cfg.name.c_str(), width, height, total_frame);
546 546  
547 547 new_task.frameImage = cv::Mat::zeros(height, width, CV_8UC3);
548 548 new_task.taskState = PLAY;
... ... @@ -634,7 +634,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh
634 634 AddTaskTracker(VPT_Handle, new_task.taskID, width, height);
635 635  
636 636 if (!ProcessFlag) {
637   - ProcessThread = boost::thread(ThreadProcess, this);
  637 + m_bProcessExit = false;
  638 + ProcessThread = std::thread(ThreadProcess, this);
638 639 ProcessFlag = true;
639 640 }
640 641  
... ... @@ -645,12 +646,10 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh
645 646  
646 647 int CMutliSourceVideoProcess::AddOperator(task_param tparam)
647 648 {
648   - //boost::mutex::scoped_lock lock(process_thread_mutex);
649   -
650 649 if (!ProcessFlag)
651 650 {
652 651 AddTask(tparam);
653   - boost::thread::sleep(boost::get_system_time() + boost::posix_time::microseconds(500));
  652 + std::this_thread::sleep_for(std::chrono::milliseconds(500));
654 653 }
655 654 else
656 655 {
... ... @@ -673,7 +672,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam)
673 672 memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE);
674 673 TaskOperatorQ.push_back(newOper);
675 674 taskCondVar.wait_for(l, std::chrono::seconds(20));
676   - // printf("finish first task in operator queue\n");
677 675 }
678 676  
679 677 int addRes = -1;
... ... @@ -895,7 +893,7 @@ DWORD ThreadProcess(LPVOID param)
895 893 long long last_time = get_cur_time_ms();
896 894  
897 895 {
898   - while (1)
  896 + while (!pThreadParam->m_bProcessExit)
899 897 {
900 898 if (pThreadParam->licence_status <= -3)
901 899 {
... ... @@ -1037,7 +1035,7 @@ DWORD ThreadProcess(LPVOID param)
1037 1035 //��û�л�ȡ������·���Ľ������� ѭ���ȴ�
1038 1036 if (k.size() < curPlayTaskCount)
1039 1037 {
1040   - boost::this_thread::sleep(boost::posix_time::milliseconds(1));
  1038 + std::this_thread::sleep_for(std::chrono::milliseconds(1));
1041 1039 goto getdata_flag;
1042 1040 }
1043 1041  
... ... @@ -1704,6 +1702,11 @@ DWORD ThreadProcess(LPVOID param)
1704 1702 task_iter++;
1705 1703 }
1706 1704  
  1705 + for (auto task_id: pThreadParam->TaskinPlayID) {
  1706 + cudaFree(pThreadParam->tasks[task_id].task_algorithm_data.frame);
  1707 + }
  1708 +
  1709 +
1707 1710 for (int i = 0; i < deleteObjectID.size(); i++)
1708 1711 vector<int>().swap(deleteObjectID[i]);
1709 1712 vector<vector<int>>().swap(deleteObjectID);
... ... @@ -1720,7 +1723,7 @@ DWORD ThreadProcess(LPVOID param)
1720 1723 LOG_ERROR("object_attri_analysis last error: {}", cudaGetErrorString(cudaStatus));
1721 1724 }
1722 1725  
1723   - boost::this_thread::sleep(boost::posix_time::milliseconds(1));
  1726 + std::this_thread::sleep_for(std::chrono::milliseconds(1));
1724 1727  
1725 1728 ++total_count;
1726 1729 ++ncount;
... ... @@ -1739,8 +1742,7 @@ DWORD ThreadProcess(LPVOID param)
1739 1742 exit(-1);*/
1740 1743 }
1741 1744 long long costTime1 = get_cur_time_ms() - begintime1;
1742   - std::cout << "==================== Process Thread is Finished: " << std::endl;
1743   - printf("total frame cost time = %lld us, process times: %d total_count: %d \n", costTime1, process_times, total_count);
  1745 + LOG_INFO("Process Thread is Finished. total frame cost time = {} ms, process times: {}", costTime1, process_times);
1744 1746  
1745 1747 pThreadParam->m_snaphot_helper.snapShotInfo.clear();
1746 1748 pThreadParam->ProcessFlag = false;
... ... @@ -1780,7 +1782,7 @@ void check_thread(void* handle)
1780 1782  
1781 1783 CMutliSourceVideoProcess *pThreadParam = (CMutliSourceVideoProcess *)handle;
1782 1784  
1783   - while (1)
  1785 + while (!pThreadParam->m_bExit)
1784 1786 {
1785 1787 //printf("xxx check status on process...\n");
1786 1788 #ifdef _MSC_VER
... ... @@ -1792,6 +1794,7 @@ void check_thread(void* handle)
1792 1794 if (res < 0)
1793 1795 {
1794 1796 pThreadParam->licence_status = pThreadParam->licence_status - 1;
  1797 + printf("CMutliSourceVideoProcess licence error, ret: %d \n", res);
1795 1798 }
1796 1799 else
1797 1800 {
... ... @@ -1800,7 +1803,7 @@ void check_thread(void* handle)
1800 1803 pThreadParam->licence_status = 0;
1801 1804 }
1802 1805 }
1803   - boost::this_thread::sleep(boost::posix_time::seconds(300)); //5min
  1806 + std::this_thread::sleep_for(std::chrono::seconds(300));
1804 1807 }
1805 1808 }
1806 1809 #endif
1807 1810 \ No newline at end of file
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp
... ... @@ -11,7 +11,6 @@
11 11 #include <time.h>
12 12 #include "ErrorInfo.h"
13 13 #include "fstream"
14   -#include <boost/thread/thread.hpp>
15 14  
16 15  
17 16  
... ... @@ -41,8 +40,7 @@ typedef struct objDetector {
41 40 // VPT_FPNPluginFactory tensorrt_plugin_factory;
42 41  
43 42 int licence_status = -1;
44   - int thrd_status = -1;
45   - boost::thread thrd;
  43 + int thrd_status = -1;
46 44 vector<TaskTracker> taskTrackers;
47 45 objDetector()
48 46 {
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp
1 1 #include "VehiclePlate.h"
2 2 #include <cuda_runtime.h>
  3 +
  4 +#include "../../FFNvDecoder/logger.hpp"
3 5 //static string type[69] = { "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "³", "ԥ", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "��", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "��", "ѧ", "ʹ", "��" };
4 6  
5 7 int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license)
6 8 {
7   - vpd_param param;
8   - param.gpuid = gpuid;
9   - param.thresld = 0.3;
  9 + vp_detect_param param;
  10 + param.gpuid = gpuid;
  11 + param.thresld = 0.4;
10 12 param.max_batch = 20;
11   - param.serialize_file = "./serialize_file/VPD";
12   - param.auth_license = auth_license;
  13 + param.serialize_file = "./serialize_file/VPDetect";
  14 + param.auth_license = "sy_va_sub_sdk_2023";
13 15  
14 16 vpr_param rparam;
15   - rparam.gpuid =gpuid;
16   - param.max_batch = 20;
17   - param.serialize_file = "./serialize_file/VPR";
  17 + rparam.gpuid = gpuid;
  18 + rparam.max_batch = 20;
  19 + rparam.serialize_file = "./serialize_file/VPRecg";
  20 + param.auth_license = "sy_va_sub_sdk_2023";
18 21  
19 22 int ret = vpdr_init(&handle, param, rparam);
20 23  
21   -
22 24 if (ret != 0)
23 25 {
24   - cout << "Init platedr Failed!" << endl;
  26 + cout << "vpdr_init Failed!" << endl;
25 27 return FAILED;
26 28 }
27   -
28 29  
29 30 return SUCCESS;
30 31 }
31 32  
32   -int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vplate_result *&result)
  33 +int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_plate_result *&result)
33 34 {
34   - /*��ʼ������ṹ��*/
35   - vplates_result * all_result = new vplates_result[batchsize] {};
36   - for (int i = 0; i<batchsize; i++)
37   - {
38   - for (int j = 0; j < MAXPLATECOUNT; j++)
39   - {
40   - memset(&all_result[i].vehicle_plate_infos[j].rect, -1, sizeof(sy_rect));
41   - }
42   - }
43   -
44 35 sy_img cpu_batch_img[batchsize];
45 36 for (int i = 0; i < batchsize; i++)
46 37 {
47 38 if (batch_img[i].data_ == NULL)
48 39 {
49   - cout << i << " data null" << endl;
  40 + LOG_ERROR("data null ");
  41 + return FAILED;
50 42 }
51 43 cpu_batch_img[i].data_ = (unsigned char *)malloc(batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char));
52 44 cudaMemcpy(cpu_batch_img[i].data_, batch_img[i].data_, batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char), cudaMemcpyDeviceToHost);
... ... @@ -55,7 +47,17 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc
55 47 cpu_batch_img[i].c_ = batch_img[i].c_;
56 48 }
57 49  
  50 + vehicle_plate_results * all_result = new vehicle_plate_results[batchsize] {};
  51 + for (int i = 0; i<batchsize; i++)
  52 + {
  53 + for (int j = 0; j < MAXPLATECOUNT; j++)
  54 + {
  55 + memset(&all_result[i].vehicle_plate_infos[j].rect, -1, sizeof(sy_rect));
  56 + }
  57 + }
  58 +
58 59 int index_count = vpdr_batch(handle, cpu_batch_img, batchsize, all_result);
  60 + cudaDeviceSynchronize();
59 61  
60 62 for (int b = 0; b < batchsize; b++)
61 63 {
... ... @@ -75,12 +77,14 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc
75 77 }
76 78 }
77 79  
78   - memcpy(&result[b], &all_result[b].vehicle_plate_infos[best_index], sizeof(vplate_result));
  80 + memcpy(&result[b], &all_result[b].vehicle_plate_infos[best_index], sizeof(vehicle_plate_result));
79 81 }
80 82  
81 83 for (int i = 0; i < batchsize; i++) {
82   - free(cpu_batch_img[i].data_);
83   - cpu_batch_img[i].data_ = nullptr;
  84 + if(cpu_batch_img[i].data_ != nullptr) {
  85 + free(cpu_batch_img[i].data_);
  86 + cpu_batch_img[i].data_ = nullptr;
  87 + }
84 88 }
85 89  
86 90 if (all_result != NULL)
... ... @@ -91,7 +95,9 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc
91 95  
92 96 int VehiclePlateDetectRecog_Release(void *& handle)
93 97 {
94   - if (handle)
95   - vpdr_release(&handle);
  98 + if (handle) {
  99 + vpdr_release(&handle);
  100 + }
  101 +
96 102 return SUCCESS;
97 103 }
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.h
1   -#include "vehicle_plate_dr.h"
2   -
3 1  
4 2 #pragma once
5 3 #include "opencv2/highgui/highgui.hpp"
6 4 #include <iostream>
7 5 #include "utools.h"
8 6 #include <vector>
9   -using namespace std;
10 7  
  8 +#include "vehicle_plate_dr.h"
  9 +
  10 +
  11 +using namespace std;
11 12  
12 13  
13 14 int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license);
14   -int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img,int batchsize, vplate_result *&result);
  15 +int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img,int batchsize, vehicle_plate_result *&result);
15 16 int VehiclePlateDetectRecog_Release(void *& handle);
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.cpp
... ... @@ -5,29 +5,22 @@ int VehicleRearRecg_Init(void *&amp;handle, char*dbpath, int gpuid, char* auth_licen
5 5 vrr_param params;
6 6 params.gpuid = gpuid;
7 7 params.mode = DEVICE_GPU;
8   - //printf("ERROR PATH\n");
9   - params.db_path = dbpath;//"../../db/mvpt.bin";
  8 + params.db_path = dbpath;
10 9 params.engine = ENGINE_TENSORRT;
11 10 params.max_batch = 20;
12 11 params.serialize_file = "./serialize_file/VRR";
13 12 params.auth_license = auth_license;
14 13  
15   - //#ifdef _MSC_VER
16   - // params.dbPath = "../../../../vehicleRecognition_MCaffeTmpBody/db/CarBodyFeature.db";
17   - //#else
18   - // params.dbPath = "/home/mliu/project/Project_MultiVPT/Video-Platform/video_structure_20190131/VehicleRecognition_body/db/CarBodyFeature.db";
19   - //#endif
20   -
21 14 int ret = vrr_init(&handle, params);
22 15 if (ret != 0)
23 16 {
24 17 cout << "VRR Init Failed!" << endl;
25   - system("pause");
26 18 return FAILED;
27 19 }
  20 +
28 21 return SUCCESS;
29 22 }
30   -int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vr_result)
  23 +int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result)
31 24 {
32 25 for (int i = 0; i < batchsize; i++)
33 26 {
... ... @@ -37,7 +30,6 @@ int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr
37 30  
38 31 vrr_batch(handle, batch_img, batchsize, vr_result);
39 32  
40   -
41 33 return SUCCESS;
42 34 }
43 35 int VehicleRearRecg_Release(void *& handle)
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h
... ... @@ -9,5 +9,5 @@ using namespace std;
9 9  
10 10  
11 11 int VehicleRearRecg_Init(void *&handle, char*dbpath, int gpuid, char* auth_license);
12   -int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vr_result);
  12 +int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result);
13 13 int VehicleRearRecg_Release(void *& handle);
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp
... ... @@ -6,87 +6,33 @@ using namespace std;
6 6 int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license)
7 7 {
8 8 vr_param params;
9   - params.gpuid = gpuid;
10   - params.mode = DEVICE_GPU;
11   -
12   - params.db_path = dbpath;//"../../db/mvpt.bin";
  9 + params.gpuid = 0;
  10 + params.mode = DEVICE_GPU;
13 11 params.engine = ENGINE_TENSORRT;
14 12 params.max_batch = 20;
15   - params.serialize_file = "./serialize_file/VR";
16   - params.auth_license = auth_license;
17   -//#ifdef _MSC_VER
18   -// params.dbPath = "../../../../vehicleRecognition_MCaffeTmpBody/db/CarBodyFeature.db";
19   -//#else
20   -// params.dbPath = "/home/mliu/project/Project_MultiVPT/Video-Platform/video_structure_20190131/VehicleRecognition_body/db/CarBodyFeature.db";
21   -//#endif
  13 + params.vehicle_brand_serialize_file = "./serialize_file/VEHICLE_BRAND";
  14 + params.vr5905cls_serialize_file = "./serialize_file/VR5905CLS";
  15 + params.vehicle_type_serialize_file = "./serialize_file/VEHICLE_TYPE";
  16 + params.auth_license = "sy_va_sub_sdk_2023";
  17 +
22 18 int ret = vr_init(&handle, params);
23 19 if (ret != 0)
24 20 {
25 21 cout << "VR Init Failed!" << endl;
26   - system("pause");
27 22 return FAILED;
28 23 }
29 24 return SUCCESS;
30 25 }
31 26  
32   -int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vrresult)
  27 +int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_recog_result *&vrresult)
33 28 {
34   - //VR_Result *vr_result = new VR_Result[batchsize];
35   - /*vrresult = new vr_result[batchsize];
36   - for (int i = 0; i < batchsize; i++)
37   - {
38   - vrresult[i].vehicle_brand = new char[260];
39   - vrresult[i].vehicle_subbrand = new char[260];
40   - vrresult[i].vehicle_issue_year = new char[260];
41   - vrresult[i].vehicle_type = new char[260];
42   - vrresult[i].freight_ton = new char[260];
43   - }*/
44 29 for (int i = 0; i < batchsize; i++)
45 30 {
46 31 if (batch_img[i].data_ == NULL)
47 32 cout << i << " data null" << endl;
48 33 }
49 34  
50   - //cout << "begin vr_batch" << endl;
51 35 vr_batch(handle, batch_img, batchsize, vrresult);
52   - //cout << "end vr_batch" << endl;
53   - /* for (int i = 0; i < batchsize; i++)
54   - {
55   - cout << i << ".ʶ������" << endl;
56   - cout << " ʶ�����Ŷ�: " << vr_result[i].name_score << endl;
57   - cout << " ����Ʒ�� - " << vr_result[i].vehicleBrand << endl;
58   - cout << " ������Ʒ�� - " << vr_result[i].vehicleSubBrand << endl;
59   - cout << " ������� - " << vr_result[i].vehicleIssueYear << endl;
60   - cout << " �������� - " << vr_result[i].vehicleType << endl;
61   - cout << " �����ּ� - " << vr_result[i].freightTon << endl;
62   - cout << endl;
63   -
64   - if (vr_result[i].vehicleBrand != NULL)
65   - {
66   - delete[] vr_result[i].vehicleBrand;
67   - vr_result[i].vehicleBrand = NULL;
68   - }
69   - if (vr_result[i].vehicleSubBrand != NULL)
70   - {
71   - delete[] vr_result[i].vehicleSubBrand;
72   - vr_result[i].vehicleSubBrand = NULL;
73   - }
74   - if (vr_result[i].vehicleIssueYear != NULL)
75   - {
76   - delete[] vr_result[i].vehicleIssueYear;
77   - vr_result[i].vehicleIssueYear = NULL;
78   - }
79   - if (vr_result[i].vehicleType != NULL)
80   - {
81   - delete[] vr_result[i].vehicleType;
82   - vr_result[i].vehicleType = NULL;
83   - }
84   - if (vr_result[i].freightTon != NULL)
85   - {
86   - delete[] vr_result[i].freightTon;
87   - vr_result[i].freightTon = NULL;
88   - }
89   - }*/
90 36  
91 37 return SUCCESS;
92 38 }
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h
... ... @@ -11,5 +11,5 @@ using namespace std;
11 11  
12 12  
13 13 int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license);
14   -int VehicleRecognition_Process(void * handle, sy_img * batch_img,int batchsize, vr_result *&vr_result);
  14 +int VehicleRecognition_Process(void * handle, sy_img * batch_img,int batchsize, vehicle_recog_result*&vr_result);
15 15 int VehicleRecognition_Release(void *& handle);
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp renamed to vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp
1   -#include "non_vehicle_fea_trt.h"
  1 +#include "non_vehicle_fea.h"
  2 +#include "sy_common.h"
2 3 #include <iostream>
3 4 int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license)
4 5 {
... ... @@ -11,7 +12,7 @@ int NonVehicleFea_Init(void *&amp;handle, int gpuid, char* auth_license)
11 12 fea_param.thres = 0.6;
12 13 fea_param.engine = ENGINE_TENSORRT;
13 14  
14   - //δÉúЧ
  15 + //δ��Ч
15 16 fea_param.max_batch = 20;
16 17 fea_param.serialize_file = "./serialize_file/HF";
17 18 fea_param.auth_license = auth_license;
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h renamed to vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h
1 1 #pragma once
2   -#include "human_fea.h"
  2 +#include "non_vehicle_fea_trt.h"
3 3 #include "utools.h"
4 4  
5 5 int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license);
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp
1 1 #include "opencv2/opencv.hpp"
2 2 #include "opencv2/highgui/highgui.hpp"
3 3 #include "snapshot_helper.h"
4   -#include <vector>
5   -#include <thread>
6 4 #include "HumanParsing.h"
7 5 #include "HumanCarParsing.h"
8 6 #include "VehiclePlate.h"
9 7 #include "VehicleRecognition.h"
10 8 #include "VehicleColor.h"
11   -#include "non_vehicle_fea_trt.h"
  9 +#include "non_vehicle_fea.h"
12 10 //#include "HumanFeatures.h"
13 11 #include "vehicle_features.h"
14 12 #include "VehicleRearRecg.h"
... ... @@ -16,12 +14,14 @@
16 14  
17 15 #include <chrono>
18 16  
  17 +#include "../FFNvDecoder/logger.hpp"
  18 +
19 19 using namespace std;
20 20  
21 21 string ObjTypes[9] = { "行人", "自行车", "摩托车", "三轮车", "小型车", "大车", "卡车", "拖拉机", "中巴" };
22 22 string ObjTypesEnglish[9] = { "person", "bike", "motor", "tricycle", "car", "bigbus", "lorry", "tractor", "midibus" };
23   -DWORD SnapshotThreadProcess(LPVOID param);
24   -DWORD SnapshotImageWriteThreadProcess(LPVOID param);
  23 +
  24 +
25 25 #ifdef _MSC_VER
26 26 char* GbkToUtf8(const char *src_str)
27 27 {
... ... @@ -74,10 +74,22 @@ private:
74 74 long end_time{ 0 };
75 75 char* opt_name;
76 76 };
  77 +#endif
77 78  
  79 +void SnapshotThreadProcess(const void * userPtr){
  80 + snapshot_helper* _this = (snapshot_helper*)userPtr;
  81 + if(nullptr != _this){
  82 + _this->snapshot_thread_process();
  83 + }
  84 +}
78 85  
  86 +void SnapshotImageWriteThreadProcess(const void * userPtr){
  87 + snapshot_helper* _this = (snapshot_helper*)userPtr;
  88 + if(nullptr != _this){
  89 + _this->snapshot_imagewrite_thread_process();
  90 + }
  91 +}
79 92  
80   -#endif
81 93 void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, char* dbpath, char* auth_license, int wait_framecount, sy_command hp_analysis_config, \
82 94 sy_command hcp_analysis_config, sy_command vehicle_analysis_config, sy_command vehicle_recg_config, sy_command vehicle_plate_det_recg_config, sy_command hf_recg_config, sy_command hcf_recg_config, sy_command vcf_recg_config)
83 95 {
... ... @@ -150,37 +162,18 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c
150 162 batch_vehicle = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{};
151 163 batch_vehicle_vf = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{};
152 164  
153   - //count_vehivle_finishanalysis = 0;
154   - ProcessSnapshotThread = boost::thread(SnapshotThreadProcess, this);
155   - auto writeThread1 = std::thread(SnapshotImageWriteThreadProcess, this);
156   - writeThread1.detach();
157   - auto writeThread2 = std::thread(SnapshotImageWriteThreadProcess, this);
158   - writeThread2.detach();
159   - auto writeThread3 = std::thread(SnapshotImageWriteThreadProcess, this);
160   - writeThread3.detach();
161   - auto writeThread4 = std::thread(SnapshotImageWriteThreadProcess, this);
162   - writeThread4.detach();
163   - auto writeThread5 = std::thread(SnapshotImageWriteThreadProcess, this);
164   - writeThread5.detach();
165   - auto writeThread6 = std::thread(SnapshotImageWriteThreadProcess, this);
166   - writeThread6.detach();
167   - auto writeThread7 = std::thread(SnapshotImageWriteThreadProcess, this);
168   - writeThread7.detach();
169   - auto writeThread8 = std::thread(SnapshotImageWriteThreadProcess, this);
170   - writeThread8.detach();
171   - auto writeThread9 = std::thread(SnapshotImageWriteThreadProcess, this);
172   - writeThread9.detach();
173   - auto writeThread10 = std::thread(SnapshotImageWriteThreadProcess, this);
174   - writeThread10.detach();
175   - auto writeThread11 = std::thread(SnapshotImageWriteThreadProcess, this);
176   - writeThread11.detach();
177   - auto writeThread12 = std::thread(SnapshotImageWriteThreadProcess, this);
178   - writeThread12.detach();
179   -
  165 + m_bExit = false;
  166 + ProcessSnapshotThread = new std::thread(SnapshotThreadProcess, this);
  167 + for (size_t i = 0; i < 12; i++)
  168 + {
  169 + std::thread* writeThread = new std::thread(SnapshotImageWriteThreadProcess, this);
  170 + m_vec_writeThread.push_back(writeThread);
  171 + }
180 172 }
181 173  
182 174 void snapshot_helper::snapshot_helper_release()
183 175 {
  176 + m_bExit = true;
184 177 HumanParsing_Release(hp_handle);
185 178 HumanCarParsing_Release(hcp_handle);
186 179 VehicleColor_Release(vc_handle);
... ... @@ -229,8 +222,11 @@ void snapshot_helper::snapshot_helper_release()
229 222 }
230 223 }
231 224  
232   - ProcessSnapshotThread.interrupt(); //interrupt thread
233   - ProcessSnapshotThread.join(); //waiting thread finish
  225 + ProcessSnapshotThread->join(); //waiting thread finish
  226 + for (size_t i = 0; i < m_vec_writeThread.size(); i++)
  227 + {
  228 + m_vec_writeThread[i]->join();
  229 + }
234 230 }
235 231  
236 232  
... ... @@ -262,14 +258,15 @@ int snapshot_helper::save_face_snapshot(OBJ_KEY obj_key)
262 258 save_snapshot(true, m_task_info[obj_key.videoID]._on_image_display, obj_key, snapShotName, "cpu", tempSnapShotFaceHost, obj_value.snapShotFace.width, obj_value.snapShotFace.height, obj_key.videoID, obj_key.objID, 0,
263 259 0, 0, obj_value.snapShotFace.width, obj_value.snapShotFace.height);
264 260  
  261 + // if (tempSnapShotFaceHost)
  262 + // {
  263 + // delete[] tempSnapShotFaceHost;
  264 + // tempSnapShotFaceHost = NULL;
  265 + // }
  266 +
265 267 cudaFree(obj_value.snapShotFace.frame);
266 268 obj_value.snapShotFace.frame = nullptr;
267 269 obj_value.snapShotFace.height = -1; //表示有人脸检测到 存过人脸快照图 用于确定最终是否返回人脸快照保存位置
268   - if (tempSnapShotFaceHost)
269   - {
270   - delete[] tempSnapShotFaceHost;
271   - tempSnapShotFaceHost = NULL;
272   - }
273 270 }
274 271  
275 272 return 0;
... ... @@ -468,7 +465,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
468 465 {
469 466 vector<OBJ_KEY> hp_keys;
470 467 vector<OBJ_KEY> hcp_keys;
471   - vector<OBJ_KEY> vehicle_keys;
  468 + queue<OBJ_KEY> vehicle_keys;
472 469 vector<OBJ_KEY> vehicle_else; //仅保存的
473 470  
474 471 for (auto iter = snapShotInfo.begin(); iter != snapShotInfo.end(); iter++)
... ... @@ -483,7 +480,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
483 480 hcp_keys.push_back(iter->first);
484 481 else if ((iter->second.index.index == 8 || (iter->second.index.index >= 4 && iter->second.index.index <= 6)) && (vehicle_analysis_config == SY_CONFIG_OPEN || vcf_recg_config == SY_CONFIG_OPEN) && m_task_info[task_id].snapshot_folder != NULL
485 482 && iter->second.snapShotLittle.frame != NULL && iter->second.snapShotLittle.height == VEHICLE_HEIGHT && iter->second.snapShotLittle.width == VEHICLE_WIDTH)
486   - vehicle_keys.push_back(iter->first);
  483 + vehicle_keys.push(iter->first);
487 484 else
488 485 vehicle_else.push_back(iter->first);
489 486 }
... ... @@ -699,98 +696,80 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
699 696  
700 697 if (!vehicle_keys.empty())
701 698 {
702   - const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE;
703   - const int vehicle_batch_size = vehicle_keys.size();
704   - int vehicle_batch_count = obj_batch_count;
705   - for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i)
706   - {
707   - if (i == (vehicle_batch_size / obj_batch_count))
708   - vehicle_batch_count = vehicle_batch_size % obj_batch_count;
  699 + int det_batch_size = 10;
  700 + while (!vehicle_keys.empty()) {
709 701  
710   - if (vehicle_batch_count == 0) continue;
711   -
712   - sy_img finish_vehicle_img[vehicle_batch_count];
713   - for (int j = 0; j < vehicle_batch_count; j++)
  702 + if(vehicle_keys.size() >= 10) {
  703 + det_batch_size = 10;
  704 + } else {
  705 + det_batch_size = vehicle_keys.size();
  706 + }
  707 +
  708 + sy_img finish_vehicle_img[det_batch_size];
  709 + vector<OBJ_KEY> det_vehicle_keys;
  710 + for (int j = 0; j < det_batch_size; j++)
714 711 {
715   - OBJ_KEY cur_obj_key = vehicle_keys[j];
  712 + OBJ_KEY cur_obj_key = vehicle_keys.front();
  713 + det_vehicle_keys.push_back(cur_obj_key);
716 714 finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame);
  715 + vehicle_keys.pop();
717 716 }
718 717  
719   - vc_result *vcresult = new vc_result[vehicle_batch_count]{};
720   - vplate_result *vp_result = new vplate_result[vehicle_batch_count]{};
721   - vr_result *vrresult = new vr_result[vehicle_batch_count]{};
722   - if (vehicle_analysis_config == SY_CONFIG_OPEN)
723   - {
724   - VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult);
725   - VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result);
726   - VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count);
  718 + vc_result *vcresult = new vc_result[det_batch_size]{};
  719 + vehicle_plate_result *vp_result = new vehicle_plate_result[det_batch_size]{};
  720 + vr_result *vrresult = new vr_result[det_batch_size]{};
  721 + if (vehicle_analysis_config == SY_CONFIG_OPEN) {
  722 + if(det_batch_size == 3) {
  723 + printf("batchsize: %d \n", det_batch_size);
  724 + }
  725 + VehicleColor_Process(vc_handle, finish_vehicle_img, det_batch_size, vcresult);
  726 + VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, det_batch_size, vp_result);
  727 + VehicleRecog_Process(finish_vehicle_img, det_batch_size, vrresult, det_vehicle_keys.data());
727 728 }
728 729  
729 730 int8 ** fea = nullptr;
730   - if (vcf_recg_config == SY_CONFIG_OPEN)
731   - {
732   -
733   - fea = new int8*[vehicle_batch_count] {};
734   - for (int ii = 0; ii < vehicle_batch_count; ++ii)
735   - {
  731 + if (vcf_recg_config == SY_CONFIG_OPEN) {
  732 + fea = new int8*[det_batch_size] {};
  733 + for (int ii = 0; ii < det_batch_size; ++ii) {
736 734 fea[ii] = new int8[FEATURESIZE]{};
737 735 }
738 736  
739   - //TimeCounting t("vf_features_process");
740   - vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea);
  737 + vf_features_process(vf_handle, finish_vehicle_img, det_batch_size, fea);
741 738 }
742 739  
743   -
744   - int resIndex = 0;
745 740 int feaIndex = 0;
746   - for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++)
  741 + for (int vc_idx = 0; vc_idx < det_batch_size; vc_idx++)
747 742 {
748   - auto iter = snapShotInfo.find(vehicle_keys[vc_idx]);
749   -
750   - if (iter == snapShotInfo.end())
751   - resIndex++; //cout << iter_key.videoID << " " <<iter_key.objID << " cant find" << endl;
752   - else
753   - {
  743 + auto iter = snapShotInfo.find(det_vehicle_keys[vc_idx]);
  744 + if (iter != snapShotInfo.end()) {
754 745 vehicle_result curRes = {};
755   - if (vehicle_analysis_config == SY_CONFIG_OPEN)
756   - {
757   - //VC
758   - memcpy(&curRes.vc_res, &vcresult[resIndex], sizeof(vc_result));
759   -
760   - //VP
761   - memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vplate_result));
762   -
763   - //VR
764   - memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result));
765   - resIndex++;
  746 + if (vehicle_analysis_config == SY_CONFIG_OPEN) {
  747 + memcpy(&curRes.vc_res, &vcresult[vc_idx], sizeof(vc_result));
  748 + memcpy(&curRes.vp_res, &vp_result[vc_idx], sizeof(vehicle_plate_result));
  749 + memcpy(&curRes.vr_res, &vrresult[vc_idx], sizeof(vr_result));
766 750 }
767 751  
768   - if (vcf_recg_config == SY_CONFIG_OPEN)
769   - {
770   - //if (mp_head.find(vc_idx) != mp_head.end())
771   - {
772   - int8 * feaRes = fea[feaIndex];
773   - memcpy(curRes.feature, feaRes, FEATURESIZE * sizeof(int8));
774   - ++feaIndex;
775   - }
  752 + if (vcf_recg_config == SY_CONFIG_OPEN) {
  753 + int8 * feaRes = fea[vc_idx];
  754 + memcpy(curRes.feature, feaRes, FEATURESIZE * sizeof(int8));
776 755 }
777 756  
778   - snapshot_res_callback(vehicle_keys[vc_idx], &curRes);
  757 + snapshot_res_callback(det_vehicle_keys[vc_idx], &curRes);
779 758  
780 759 int count_vehicle_size = count_vehicle_v.size();
781   - for (vector<OBJ_KEY>::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); )
  760 + for (auto iter_v = count_vehicle_v.begin(); iter_v != count_vehicle_v.end(); )
782 761 {
783   - if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID)
784   - iter = count_vehicle_v.erase(iter);
  762 + if (iter_v->videoID == det_vehicle_keys[vc_idx].videoID && iter_v->objID == det_vehicle_keys[vc_idx].objID)
  763 + iter_v = count_vehicle_v.erase(iter_v);
785 764 else
786 765 {
787   - ++iter;
  766 + ++iter_v;
788 767 }
789 768 }
790 769  
791 770 if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里
792 771 {
793   - save_snapshot(vehicle_keys[vc_idx]);
  772 + save_snapshot(det_vehicle_keys[vc_idx]);
794 773 }
795 774  
796 775 if (iter->second.snapShotLittle.frame)
... ... @@ -808,7 +787,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
808 787  
809 788 if (fea != nullptr)
810 789 {
811   - for (int ii = 0; ii < vehicle_batch_count; ++ii)
  790 + for (int ii = 0; ii < det_batch_size; ++ii)
812 791 {
813 792 delete[] fea[ii];
814 793 }
... ... @@ -832,8 +811,6 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
832 811 delete[] vrresult;
833 812 vrresult = NULL;
834 813 }
835   -
836   - vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count);
837 814 }
838 815  
839 816 v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS;
... ... @@ -862,21 +839,6 @@ void snapshot_helper::hp_analysis()
862 839 //if (count_person.size() >= OBJ_BATCH_COUNT)
863 840  
864 841 {
865   -#ifdef LOG_INFO
866   - std::cout << "------ begin HumanParsing_Process -----" << std::endl;
867   -#ifdef _MSC_VER
868   - LARGE_INTEGER nFreq, nBeginTime, nEndTime;
869   - LARGE_INTEGER nSaveBeginTime, nSaveEndTime;
870   -
871   - QueryPerformanceFrequency(&nFreq);
872   - QueryPerformanceCounter(&nBeginTime);
873   - double time_val = 0.0;
874   -#else
875   - gettimeofday(&t1, NULL);
876   -
877   -#endif
878   -#endif
879   -
880 842 //选择前N个做行人属性分析
881 843 const int OBJ_BATCH_COUNT_bk = OBJ_BATCH_COUNT;
882 844 const int OBJ_SCALE_COUNT_bk = OBJ_SCALE;
... ... @@ -933,19 +895,6 @@ void snapshot_helper::hp_analysis()
933 895 //TimeCounting t("NonVehicleFea_Process");
934 896 NonVehicleFea_Process(nvf_handle, batch_hp, obj_batch_count, result_f);
935 897 }
936   -#ifdef LOG_INFO
937   -#ifdef _MSC_VER
938   - QueryPerformanceCounter(&nEndTime);
939   - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
940   - std::printf("HumanParsing_Process: %.2f ms \n", time_val);
941   -#else
942   - /*
943   - gettimeofday(&t2, NULL);
944   - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0;
945   - printf("HumanParsing_Process = %lf ms\n", time_val);
946   - */
947   -#endif
948   -#endif
949 898  
950 899 //删除已经进行保存和二次属性分析的目标
951 900 int resIndex = 0;
... ... @@ -986,20 +935,6 @@ void snapshot_helper::hp_analysis()
986 935 delete[] result_f;
987 936 result_f = nullptr;
988 937 }
989   -#ifdef LOG_INFO
990   -#ifdef _MSC_VER
991   - QueryPerformanceCounter(&nEndTime);
992   - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
993   - std::printf("total: %.2f ms \n", time_val);
994   -#else
995   - /*
996   - gettimeofday(&t2, NULL);
997   - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0;
998   - printf("HumanParsing_Process = %lf ms\n", time_val);
999   - */
1000   -#endif
1001   - std::cout << "----- end HumanParsing_Process -----" << std::endl;
1002   -#endif
1003 938 }
1004 939  
1005 940 OBJ_BATCH_COUNT = OBJ_BATCH_COUNT_bk;
... ... @@ -1027,20 +962,6 @@ void snapshot_helper::hcp_analysis()
1027 962 {
1028 963 vector<OBJ_KEY> erase_obj_key;
1029 964  
1030   -#ifdef LOG_INFO
1031   - std::cout << "----- begin HumanCarParsing_Process -----" << endl;
1032   -#ifdef _MSC_VER
1033   - LARGE_INTEGER nFreq, nBeginTime, nEndTime;
1034   - LARGE_INTEGER nSaveBeginTime, nSaveEndTime;
1035   -
1036   - QueryPerformanceFrequency(&nFreq);
1037   - QueryPerformanceCounter(&nBeginTime);
1038   - double time_val = 0.0;
1039   -#else
1040   - gettimeofday(&t1, NULL);
1041   -
1042   -#endif
1043   -#endif
1044 965 int obj_batch_count = 0;
1045 966 hcp_analysis_result *result = nullptr;
1046 967 human_fea_result * result_f = nullptr;
... ... @@ -1088,21 +1009,6 @@ void snapshot_helper::hcp_analysis()
1088 1009 NonVehicleFea_Process(nvf_handle, batch_hcp, obj_batch_count, result_f);
1089 1010 }
1090 1011  
1091   -
1092   -#ifdef LOG_INFO
1093   -#ifdef _MSC_VER
1094   - QueryPerformanceCounter(&nEndTime);
1095   - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
1096   - printf("HumanCarParsing_Process: %.2f ms \n", time_val);
1097   -#else
1098   - /*
1099   - gettimeofday(&t2, NULL);
1100   - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0;
1101   - printf("HumanCarParsing_Process = %lf ms\n", time_val);
1102   - */
1103   -#endif
1104   - cout << "----- end HumanCarParsing_Process -----" << endl;
1105   -#endif
1106 1012 int resIndex = 0;
1107 1013 for (auto iter_key : erase_obj_key)
1108 1014 {
... ... @@ -1173,20 +1079,6 @@ bool snapshot_helper::vehicle_color_analysis()
1173 1079  
1174 1080 for (int index = 0; index < OBJ_SCALE; ++index)
1175 1081 {
1176   -#ifdef LOG_INFO
1177   - cout << "----- begin VehicleColor_Process -----" << endl;
1178   -#ifdef _MSC_VER
1179   - LARGE_INTEGER nFreq, nBeginTime, nEndTime;
1180   - LARGE_INTEGER nSaveBeginTime, nSaveEndTime;
1181   -
1182   - QueryPerformanceFrequency(&nFreq);
1183   - QueryPerformanceCounter(&nBeginTime);
1184   - double time_val = 0.0;
1185   -#else
1186   - gettimeofday(&t1, NULL);
1187   -
1188   -#endif
1189   -#endif
1190 1082 int start_idx = cur_iter_count * index;
1191 1083  
1192 1084 int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count;
... ... @@ -1224,21 +1116,6 @@ bool snapshot_helper::vehicle_color_analysis()
1224 1116 //TimeCounting t("VehicleColor_Process");
1225 1117 VehicleColor_Process(vc_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vcresult);
1226 1118 }
1227   -
1228   -
1229   -#ifdef LOG_INFO
1230   -#ifdef _MSC_VER
1231   - QueryPerformanceCounter(&nEndTime);
1232   - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
1233   - printf("VehicleColor_Process: %.2f ms \n", time_val);
1234   -#else
1235   - /*
1236   - gettimeofday(&t2, NULL);
1237   - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0;
1238   - printf("VehicleColor_Process = %lf ms\n", time_val);
1239   - */
1240   -#endif
1241   -#endif
1242 1119  
1243 1120 for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++)
1244 1121 {
... ... @@ -1287,21 +1164,6 @@ bool snapshot_helper::vehicle_plate_dr_analysis()
1287 1164  
1288 1165 for (int index = 0; index < OBJ_SCALE; ++index)
1289 1166 {
1290   -#ifdef LOG_INFO
1291   - cout << "----- begin VEHICLEPLATEAnalysis -----" << endl;
1292   -
1293   -#ifdef _MSC_VER
1294   - LARGE_INTEGER nFreq, nBeginTime, nEndTime;
1295   - LARGE_INTEGER nSaveBeginTime, nSaveEndTime;
1296   -
1297   - QueryPerformanceFrequency(&nFreq);
1298   - QueryPerformanceCounter(&nBeginTime);
1299   - double time_val = 0.0;
1300   -#else
1301   - gettimeofday(&t1, NULL);
1302   -
1303   -#endif
1304   -#endif
1305 1167 int start_idx = cur_iter_count * index;
1306 1168 int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count;
1307 1169  
... ... @@ -1331,26 +1193,8 @@ bool snapshot_helper::vehicle_plate_dr_analysis()
1331 1193 }
1332 1194 batch_vehicle[i].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame);
1333 1195 }
1334   - vplate_result *vp_result = new vplate_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{};
1335   - {
1336   - //TimeCounting t("VehiclePlateDetectRecog_Process");
1337   - VehiclePlateDetectRecog_Process(vp_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result);
1338   - }
1339   -
1340   -
1341   -#ifdef LOG_INFO
1342   -#ifdef _MSC_VER
1343   - QueryPerformanceCounter(&nEndTime);
1344   - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
1345   - printf("VEHICLEPLATEAnalysis: %.2f ms \n", time_val);
1346   -#else
1347   - /*
1348   - gettimeofday(&t2, NULL);
1349   - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0;
1350   - printf("VehicleColor_Process = %lf ms\n", time_val);
1351   - */
1352   -#endif
1353   -#endif
  1196 + vehicle_plate_result *vp_result = new vehicle_plate_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{};
  1197 + VehiclePlateDetectRecog_Process(vp_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result);
1354 1198  
1355 1199 int resIndex = 0;
1356 1200 for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++)
... ... @@ -1363,7 +1207,7 @@ bool snapshot_helper::vehicle_plate_dr_analysis()
1363 1207 {
1364 1208 vehicle_result &curRes = vehicle_result_v[i + start_idx];
1365 1209  
1366   - memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vplate_result));
  1210 + memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vehicle_plate_result));
1367 1211 resIndex++;
1368 1212 }
1369 1213 }
... ... @@ -1392,13 +1236,17 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr
1392 1236 sy_img * batch_vehicle_head = new sy_img[batchsize]{};
1393 1237 sy_img * batch_vehicle_rear = new sy_img[batchsize]{};
1394 1238  
1395   - vpd_result * vhd_res = new vpd_result[batchsize]{};
  1239 + vpd2_result* vhd_res = new vpd2_result[batchsize];
  1240 + for (int b = 0; b < batchsize; b++)
  1241 + {
  1242 + vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT];
  1243 + }
1396 1244 vhd_features_process(vhd_handle, batch_img, batchsize, vhd_res);
1397 1245  
1398 1246 for (int vc_idx = 0; vc_idx < batchsize; vc_idx++)
1399 1247 {
1400 1248 OBJ_KEY cur_obj_key = obj_keys[vc_idx];
1401   - vpd_result & result = vhd_res[vc_idx];
  1249 + vpd2_result & result = vhd_res[vc_idx];
1402 1250  
1403 1251 if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别
1404 1252 {
... ... @@ -1472,18 +1320,15 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr
1472 1320  
1473 1321 if (index_head != 0)
1474 1322 {
1475   - vr_result *vrresult = new vr_result[index_head]{};
1476   - {
1477   - //TimeCounting t("VehicleRecognition_Process");
1478   - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult);
1479   - }
  1323 + LOG_DEBUG("index_head : {}", index_head);
  1324 + vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{};
  1325 + VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult);
1480 1326  
1481 1327  
1482 1328 int resIndex = 0;
1483 1329 for (auto & item : mp_head)
1484 1330 {
1485   - vr_result &curRes = vresult[item];
1486   - memcpy(&vresult[item], &vrresult[resIndex], sizeof(vr_result));
  1331 + memcpy(&vresult[item], &vrresult[resIndex], sizeof(vehicle_recog_result));
1487 1332 resIndex++;
1488 1333 }
1489 1334 delete[] vrresult;
... ... @@ -1492,18 +1337,13 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr
1492 1337  
1493 1338 if (index_rear != 0)
1494 1339 {
1495   - vr_result *vrresult = new vr_result[index_rear]{};
1496   -
1497   - {
1498   - //TimeCounting t("VehicleRearRecg_Process");
1499   - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult);
1500   - }
  1340 + vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{};
  1341 + VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult);
1501 1342  
1502 1343 int resIndex = 0;
1503 1344 for (auto & item : mp_rear)
1504 1345 {
1505   - vr_result &curRes = vresult[item];
1506   - memcpy(&vresult[item], &vrresult[resIndex], sizeof(vr_result));
  1346 + memcpy(&vresult[item], &vrresult[resIndex], sizeof(vehicle_rear_result));
1507 1347 resIndex++;
1508 1348 }
1509 1349 delete[] vrresult;
... ... @@ -1561,21 +1401,6 @@ bool snapshot_helper::vehicle_recg_analysis()
1561 1401 // OBJ_BATCH_COUNT_VEHICLE, OBJ_SCALE, cur_iter_count);
1562 1402 for (int index = 0; index < OBJ_SCALE; ++index)
1563 1403 {
1564   -#ifdef LOG_INFO
1565   - cout << "----- begin VehicleColor_Process -----" << endl;
1566   -
1567   -#ifdef _MSC_VER
1568   - LARGE_INTEGER nFreq, nBeginTime, nEndTime;
1569   - LARGE_INTEGER nSaveBeginTime, nSaveEndTime;
1570   -
1571   - QueryPerformanceFrequency(&nFreq);
1572   - QueryPerformanceCounter(&nBeginTime);
1573   - double time_val = 0.0;
1574   -#else
1575   - gettimeofday(&t1, NULL);
1576   -
1577   -#endif
1578   -#endif
1579 1404 int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count;
1580 1405  
1581 1406 for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++)
... ... @@ -1616,13 +1441,17 @@ bool snapshot_helper::vehicle_recg_analysis()
1616 1441 sy_img * batch_vehicle_head = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{};
1617 1442 sy_img * batch_vehicle_rear = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{};
1618 1443  
1619   - vpd_result * vhd_res = new vpd_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{};
  1444 + vpd2_result* vhd_res = new vpd2_result[cur_batchsize];
  1445 + for (int b = 0; b < cur_batchsize; b++)
  1446 + {
  1447 + vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT];
  1448 + }
1620 1449 vhd_features_process(vhd_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res);
1621 1450  
1622 1451 for (int vc_idx = 0; vc_idx < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; vc_idx++)
1623 1452 {
1624 1453 OBJ_KEY cur_obj_key = count_vehicle_v[vc_idx];
1625   - vpd_result & result = vhd_res[vc_idx];
  1454 + vpd2_result & result = vhd_res[vc_idx];
1626 1455  
1627 1456 if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别
1628 1457 {
... ... @@ -1697,11 +1526,8 @@ bool snapshot_helper::vehicle_recg_analysis()
1697 1526  
1698 1527 if (index_head != 0)
1699 1528 {
1700   - vr_result *vrresult = new vr_result[index_head]{};
1701   - {
1702   - //TimeCounting t("VehicleRecognition_Process");
1703   - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult);
1704   - }
  1529 + vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{};
  1530 + VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult);
1705 1531  
1706 1532 int resIndex = 0;
1707 1533 for (auto & item : mp_head)
... ... @@ -1712,7 +1538,7 @@ bool snapshot_helper::vehicle_recg_analysis()
1712 1538 else
1713 1539 {
1714 1540 vehicle_result &curRes = vehicle_result_v[item.first];
1715   - memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result));
  1541 + memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vehicle_recog_result));
1716 1542 resIndex++;
1717 1543 }
1718 1544 }
... ... @@ -1721,12 +1547,8 @@ bool snapshot_helper::vehicle_recg_analysis()
1721 1547 }
1722 1548 if (index_rear != 0)
1723 1549 {
1724   - vr_result *vrresult = new vr_result[index_rear]{};
1725   -
1726   - {
1727   - //TimeCounting t("VehicleRearRecg_Process");
1728   - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult);
1729   - }
  1550 + vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{};
  1551 + VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult);
1730 1552  
1731 1553 int resIndex = 0;
1732 1554 for (auto & item : mp_rear)
... ... @@ -1738,7 +1560,7 @@ bool snapshot_helper::vehicle_recg_analysis()
1738 1560 else
1739 1561 {
1740 1562 vehicle_result &curRes = vehicle_result_v[item.first];
1741   - memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result));
  1563 + memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vehicle_rear_result));
1742 1564 resIndex++;
1743 1565 }
1744 1566 }
... ... @@ -1964,12 +1786,9 @@ void snapshot_helper::snapshot_res_callback(OBJ_KEY obj_key,/* OBJ_VALUE obj_val
1964 1786 finished_analysis_ss_info[obj_key] = newVideoObj;
1965 1787 }
1966 1788 }
1967   -#include <fstream>
  1789 +
1968 1790 void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key)
1969 1791 {
1970   - //std::ofstream os("D:\\vptlog1_2.txt", std::ofstream::out | std::ofstream::trunc);
1971   - //os << unitbuf;
1972   - //os << obj_key.videoID << " and " << obj_key.objID << endl;
1973 1792 bool image_unsave = false;
1974 1793 bool sna_unsave = false;
1975 1794 std::lock_guard<std::mutex> lock(threadMutex);
... ... @@ -1997,46 +1816,34 @@ void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key)
1997 1816 }
1998 1817 if (!sna_unsave)
1999 1818 {
2000   - //os << 1 << endl;
2001 1819 finished_save_ss_info.erase(obj_key);
2002 1820 char snapShotName[260] = {};
2003 1821 sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].snapshot_folder, obj_key.objID);
2004 1822 remove(snapShotName);
2005   - //os << snapShotName << endl;
2006 1823 }
2007 1824  
2008 1825 if (!image_unsave)
2009 1826 {
2010   - //os << 2 << endl;
2011 1827 char snapShotName[260] = {};
2012 1828 sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].image_folder, obj_key.objID);
2013 1829 remove(snapShotName);
2014   - //os << snapShotName << endl;
2015 1830 }
2016   - //os << 3 << endl;
2017 1831 }
2018 1832  
2019   -//SNAPSHOT_IMAGE_UNIT cur_image;
2020   -#ifndef _MSC_VER
2021   -#include <malloc.h>
2022   -#endif
2023   -
2024   -DWORD SnapshotImageWriteThreadProcess(LPVOID param)
  1833 +void snapshot_helper:: snapshot_imagewrite_thread_process()
2025 1834 {
2026   - snapshot_helper *pThreadParam = (snapshot_helper *)param;
2027   -
2028   - while (true)
  1835 + while (!m_bExit)
2029 1836 {
2030   - std::unique_lock<std::mutex> l(pThreadParam->threadMutex);
2031   - if (!pThreadParam->snapshotImageQueue.empty())
  1837 + std::unique_lock<std::mutex> l(threadMutex);
  1838 + if (!snapshotImageQueue.empty())
2032 1839 {
2033   - SNAPSHOT_IMAGE_UNIT cur_image = pThreadParam->snapshotImageQueue.front();
2034   - pThreadParam->snapshotImageQueue.pop();
  1840 + SNAPSHOT_IMAGE_UNIT cur_image = snapshotImageQueue.front();
  1841 + snapshotImageQueue.pop();
2035 1842 l.unlock();
2036 1843 vector<int> compression_params;
2037 1844 compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
2038 1845 //-------debug by zsh----------------------------------------------------
2039   - int jpeg_quality_ = pThreadParam->m_task_info[cur_image.obj_key.videoID].jpeg_quality_;
  1846 + int jpeg_quality_ = m_task_info[cur_image.obj_key.videoID].jpeg_quality_;
2040 1847 jpeg_quality_ = jpeg_quality_ > 0 ? jpeg_quality_ : 0;
2041 1848 jpeg_quality_ = jpeg_quality_ < 100 ? jpeg_quality_ : 100;
2042 1849 //cout << "jpeg_quality_:" << jpeg_quality_ << endl;
... ... @@ -2049,86 +1856,74 @@ DWORD SnapshotImageWriteThreadProcess(LPVOID param)
2049 1856 {
2050 1857 delete[]cur_image.image.data;
2051 1858 cur_image.image.data = NULL;
2052   -#ifndef _MSC_VER
2053   - malloc_trim(0);
2054   -#endif
2055 1859 }
2056 1860 image.release();
2057 1861 if (false == cur_image.is_image)
2058 1862 {
2059   - std::unique_lock<std::mutex> ll(pThreadParam->finishedThreadMutex);
2060   - pThreadParam->finished_save_ss_info_que.push(cur_image.obj_key);
  1863 + std::unique_lock<std::mutex> ll(finishedThreadMutex);
  1864 + finished_save_ss_info_que.push(cur_image.obj_key);
2061 1865 }
2062   -
2063 1866 }
2064 1867 else
2065 1868 {
2066 1869 l.unlock();
2067 1870 std::this_thread::sleep_for(std::chrono::milliseconds(10));
2068 1871 }
2069   -
2070 1872 }
2071   - return 0;
  1873 + return ;
2072 1874 }
2073 1875  
2074   -DWORD SnapshotThreadProcess(LPVOID param)
  1876 +void snapshot_helper::snapshot_thread_process()
2075 1877 {
2076   - snapshot_helper *pThreadParam = (snapshot_helper *)param;
2077   - //std::ofstream os("./vptlog1.txt", std::ofstream::out | std::ofstream::trunc);
2078   - //os << unitbuf;
2079   - //try
  1878 + while (!m_bExit)
2080 1879 {
2081   - while (true)
  1880 + std::unique_lock<std::mutex> l(finishedThreadMutex);
  1881 + while (!finished_save_ss_info_que.empty())
2082 1882 {
2083   - std::unique_lock<std::mutex> l(pThreadParam->finishedThreadMutex);
2084   - while (!pThreadParam->finished_save_ss_info_que.empty())
2085   - {
2086   - pThreadParam->finished_save_ss_info.insert(pThreadParam->finished_save_ss_info_que.front());
2087   - pThreadParam->finished_save_ss_info_que.pop();
2088   - }
2089   - l.unlock();
2090   - for (auto iter = pThreadParam->finished_save_ss_info.begin(); iter != pThreadParam->finished_save_ss_info.end();)
  1883 + finished_save_ss_info.insert(finished_save_ss_info_que.front());
  1884 + finished_save_ss_info_que.pop();
  1885 + }
  1886 + l.unlock();
  1887 + for (auto iter = finished_save_ss_info.begin(); iter != finished_save_ss_info.end();)
  1888 + {
  1889 + std::lock_guard<std::mutex> lock(analysisThreadMutex);
  1890 + auto iter_snapshot = finished_analysis_ss_info.find(*iter);
  1891 + if (iter_snapshot != finished_analysis_ss_info.end())
2091 1892 {
2092   - std::lock_guard<std::mutex> lock(pThreadParam->analysisThreadMutex);
2093   - if (pThreadParam->finished_analysis_ss_info.find(*iter) != pThreadParam->finished_analysis_ss_info.end())
  1893 + video_object_snapshot v_object_snapshot = finished_analysis_ss_info[*iter];
  1894 + if (m_task_info[iter->videoID].obj_callback != nullptr)
2094 1895 {
2095   - if (pThreadParam->m_task_info[iter->videoID].obj_callback != nullptr)
  1896 + //os << iter->videoID << " " << iter->objID << "; ";
  1897 + std::lock_guard<std::mutex> l(callback_tx);
  1898 + m_task_info[iter->videoID].obj_callback(&v_object_snapshot);
  1899 + }
  1900 +
  1901 + {
  1902 + if (v_object_snapshot.analysisRes != NULL)
2096 1903 {
2097   - //os << iter->videoID << " " << iter->objID << "; ";
2098   - std::lock_guard<std::mutex> l(pThreadParam->callback_tx);
2099   - pThreadParam->m_task_info[iter->videoID].obj_callback(&pThreadParam->finished_analysis_ss_info[*iter]);
  1904 + delete v_object_snapshot.analysisRes;
  1905 + v_object_snapshot.analysisRes = NULL;
2100 1906 }
2101 1907  
  1908 + if (v_object_snapshot.face_res != nullptr)
2102 1909 {
2103   - if (pThreadParam->finished_analysis_ss_info[*iter].analysisRes != NULL)
2104   - {
2105   - delete pThreadParam->finished_analysis_ss_info[*iter].analysisRes;
2106   - pThreadParam->finished_analysis_ss_info[*iter].analysisRes = NULL;
2107   - }
2108   -
2109   - if (pThreadParam->finished_analysis_ss_info[*iter].face_res != nullptr)
2110   - {
2111   - delete pThreadParam->finished_analysis_ss_info[*iter].face_res;
2112   - pThreadParam->finished_analysis_ss_info[*iter].face_res = nullptr;
2113   - }
2114   -
2115   - pThreadParam->finished_analysis_ss_info.erase(pThreadParam->finished_analysis_ss_info.find(*iter));
  1910 + delete v_object_snapshot.face_res;
  1911 + v_object_snapshot.face_res = nullptr;
2116 1912 }
2117   - iter = pThreadParam->finished_save_ss_info.erase(iter);
  1913 +
  1914 + finished_analysis_ss_info.erase(iter_snapshot);
2118 1915 }
2119   - else
2120   - iter++;
  1916 + iter = finished_save_ss_info.erase(iter);
2121 1917 }
2122   - boost::this_thread::sleep(boost::posix_time::milliseconds(10));
2123   -
  1918 + else
  1919 + iter++;
2124 1920 }
2125   - }
2126   - //catch (...)
2127   - {
2128   - std::cout << "Save Process Thread is Finished" << std::endl;
  1921 + std::this_thread::sleep_for(std::chrono::milliseconds(10));
2129 1922 }
2130 1923  
2131   - return 0;
  1924 + std::cout << "Save Process Thread is Finished" << std::endl;
  1925 +
  1926 + return ;
2132 1927 }
2133 1928  
2134 1929 int snapshot_helper::save_snapshot(bool is_image, bool on_image_display, OBJ_KEY obj_key, char* filename, char* mode, float* imgData, int width, int height, int taskID, int objID, int recFlag, int left = 0, int top = 0, int right = 0, int bottom = 0)
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h
... ... @@ -5,8 +5,9 @@
5 5 #include <string>
6 6 #include <set>
7 7 #include <unordered_map>
8   -#include <boost/thread/thread.hpp>
9 8 #include <mutex>
  9 +#include <vector>
  10 +#include <thread>
10 11 #include <condition_variable>
11 12 #include "ImageSaveCache.h"
12 13 using namespace std;
... ... @@ -200,7 +201,13 @@ private:
200 201 int hp_wait_count, hcp_wait_count, vehicle_wait_count;
201 202 int wait_framecount;
202 203  
203   - boost::thread ProcessSnapshotThread;
  204 + std::thread* ProcessSnapshotThread;
  205 + std::vector<std::thread*> m_vec_writeThread;
  206 + bool m_bExit {false};
  207 +
  208 +public:
  209 + void snapshot_thread_process();
  210 + void snapshot_imagewrite_thread_process();
204 211  
205 212 public:
206 213 std::mutex callback_tx;
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp
... ... @@ -13,7 +13,7 @@ int vhd_features_init(void *&amp;handle, char*dbpath, int gpuid, char* auth_license)
13 13 params.serialize_file = "./serialize_file/VPD";
14 14 params.thresld = 0.6;
15 15 params.auth_license = auth_license;
16   - if (vpd_init(&handle, params) !=0) {
  16 + if (vpd2_init(&handle, params) !=0) {
17 17 cout << "Init vhd Failed!" << endl;
18 18 return FAILED;
19 19 }
... ... @@ -43,20 +43,21 @@ int vf_features_init(void *&amp;handle, char*dbpath, int gpuid, char* auth_license)
43 43  
44 44  
45 45  
46   -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd_result*& result)
  46 +int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result)
47 47 {
48 48 for (int i = 0; i < batch_size; i++)
49 49 {
50 50 if (batch_img[i].data_ == NULL)
51 51 cout << i << " data null" << endl;
52 52 }
53   - vpd_process(handle, batch_img, batch_size, result);
  53 + vpd2_process(handle, batch_img, batch_size, result);
54 54  
55 55 for (int b = 0; b < batch_size; b++)
56 56 {
57 57 for (int c = 0; c < result[b].count; c++)
58 58 {
59   - RectboundCheck(batch_img[b].w_, batch_img[b].h_, result[b].vpd_res[c].rect.left_, result[b].vpd_res[c].rect.top_, result[b].vpd_res[c].rect.width_, result[b].vpd_res[c].rect.height_);
  59 + sy_rect rect = result[b].vpd_res[c].rect;
  60 + RectboundCheck(batch_img[b].w_, batch_img[b].h_, rect.left_, rect.top_, rect.width_, rect.height_);
60 61 }
61 62 }
62 63  
... ... @@ -113,7 +114,7 @@ int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8
113 114 int vhd_feature_release(void *& handle)
114 115 {
115 116 if (handle)
116   - vpd_release(&handle);
  117 + vpd2_release(&handle);
117 118 return SUCCESS;
118 119 }
119 120  
... ... @@ -130,7 +131,7 @@ void RectboundCheck(int Width, int Height, int &amp;left, int &amp;top, int &amp;width, int
130 131 #ifdef _DEBUG
131 132 printf("img: Width = %d Height = %d\n",
132 133 Width, Height);
133   - printf("Src: width = %d height = %d, x = %d, y =%d\n", width, height, left, top);
  134 + printf("Src: width = %d height = %d, x = %d, y =%d\n", Width, Height, left, top);
134 135 #endif
135 136 if (left <= 0)
136 137 left = 0;
... ... @@ -152,9 +153,6 @@ void RectboundCheck(int Width, int Height, int &amp;left, int &amp;top, int &amp;width, int
152 153 height = Height - 1 - top;
153 154 if (height <= 0)
154 155 height = 0;
155   -#ifdef _DEBUG
156   - printf("Dst: width = %d, height = %d, x = %d, y =%d\n", width, height, left, top);
157   -#endif
158 156 }
159 157  
160 158  
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h
... ... @@ -2,7 +2,7 @@
2 2  
3 3 #ifndef _VEHICLEFEATURES_H_
4 4 #define _VEHICLEFEATURES_H_
5   -#include "vf.h"
  5 +#include "vehicle_fea_int8.h"
6 6 #include "vpd.h"
7 7  
8 8 #ifndef __INT8__
... ... @@ -14,7 +14,7 @@ int vhd_features_init(void *&amp;handle, char*dbpath, int gpuid, char* auth_license)
14 14  
15 15 int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license);
16 16  
17   -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd_result*& result);
  17 +int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result);
18 18  
19 19 int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8**& result);
20 20  
... ...
vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp
... ... @@ -725,7 +725,7 @@ int main(int argc, char* argv[])
725 725 // vptParam.hf_recg_config = SY_CONFIG_CLOSE;
726 726 // vptParam.hcf_recg_config = SY_CONFIG_CLOSE;
727 727 // vptParam.vcf_recg_config = SY_CONFIG_CLOSE;
728   - // vptParam.face_det_config = SY_CONFIG_CLOSE;
  728 + vptParam.face_det_config = SY_CONFIG_CLOSE;
729 729  
730 730 vptParam.hp_analysis_config = SY_CONFIG_OPEN;
731 731 vptParam.hcp_analysis_config = SY_CONFIG_OPEN;
... ... @@ -733,7 +733,7 @@ int main(int argc, char* argv[])
733 733 vptParam.hf_recg_config = SY_CONFIG_OPEN;
734 734 vptParam.hcf_recg_config = SY_CONFIG_OPEN;
735 735 vptParam.vcf_recg_config = SY_CONFIG_OPEN;
736   - vptParam.face_det_config = SY_CONFIG_OPEN;
  736 + // vptParam.face_det_config = SY_CONFIG_OPEN;
737 737  
738 738 vptParam.vrdbpath = argv[4];
739 739 //vptParam.vrdbpath = "../../db/mvpt.bin";
... ... @@ -764,30 +764,25 @@ int main(int argc, char* argv[])
764 764 continue;
765 765 }
766 766  
767   - create_task("/home/cmhu/data/video/bayue.mp4", total_index++);
  767 + // create_task("/home/cmhu/data/video/bayue.mp4", total_index++);
768 768  
769   - create_task("/home/cmhu/data/video/duan1.avi", total_index++);
  769 + // create_task("/home/cmhu/data/video/duan1.avi", total_index++);
770 770  
771   - create_task("/home/cmhu/data/video/Street.uvf", total_index++);
  771 + // create_task("/home/cmhu/data/video/Street.uvf", total_index++);
772 772  
773   - create_task("/home/cmhu/data/video/1.mp4", total_index++);
  773 + // create_task("/home/cmhu/data/video/1.mp4", total_index++);
774 774  
775   - create_task("/home/cmhu/data/video/720.avi", total_index++);
  775 + // create_task("/home/cmhu/data/video/720.avi", total_index++);
776 776  
777   - create_task("/home/cmhu/data/video/face1.mp4", total_index++);
  777 + // create_task("/home/cmhu/data/video/face1.mp4", total_index++);
778 778  
779   - // for (int i = 0; i < addTaskCount; i++) {
  779 + for (int i = 0; i < addTaskCount; i++) {
780 780  
781   - // create_task(videoFileName, total_index);
  781 + create_task(videoFileName, total_index);
782 782  
783   - // total_index++ ;
  783 + total_index++ ;
784 784  
785   - // #ifdef _MSC_VER
786   - // Sleep(2000);
787   - // #else
788   - // usleep(40000);
789   - // #endif
790   - // }
  785 + }
791 786 } while(0) ;
792 787  
793 788 printf("-------------------Begin rt_view_task 1 !----------------------\n");
... ...