Commit 922efde74e8bb441dbf38fe529248e911762c2c7
1 parent
99b91853
子库全部重新编译
Showing
21 changed files
with
339 additions
and
561 deletions
.vscode/launch.json
@@ -73,6 +73,24 @@ | @@ -73,6 +73,24 @@ | ||
73 | "ignoreFailures": true | 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 | \ No newline at end of file | 97 | \ No newline at end of file |
.vscode/settings.json
@@ -60,7 +60,25 @@ | @@ -60,7 +60,25 @@ | ||
60 | "utility": "cpp", | 60 | "utility": "cpp", |
61 | "typeindex": "cpp", | 61 | "typeindex": "cpp", |
62 | "typeinfo": "cpp", | 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 | "git.ignoreLimitWarning": true | 83 | "git.ignoreLimitWarning": true |
66 | } | 84 | } |
67 | \ No newline at end of file | 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,11 +25,10 @@ SPDLOG_ROOT = $(DEPEND_DIR)/spdlog-1.9.2/release | ||
25 | 25 | ||
26 | TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so | 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 | -I $(OPENCV_ROOT)/include/opencv4/opencv2 \ | 32 | -I $(OPENCV_ROOT)/include/opencv4/opencv2 \ |
34 | -I $(UTOOLS_SSD_ROOT) \ | 33 | -I $(UTOOLS_SSD_ROOT) \ |
35 | -I $(SRC_ROOT) \ | 34 | -I $(SRC_ROOT) \ |
@@ -41,7 +40,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ | @@ -41,7 +40,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ | ||
41 | -I $(HIDE_MODEL_TRT) \ | 40 | -I $(HIDE_MODEL_TRT) \ |
42 | -I $(AUTHORITY_DIR) \ | 41 | -I $(AUTHORITY_DIR) \ |
43 | -I $(FFMPEG_ROOT)/include \ | 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 | -I $(SPDLOG_ROOT)/include \ | 53 | -I $(SPDLOG_ROOT)/include \ |
46 | -I $(FFNVDECODER_ROOT) \ | 54 | -I $(FFNVDECODER_ROOT) \ |
47 | -I $(FFNVDECODER_ROOT)/common/inc \ | 55 | -I $(FFNVDECODER_ROOT)/common/inc \ |
@@ -50,14 +58,13 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ | @@ -50,14 +58,13 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ | ||
50 | 58 | ||
51 | LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ | 59 | LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ |
52 | -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ | 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 | -L$(UTOOLS_SSD_ROOT) -l:libutools.so \ | 63 | -L$(UTOOLS_SSD_ROOT) -l:libutools.so \ |
56 | -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \ | 64 | -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \ |
57 | -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | 65 | -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ |
58 | -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ | 66 | -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ |
59 | -L$(AUTHORITY_DIR) -l:libauthority.a \ | 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 | -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ | 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,10 +32,6 @@ DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg ) | ||
32 | m_name = cfg->name; | 32 | m_name = cfg->name; |
33 | m_decMode = cfg->decMode; | 33 | m_decMode = cfg->decMode; |
34 | 34 | ||
35 | - CUdevice cuDevice; | ||
36 | - cuDeviceGet(&cuDevice, cfg->devId); | ||
37 | - cuCtxCreate(&m_cuda_cxt, 0, cuDevice); | ||
38 | - | ||
39 | return; | 35 | return; |
40 | } | 36 | } |
41 | 37 | ||
@@ -107,9 +103,6 @@ int DxDecoderWrap::DxCloseDecoder() | @@ -107,9 +103,6 @@ int DxDecoderWrap::DxCloseDecoder() | ||
107 | cudaFree(m_pHwData); | 103 | cudaFree(m_pHwData); |
108 | } | 104 | } |
109 | 105 | ||
110 | - cuCtxPopCurrent(nullptr); | ||
111 | - cuCtxDestroy(m_cuda_cxt); | ||
112 | - | ||
113 | return 0; | 106 | return 0; |
114 | } | 107 | } |
115 | 108 | ||
@@ -190,20 +183,16 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) | @@ -190,20 +183,16 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) | ||
190 | AVFrame* gpuFrame = decodedFrame->gpuFrame; | 183 | AVFrame* gpuFrame = decodedFrame->gpuFrame; |
191 | 184 | ||
192 | cudaSetDevice(atoi(m_cfg.gpuid.c_str())); | 185 | cudaSetDevice(atoi(m_cfg.gpuid.c_str())); |
193 | - cuCtxPushCurrent(m_cuda_cxt); | ||
194 | cudaError_t cudaStatus; | 186 | cudaError_t cudaStatus; |
195 | size_t rgbSize = 3 * gpuFrame->width * gpuFrame->height * sizeof(unsigned char); | 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 | cuda_common::setColorSpace( ITU_709, 0 ); | 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 | if (cudaStatus != cudaSuccess) { | 196 | if (cudaStatus != cudaSuccess) { |
208 | LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str()); | 197 | LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str()); |
209 | return -1; | 198 | return -1; |
@@ -211,8 +200,8 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) | @@ -211,8 +200,8 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) | ||
211 | 200 | ||
212 | frame->width = gpuFrame->width; | 201 | frame->width = gpuFrame->width; |
213 | frame->height = gpuFrame->height; | 202 | frame->height = gpuFrame->height; |
214 | - frame->size = rgbSize; | ||
215 | - frame->frame = m_pHwData; | 203 | + frame->size = gpuFrame->width; |
204 | + frame->frame = pHwData; | ||
216 | frame->timestamp = decodedFrame->ts; | 205 | frame->timestamp = decodedFrame->ts; |
217 | 206 | ||
218 | delete decodedFrame; | 207 | delete decodedFrame; |
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp
@@ -199,6 +199,7 @@ void FFNvDecoder::decode_thread() | @@ -199,6 +199,7 @@ void FFNvDecoder::decode_thread() | ||
199 | // long start_time = get_cur_time(); | 199 | // long start_time = get_cur_time(); |
200 | 200 | ||
201 | unsigned long long index = 0; | 201 | unsigned long long index = 0; |
202 | + unsigned long long decoded_frame_count = 0; | ||
202 | while (m_bRunning) | 203 | while (m_bRunning) |
203 | { | 204 | { |
204 | if (!m_bReal) | 205 | if (!m_bReal) |
@@ -262,6 +263,8 @@ void FFNvDecoder::decode_thread() | @@ -262,6 +263,8 @@ void FFNvDecoder::decode_thread() | ||
262 | } | 263 | } |
263 | av_packet_unref(pkt); | 264 | av_packet_unref(pkt); |
264 | 265 | ||
266 | + decoded_frame_count++; | ||
267 | + | ||
265 | if(gpuFrame != nullptr){ | 268 | if(gpuFrame != nullptr){ |
266 | m_queue_mutex.lock(); | 269 | m_queue_mutex.lock(); |
267 | if(mFrameQueue.size() <= 10){ | 270 | if(mFrameQueue.size() <= 10){ |
@@ -290,8 +293,6 @@ void FFNvDecoder::decode_thread() | @@ -290,8 +293,6 @@ void FFNvDecoder::decode_thread() | ||
290 | 293 | ||
291 | decode_finished_cbk(m_finishedDecArg); | 294 | decode_finished_cbk(m_finishedDecArg); |
292 | 295 | ||
293 | - decode_finished(); | ||
294 | - | ||
295 | // 清空队列 | 296 | // 清空队列 |
296 | while(mFrameQueue.size() > 0){ | 297 | while(mFrameQueue.size() > 0){ |
297 | GPUFrame * frame = mFrameQueue.front(); | 298 | GPUFrame * frame = mFrameQueue.front(); |
@@ -300,7 +301,9 @@ void FFNvDecoder::decode_thread() | @@ -300,7 +301,9 @@ void FFNvDecoder::decode_thread() | ||
300 | mFrameQueue.pop(); | 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 | void FFNvDecoder::decode_finished(){ | 309 | void FFNvDecoder::decode_finished(){ |
@@ -325,6 +328,7 @@ void FFNvDecoder::post_decode_thread(){ | @@ -325,6 +328,7 @@ void FFNvDecoder::post_decode_thread(){ | ||
325 | } | 328 | } |
326 | 329 | ||
327 | unsigned long long index = 0; | 330 | unsigned long long index = 0; |
331 | + int frame_count = 0; | ||
328 | while (m_bRunning) | 332 | while (m_bRunning) |
329 | { | 333 | { |
330 | std::this_thread::sleep_for(std::chrono::milliseconds(2)); //给m_snapshot_mutex的喘息时间,避免截图一直截不到。避免线程资源占用。 | 334 | std::this_thread::sleep_for(std::chrono::milliseconds(2)); //给m_snapshot_mutex的喘息时间,避免截图一直截不到。避免线程资源占用。 |
@@ -338,6 +342,7 @@ void FFNvDecoder::post_decode_thread(){ | @@ -338,6 +342,7 @@ void FFNvDecoder::post_decode_thread(){ | ||
338 | // 跳帧 | 342 | // 跳帧 |
339 | if (skip_frame == 1 || index % skip_frame == 0){ | 343 | if (skip_frame == 1 || index % skip_frame == 0){ |
340 | post_decoded_cbk(m_postDecArg, frame); | 344 | post_decoded_cbk(m_postDecArg, frame); |
345 | + frame_count++; | ||
341 | } | 346 | } |
342 | 347 | ||
343 | // av_frame_free(&gpuFrame); | 348 | // av_frame_free(&gpuFrame); |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | #include <fstream> | 8 | #include <fstream> |
9 | #include <algorithm> | 9 | #include <algorithm> |
10 | #include <thread> | 10 | #include <thread> |
11 | +#include <chrono> | ||
11 | #include <future> | 12 | #include <future> |
12 | 13 | ||
13 | #include "../FFNvDecoder/logger.hpp" | 14 | #include "../FFNvDecoder/logger.hpp" |
@@ -25,7 +26,6 @@ | @@ -25,7 +26,6 @@ | ||
25 | #define AUTHORIZATION | 26 | #define AUTHORIZATION |
26 | //#define DQ_AUTHORIZATION | 27 | //#define DQ_AUTHORIZATION |
27 | 28 | ||
28 | -#include<boost/thread.hpp> | ||
29 | 29 | ||
30 | #ifdef DQ_AUTHORIZATION | 30 | #ifdef DQ_AUTHORIZATION |
31 | #include "license_validator.h" | 31 | #include "license_validator.h" |
@@ -201,12 +201,12 @@ int CMutliSourceVideoProcess::FinishProcessThread() | @@ -201,12 +201,12 @@ int CMutliSourceVideoProcess::FinishProcessThread() | ||
201 | { | 201 | { |
202 | if (thrd_status == 0) | 202 | if (thrd_status == 0) |
203 | { | 203 | { |
204 | - thrd.interrupt(); | 204 | + m_bExit = true; |
205 | thrd.join(); | 205 | thrd.join(); |
206 | thrd_status = -1; | 206 | thrd_status = -1; |
207 | } | 207 | } |
208 | 208 | ||
209 | - ProcessThread.interrupt(); //interrupt thread | 209 | + m_bProcessExit = true; |
210 | ProcessThread.join(); //waiting thread finish | 210 | ProcessThread.join(); //waiting thread finish |
211 | 211 | ||
212 | VPT_Release(VPT_Handle); | 212 | VPT_Release(VPT_Handle); |
@@ -252,7 +252,8 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN | @@ -252,7 +252,8 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN | ||
252 | char wtime[15]; | 252 | char wtime[15]; |
253 | memset(wtime, 0, 15); | 253 | memset(wtime, 0, 15); |
254 | char * time = wtime; | 254 | char * time = wtime; |
255 | - if (SUCCESS == (ret = sy_licence(productSN, &time))) | 255 | + ret = sy_licence(productSN, &time); |
256 | + if (SUCCESS == ret) | ||
256 | #endif | 257 | #endif |
257 | #else | 258 | #else |
258 | ret = license_check(vptParam.auth_license, productSN);// sy_time_check(2022, 2); | 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,8 +349,9 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN | ||
348 | if (ret == SUCCESS) //�ɹ� | 349 | if (ret == SUCCESS) //�ɹ� |
349 | { | 350 | { |
350 | licence_status = 0; | 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 | #endif | 355 | #endif |
354 | thrd_status = 0; | 356 | thrd_status = 0; |
355 | } | 357 | } |
@@ -374,8 +376,6 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN | @@ -374,8 +376,6 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN | ||
374 | 376 | ||
375 | void CMutliSourceVideoProcess::FinishDecode(const int taskID) | 377 | void CMutliSourceVideoProcess::FinishDecode(const int taskID) |
376 | { | 378 | { |
377 | - boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(400)); | ||
378 | - | ||
379 | for (int i = 0; i < tasks.size(); i++) | 379 | for (int i = 0; i < tasks.size(); i++) |
380 | { | 380 | { |
381 | if (tasks[i].taskID == taskID && tasks[taskID].taskTcuvid != NULL) | 381 | if (tasks[i].taskID == taskID && tasks[taskID].taskTcuvid != NULL) |
@@ -404,7 +404,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) | @@ -404,7 +404,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) | ||
404 | tasks[i].taskObjCallbackFunc = nullptr; | 404 | tasks[i].taskObjCallbackFunc = nullptr; |
405 | tasks[i].taskRealTimeCallbackFunc = nullptr; | 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 | if (tasks[i].folderName) | 409 | if (tasks[i].folderName) |
410 | { | 410 | { |
@@ -542,7 +542,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | @@ -542,7 +542,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | ||
542 | int height = 0; | 542 | int height = 0; |
543 | new_task.taskTcuvid->DxGetResolution(width, height); | 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 | new_task.frameImage = cv::Mat::zeros(height, width, CV_8UC3); | 547 | new_task.frameImage = cv::Mat::zeros(height, width, CV_8UC3); |
548 | new_task.taskState = PLAY; | 548 | new_task.taskState = PLAY; |
@@ -634,7 +634,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | @@ -634,7 +634,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | ||
634 | AddTaskTracker(VPT_Handle, new_task.taskID, width, height); | 634 | AddTaskTracker(VPT_Handle, new_task.taskID, width, height); |
635 | 635 | ||
636 | if (!ProcessFlag) { | 636 | if (!ProcessFlag) { |
637 | - ProcessThread = boost::thread(ThreadProcess, this); | 637 | + m_bProcessExit = false; |
638 | + ProcessThread = std::thread(ThreadProcess, this); | ||
638 | ProcessFlag = true; | 639 | ProcessFlag = true; |
639 | } | 640 | } |
640 | 641 | ||
@@ -645,12 +646,10 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | @@ -645,12 +646,10 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh | ||
645 | 646 | ||
646 | int CMutliSourceVideoProcess::AddOperator(task_param tparam) | 647 | int CMutliSourceVideoProcess::AddOperator(task_param tparam) |
647 | { | 648 | { |
648 | - //boost::mutex::scoped_lock lock(process_thread_mutex); | ||
649 | - | ||
650 | if (!ProcessFlag) | 649 | if (!ProcessFlag) |
651 | { | 650 | { |
652 | AddTask(tparam); | 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 | else | 654 | else |
656 | { | 655 | { |
@@ -673,7 +672,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) | @@ -673,7 +672,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) | ||
673 | memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); | 672 | memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); |
674 | TaskOperatorQ.push_back(newOper); | 673 | TaskOperatorQ.push_back(newOper); |
675 | taskCondVar.wait_for(l, std::chrono::seconds(20)); | 674 | taskCondVar.wait_for(l, std::chrono::seconds(20)); |
676 | - // printf("finish first task in operator queue\n"); | ||
677 | } | 675 | } |
678 | 676 | ||
679 | int addRes = -1; | 677 | int addRes = -1; |
@@ -895,7 +893,7 @@ DWORD ThreadProcess(LPVOID param) | @@ -895,7 +893,7 @@ DWORD ThreadProcess(LPVOID param) | ||
895 | long long last_time = get_cur_time_ms(); | 893 | long long last_time = get_cur_time_ms(); |
896 | 894 | ||
897 | { | 895 | { |
898 | - while (1) | 896 | + while (!pThreadParam->m_bProcessExit) |
899 | { | 897 | { |
900 | if (pThreadParam->licence_status <= -3) | 898 | if (pThreadParam->licence_status <= -3) |
901 | { | 899 | { |
@@ -1037,7 +1035,7 @@ DWORD ThreadProcess(LPVOID param) | @@ -1037,7 +1035,7 @@ DWORD ThreadProcess(LPVOID param) | ||
1037 | //��û�л�ȡ������·���Ľ������� ѭ���ȴ� | 1035 | //��û�л�ȡ������·���Ľ������� ѭ���ȴ� |
1038 | if (k.size() < curPlayTaskCount) | 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 | goto getdata_flag; | 1039 | goto getdata_flag; |
1042 | } | 1040 | } |
1043 | 1041 | ||
@@ -1704,6 +1702,11 @@ DWORD ThreadProcess(LPVOID param) | @@ -1704,6 +1702,11 @@ DWORD ThreadProcess(LPVOID param) | ||
1704 | task_iter++; | 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 | for (int i = 0; i < deleteObjectID.size(); i++) | 1710 | for (int i = 0; i < deleteObjectID.size(); i++) |
1708 | vector<int>().swap(deleteObjectID[i]); | 1711 | vector<int>().swap(deleteObjectID[i]); |
1709 | vector<vector<int>>().swap(deleteObjectID); | 1712 | vector<vector<int>>().swap(deleteObjectID); |
@@ -1720,7 +1723,7 @@ DWORD ThreadProcess(LPVOID param) | @@ -1720,7 +1723,7 @@ DWORD ThreadProcess(LPVOID param) | ||
1720 | LOG_ERROR("object_attri_analysis last error: {}", cudaGetErrorString(cudaStatus)); | 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 | ++total_count; | 1728 | ++total_count; |
1726 | ++ncount; | 1729 | ++ncount; |
@@ -1739,8 +1742,7 @@ DWORD ThreadProcess(LPVOID param) | @@ -1739,8 +1742,7 @@ DWORD ThreadProcess(LPVOID param) | ||
1739 | exit(-1);*/ | 1742 | exit(-1);*/ |
1740 | } | 1743 | } |
1741 | long long costTime1 = get_cur_time_ms() - begintime1; | 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 | pThreadParam->m_snaphot_helper.snapShotInfo.clear(); | 1747 | pThreadParam->m_snaphot_helper.snapShotInfo.clear(); |
1746 | pThreadParam->ProcessFlag = false; | 1748 | pThreadParam->ProcessFlag = false; |
@@ -1780,7 +1782,7 @@ void check_thread(void* handle) | @@ -1780,7 +1782,7 @@ void check_thread(void* handle) | ||
1780 | 1782 | ||
1781 | CMutliSourceVideoProcess *pThreadParam = (CMutliSourceVideoProcess *)handle; | 1783 | CMutliSourceVideoProcess *pThreadParam = (CMutliSourceVideoProcess *)handle; |
1782 | 1784 | ||
1783 | - while (1) | 1785 | + while (!pThreadParam->m_bExit) |
1784 | { | 1786 | { |
1785 | //printf("xxx check status on process...\n"); | 1787 | //printf("xxx check status on process...\n"); |
1786 | #ifdef _MSC_VER | 1788 | #ifdef _MSC_VER |
@@ -1792,6 +1794,7 @@ void check_thread(void* handle) | @@ -1792,6 +1794,7 @@ void check_thread(void* handle) | ||
1792 | if (res < 0) | 1794 | if (res < 0) |
1793 | { | 1795 | { |
1794 | pThreadParam->licence_status = pThreadParam->licence_status - 1; | 1796 | pThreadParam->licence_status = pThreadParam->licence_status - 1; |
1797 | + printf("CMutliSourceVideoProcess licence error, ret: %d \n", res); | ||
1795 | } | 1798 | } |
1796 | else | 1799 | else |
1797 | { | 1800 | { |
@@ -1800,7 +1803,7 @@ void check_thread(void* handle) | @@ -1800,7 +1803,7 @@ void check_thread(void* handle) | ||
1800 | pThreadParam->licence_status = 0; | 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 | #endif | 1809 | #endif |
1807 | \ No newline at end of file | 1810 | \ No newline at end of file |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp
@@ -11,7 +11,6 @@ | @@ -11,7 +11,6 @@ | ||
11 | #include <time.h> | 11 | #include <time.h> |
12 | #include "ErrorInfo.h" | 12 | #include "ErrorInfo.h" |
13 | #include "fstream" | 13 | #include "fstream" |
14 | -#include <boost/thread/thread.hpp> | ||
15 | 14 | ||
16 | 15 | ||
17 | 16 | ||
@@ -41,8 +40,7 @@ typedef struct objDetector { | @@ -41,8 +40,7 @@ typedef struct objDetector { | ||
41 | // VPT_FPNPluginFactory tensorrt_plugin_factory; | 40 | // VPT_FPNPluginFactory tensorrt_plugin_factory; |
42 | 41 | ||
43 | int licence_status = -1; | 42 | int licence_status = -1; |
44 | - int thrd_status = -1; | ||
45 | - boost::thread thrd; | 43 | + int thrd_status = -1; |
46 | vector<TaskTracker> taskTrackers; | 44 | vector<TaskTracker> taskTrackers; |
47 | objDetector() | 45 | objDetector() |
48 | { | 46 | { |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp
1 | #include "VehiclePlate.h" | 1 | #include "VehiclePlate.h" |
2 | #include <cuda_runtime.h> | 2 | #include <cuda_runtime.h> |
3 | + | ||
4 | +#include "../../FFNvDecoder/logger.hpp" | ||
3 | //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", "��", "ѧ", "ʹ", "��" }; | 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 | int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license) | 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 | param.max_batch = 20; | 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 | vpr_param rparam; | 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 | int ret = vpdr_init(&handle, param, rparam); | 22 | int ret = vpdr_init(&handle, param, rparam); |
20 | 23 | ||
21 | - | ||
22 | if (ret != 0) | 24 | if (ret != 0) |
23 | { | 25 | { |
24 | - cout << "Init platedr Failed!" << endl; | 26 | + cout << "vpdr_init Failed!" << endl; |
25 | return FAILED; | 27 | return FAILED; |
26 | } | 28 | } |
27 | - | ||
28 | 29 | ||
29 | return SUCCESS; | 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 | sy_img cpu_batch_img[batchsize]; | 35 | sy_img cpu_batch_img[batchsize]; |
45 | for (int i = 0; i < batchsize; i++) | 36 | for (int i = 0; i < batchsize; i++) |
46 | { | 37 | { |
47 | if (batch_img[i].data_ == NULL) | 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 | cpu_batch_img[i].data_ = (unsigned char *)malloc(batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char)); | 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 | 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); | 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,7 +47,17 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc | ||
55 | cpu_batch_img[i].c_ = batch_img[i].c_; | 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 | int index_count = vpdr_batch(handle, cpu_batch_img, batchsize, all_result); | 59 | int index_count = vpdr_batch(handle, cpu_batch_img, batchsize, all_result); |
60 | + cudaDeviceSynchronize(); | ||
59 | 61 | ||
60 | for (int b = 0; b < batchsize; b++) | 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,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 | for (int i = 0; i < batchsize; i++) { | 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 | if (all_result != NULL) | 90 | if (all_result != NULL) |
@@ -91,7 +95,9 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc | @@ -91,7 +95,9 @@ int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batc | ||
91 | 95 | ||
92 | int VehiclePlateDetectRecog_Release(void *& handle) | 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 | return SUCCESS; | 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 | #pragma once | 2 | #pragma once |
5 | #include "opencv2/highgui/highgui.hpp" | 3 | #include "opencv2/highgui/highgui.hpp" |
6 | #include <iostream> | 4 | #include <iostream> |
7 | #include "utools.h" | 5 | #include "utools.h" |
8 | #include <vector> | 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 | int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license); | 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 | int VehiclePlateDetectRecog_Release(void *& handle); | 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 *&handle, char*dbpath, int gpuid, char* auth_licen | @@ -5,29 +5,22 @@ int VehicleRearRecg_Init(void *&handle, char*dbpath, int gpuid, char* auth_licen | ||
5 | vrr_param params; | 5 | vrr_param params; |
6 | params.gpuid = gpuid; | 6 | params.gpuid = gpuid; |
7 | params.mode = DEVICE_GPU; | 7 | params.mode = DEVICE_GPU; |
8 | - //printf("ERROR PATH\n"); | ||
9 | - params.db_path = dbpath;//"../../db/mvpt.bin"; | 8 | + params.db_path = dbpath; |
10 | params.engine = ENGINE_TENSORRT; | 9 | params.engine = ENGINE_TENSORRT; |
11 | params.max_batch = 20; | 10 | params.max_batch = 20; |
12 | params.serialize_file = "./serialize_file/VRR"; | 11 | params.serialize_file = "./serialize_file/VRR"; |
13 | params.auth_license = auth_license; | 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 | int ret = vrr_init(&handle, params); | 14 | int ret = vrr_init(&handle, params); |
22 | if (ret != 0) | 15 | if (ret != 0) |
23 | { | 16 | { |
24 | cout << "VRR Init Failed!" << endl; | 17 | cout << "VRR Init Failed!" << endl; |
25 | - system("pause"); | ||
26 | return FAILED; | 18 | return FAILED; |
27 | } | 19 | } |
20 | + | ||
28 | return SUCCESS; | 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 | for (int i = 0; i < batchsize; i++) | 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,7 +30,6 @@ int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr | ||
37 | 30 | ||
38 | vrr_batch(handle, batch_img, batchsize, vr_result); | 31 | vrr_batch(handle, batch_img, batchsize, vr_result); |
39 | 32 | ||
40 | - | ||
41 | return SUCCESS; | 33 | return SUCCESS; |
42 | } | 34 | } |
43 | int VehicleRearRecg_Release(void *& handle) | 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,5 +9,5 @@ using namespace std; | ||
9 | 9 | ||
10 | 10 | ||
11 | int VehicleRearRecg_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); | 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 | int VehicleRearRecg_Release(void *& handle); | 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,87 +6,33 @@ using namespace std; | ||
6 | int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license) | 6 | int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license) |
7 | { | 7 | { |
8 | vr_param params; | 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 | params.engine = ENGINE_TENSORRT; | 11 | params.engine = ENGINE_TENSORRT; |
14 | params.max_batch = 20; | 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 | int ret = vr_init(&handle, params); | 18 | int ret = vr_init(&handle, params); |
23 | if (ret != 0) | 19 | if (ret != 0) |
24 | { | 20 | { |
25 | cout << "VR Init Failed!" << endl; | 21 | cout << "VR Init Failed!" << endl; |
26 | - system("pause"); | ||
27 | return FAILED; | 22 | return FAILED; |
28 | } | 23 | } |
29 | return SUCCESS; | 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 | for (int i = 0; i < batchsize; i++) | 29 | for (int i = 0; i < batchsize; i++) |
45 | { | 30 | { |
46 | if (batch_img[i].data_ == NULL) | 31 | if (batch_img[i].data_ == NULL) |
47 | cout << i << " data null" << endl; | 32 | cout << i << " data null" << endl; |
48 | } | 33 | } |
49 | 34 | ||
50 | - //cout << "begin vr_batch" << endl; | ||
51 | vr_batch(handle, batch_img, batchsize, vrresult); | 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 | return SUCCESS; | 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,5 +11,5 @@ using namespace std; | ||
11 | 11 | ||
12 | 12 | ||
13 | int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); | 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 | int VehicleRecognition_Release(void *& handle); | 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 | #include <iostream> | 3 | #include <iostream> |
3 | int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) | 4 | int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) |
4 | { | 5 | { |
@@ -11,7 +12,7 @@ int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) | @@ -11,7 +12,7 @@ int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) | ||
11 | fea_param.thres = 0.6; | 12 | fea_param.thres = 0.6; |
12 | fea_param.engine = ENGINE_TENSORRT; | 13 | fea_param.engine = ENGINE_TENSORRT; |
13 | 14 | ||
14 | - //δÉúЧ | 15 | + //δ��Ч |
15 | fea_param.max_batch = 20; | 16 | fea_param.max_batch = 20; |
16 | fea_param.serialize_file = "./serialize_file/HF"; | 17 | fea_param.serialize_file = "./serialize_file/HF"; |
17 | fea_param.auth_license = auth_license; | 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
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp
1 | #include "opencv2/opencv.hpp" | 1 | #include "opencv2/opencv.hpp" |
2 | #include "opencv2/highgui/highgui.hpp" | 2 | #include "opencv2/highgui/highgui.hpp" |
3 | #include "snapshot_helper.h" | 3 | #include "snapshot_helper.h" |
4 | -#include <vector> | ||
5 | -#include <thread> | ||
6 | #include "HumanParsing.h" | 4 | #include "HumanParsing.h" |
7 | #include "HumanCarParsing.h" | 5 | #include "HumanCarParsing.h" |
8 | #include "VehiclePlate.h" | 6 | #include "VehiclePlate.h" |
9 | #include "VehicleRecognition.h" | 7 | #include "VehicleRecognition.h" |
10 | #include "VehicleColor.h" | 8 | #include "VehicleColor.h" |
11 | -#include "non_vehicle_fea_trt.h" | 9 | +#include "non_vehicle_fea.h" |
12 | //#include "HumanFeatures.h" | 10 | //#include "HumanFeatures.h" |
13 | #include "vehicle_features.h" | 11 | #include "vehicle_features.h" |
14 | #include "VehicleRearRecg.h" | 12 | #include "VehicleRearRecg.h" |
@@ -16,12 +14,14 @@ | @@ -16,12 +14,14 @@ | ||
16 | 14 | ||
17 | #include <chrono> | 15 | #include <chrono> |
18 | 16 | ||
17 | +#include "../FFNvDecoder/logger.hpp" | ||
18 | + | ||
19 | using namespace std; | 19 | using namespace std; |
20 | 20 | ||
21 | string ObjTypes[9] = { "行人", "自行车", "摩托车", "三轮车", "小型车", "大车", "卡车", "拖拉机", "中巴" }; | 21 | string ObjTypes[9] = { "行人", "自行车", "摩托车", "三轮车", "小型车", "大车", "卡车", "拖拉机", "中巴" }; |
22 | string ObjTypesEnglish[9] = { "person", "bike", "motor", "tricycle", "car", "bigbus", "lorry", "tractor", "midibus" }; | 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 | #ifdef _MSC_VER | 25 | #ifdef _MSC_VER |
26 | char* GbkToUtf8(const char *src_str) | 26 | char* GbkToUtf8(const char *src_str) |
27 | { | 27 | { |
@@ -74,10 +74,22 @@ private: | @@ -74,10 +74,22 @@ private: | ||
74 | long end_time{ 0 }; | 74 | long end_time{ 0 }; |
75 | char* opt_name; | 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 | 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, \ | 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 | 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) | 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,37 +162,18 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c | ||
150 | batch_vehicle = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{}; | 162 | batch_vehicle = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{}; |
151 | batch_vehicle_vf = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{}; | 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 | void snapshot_helper::snapshot_helper_release() | 174 | void snapshot_helper::snapshot_helper_release() |
183 | { | 175 | { |
176 | + m_bExit = true; | ||
184 | HumanParsing_Release(hp_handle); | 177 | HumanParsing_Release(hp_handle); |
185 | HumanCarParsing_Release(hcp_handle); | 178 | HumanCarParsing_Release(hcp_handle); |
186 | VehicleColor_Release(vc_handle); | 179 | VehicleColor_Release(vc_handle); |
@@ -229,8 +222,11 @@ void snapshot_helper::snapshot_helper_release() | @@ -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,14 +258,15 @@ int snapshot_helper::save_face_snapshot(OBJ_KEY obj_key) | ||
262 | 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, | 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 | 0, 0, obj_value.snapShotFace.width, obj_value.snapShotFace.height); | 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 | cudaFree(obj_value.snapShotFace.frame); | 267 | cudaFree(obj_value.snapShotFace.frame); |
266 | obj_value.snapShotFace.frame = nullptr; | 268 | obj_value.snapShotFace.frame = nullptr; |
267 | obj_value.snapShotFace.height = -1; //表示有人脸检测到 存过人脸快照图 用于确定最终是否返回人脸快照保存位置 | 269 | obj_value.snapShotFace.height = -1; //表示有人脸检测到 存过人脸快照图 用于确定最终是否返回人脸快照保存位置 |
268 | - if (tempSnapShotFaceHost) | ||
269 | - { | ||
270 | - delete[] tempSnapShotFaceHost; | ||
271 | - tempSnapShotFaceHost = NULL; | ||
272 | - } | ||
273 | } | 270 | } |
274 | 271 | ||
275 | return 0; | 272 | return 0; |
@@ -468,7 +465,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | @@ -468,7 +465,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | ||
468 | { | 465 | { |
469 | vector<OBJ_KEY> hp_keys; | 466 | vector<OBJ_KEY> hp_keys; |
470 | vector<OBJ_KEY> hcp_keys; | 467 | vector<OBJ_KEY> hcp_keys; |
471 | - vector<OBJ_KEY> vehicle_keys; | 468 | + queue<OBJ_KEY> vehicle_keys; |
472 | vector<OBJ_KEY> vehicle_else; //仅保存的 | 469 | vector<OBJ_KEY> vehicle_else; //仅保存的 |
473 | 470 | ||
474 | for (auto iter = snapShotInfo.begin(); iter != snapShotInfo.end(); iter++) | 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,7 +480,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | ||
483 | hcp_keys.push_back(iter->first); | 480 | hcp_keys.push_back(iter->first); |
484 | 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 | 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 | && iter->second.snapShotLittle.frame != NULL && iter->second.snapShotLittle.height == VEHICLE_HEIGHT && iter->second.snapShotLittle.width == VEHICLE_WIDTH) | 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 | else | 484 | else |
488 | vehicle_else.push_back(iter->first); | 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,98 +696,80 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | ||
699 | 696 | ||
700 | if (!vehicle_keys.empty()) | 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 | finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); | 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 | int8 ** fea = nullptr; | 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 | fea[ii] = new int8[FEATURESIZE]{}; | 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 | int feaIndex = 0; | 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 | vehicle_result curRes = {}; | 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 | int count_vehicle_size = count_vehicle_v.size(); | 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 | else | 764 | else |
786 | { | 765 | { |
787 | - ++iter; | 766 | + ++iter_v; |
788 | } | 767 | } |
789 | } | 768 | } |
790 | 769 | ||
791 | if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里 | 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 | if (iter->second.snapShotLittle.frame) | 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,7 +787,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | ||
808 | 787 | ||
809 | if (fea != nullptr) | 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 | delete[] fea[ii]; | 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,8 +811,6 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi | ||
832 | delete[] vrresult; | 811 | delete[] vrresult; |
833 | vrresult = NULL; | 812 | vrresult = NULL; |
834 | } | 813 | } |
835 | - | ||
836 | - vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count); | ||
837 | } | 814 | } |
838 | 815 | ||
839 | v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS; | 816 | v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS; |
@@ -862,21 +839,6 @@ void snapshot_helper::hp_analysis() | @@ -862,21 +839,6 @@ void snapshot_helper::hp_analysis() | ||
862 | //if (count_person.size() >= OBJ_BATCH_COUNT) | 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 | //选择前N个做行人属性分析 | 842 | //选择前N个做行人属性分析 |
881 | const int OBJ_BATCH_COUNT_bk = OBJ_BATCH_COUNT; | 843 | const int OBJ_BATCH_COUNT_bk = OBJ_BATCH_COUNT; |
882 | const int OBJ_SCALE_COUNT_bk = OBJ_SCALE; | 844 | const int OBJ_SCALE_COUNT_bk = OBJ_SCALE; |
@@ -933,19 +895,6 @@ void snapshot_helper::hp_analysis() | @@ -933,19 +895,6 @@ void snapshot_helper::hp_analysis() | ||
933 | //TimeCounting t("NonVehicleFea_Process"); | 895 | //TimeCounting t("NonVehicleFea_Process"); |
934 | NonVehicleFea_Process(nvf_handle, batch_hp, obj_batch_count, result_f); | 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 | int resIndex = 0; | 900 | int resIndex = 0; |
@@ -986,20 +935,6 @@ void snapshot_helper::hp_analysis() | @@ -986,20 +935,6 @@ void snapshot_helper::hp_analysis() | ||
986 | delete[] result_f; | 935 | delete[] result_f; |
987 | result_f = nullptr; | 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 | OBJ_BATCH_COUNT = OBJ_BATCH_COUNT_bk; | 940 | OBJ_BATCH_COUNT = OBJ_BATCH_COUNT_bk; |
@@ -1027,20 +962,6 @@ void snapshot_helper::hcp_analysis() | @@ -1027,20 +962,6 @@ void snapshot_helper::hcp_analysis() | ||
1027 | { | 962 | { |
1028 | vector<OBJ_KEY> erase_obj_key; | 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 | int obj_batch_count = 0; | 965 | int obj_batch_count = 0; |
1045 | hcp_analysis_result *result = nullptr; | 966 | hcp_analysis_result *result = nullptr; |
1046 | human_fea_result * result_f = nullptr; | 967 | human_fea_result * result_f = nullptr; |
@@ -1088,21 +1009,6 @@ void snapshot_helper::hcp_analysis() | @@ -1088,21 +1009,6 @@ void snapshot_helper::hcp_analysis() | ||
1088 | NonVehicleFea_Process(nvf_handle, batch_hcp, obj_batch_count, result_f); | 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 | int resIndex = 0; | 1012 | int resIndex = 0; |
1107 | for (auto iter_key : erase_obj_key) | 1013 | for (auto iter_key : erase_obj_key) |
1108 | { | 1014 | { |
@@ -1173,20 +1079,6 @@ bool snapshot_helper::vehicle_color_analysis() | @@ -1173,20 +1079,6 @@ bool snapshot_helper::vehicle_color_analysis() | ||
1173 | 1079 | ||
1174 | for (int index = 0; index < OBJ_SCALE; ++index) | 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 | int start_idx = cur_iter_count * index; | 1082 | int start_idx = cur_iter_count * index; |
1191 | 1083 | ||
1192 | int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; | 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,21 +1116,6 @@ bool snapshot_helper::vehicle_color_analysis() | ||
1224 | //TimeCounting t("VehicleColor_Process"); | 1116 | //TimeCounting t("VehicleColor_Process"); |
1225 | VehicleColor_Process(vc_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vcresult); | 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 | for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) | 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,21 +1164,6 @@ bool snapshot_helper::vehicle_plate_dr_analysis() | ||
1287 | 1164 | ||
1288 | for (int index = 0; index < OBJ_SCALE; ++index) | 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 | int start_idx = cur_iter_count * index; | 1167 | int start_idx = cur_iter_count * index; |
1306 | int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; | 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,26 +1193,8 @@ bool snapshot_helper::vehicle_plate_dr_analysis() | ||
1331 | } | 1193 | } |
1332 | batch_vehicle[i].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); | 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 | int resIndex = 0; | 1199 | int resIndex = 0; |
1356 | for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) | 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,7 +1207,7 @@ bool snapshot_helper::vehicle_plate_dr_analysis() | ||
1363 | { | 1207 | { |
1364 | vehicle_result &curRes = vehicle_result_v[i + start_idx]; | 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 | resIndex++; | 1211 | resIndex++; |
1368 | } | 1212 | } |
1369 | } | 1213 | } |
@@ -1392,13 +1236,17 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | @@ -1392,13 +1236,17 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | ||
1392 | sy_img * batch_vehicle_head = new sy_img[batchsize]{}; | 1236 | sy_img * batch_vehicle_head = new sy_img[batchsize]{}; |
1393 | sy_img * batch_vehicle_rear = new sy_img[batchsize]{}; | 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 | vhd_features_process(vhd_handle, batch_img, batchsize, vhd_res); | 1244 | vhd_features_process(vhd_handle, batch_img, batchsize, vhd_res); |
1397 | 1245 | ||
1398 | for (int vc_idx = 0; vc_idx < batchsize; vc_idx++) | 1246 | for (int vc_idx = 0; vc_idx < batchsize; vc_idx++) |
1399 | { | 1247 | { |
1400 | OBJ_KEY cur_obj_key = obj_keys[vc_idx]; | 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 | if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 | 1251 | if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 |
1404 | { | 1252 | { |
@@ -1472,18 +1320,15 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | @@ -1472,18 +1320,15 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | ||
1472 | 1320 | ||
1473 | if (index_head != 0) | 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 | int resIndex = 0; | 1328 | int resIndex = 0; |
1483 | for (auto & item : mp_head) | 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 | resIndex++; | 1332 | resIndex++; |
1488 | } | 1333 | } |
1489 | delete[] vrresult; | 1334 | delete[] vrresult; |
@@ -1492,18 +1337,13 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | @@ -1492,18 +1337,13 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr | ||
1492 | 1337 | ||
1493 | if (index_rear != 0) | 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 | int resIndex = 0; | 1343 | int resIndex = 0; |
1503 | for (auto & item : mp_rear) | 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 | resIndex++; | 1347 | resIndex++; |
1508 | } | 1348 | } |
1509 | delete[] vrresult; | 1349 | delete[] vrresult; |
@@ -1561,21 +1401,6 @@ bool snapshot_helper::vehicle_recg_analysis() | @@ -1561,21 +1401,6 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1561 | // OBJ_BATCH_COUNT_VEHICLE, OBJ_SCALE, cur_iter_count); | 1401 | // OBJ_BATCH_COUNT_VEHICLE, OBJ_SCALE, cur_iter_count); |
1562 | for (int index = 0; index < OBJ_SCALE; ++index) | 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 | int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; | 1404 | int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; |
1580 | 1405 | ||
1581 | for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) | 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,13 +1441,17 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1616 | sy_img * batch_vehicle_head = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; | 1441 | sy_img * batch_vehicle_head = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; |
1617 | sy_img * batch_vehicle_rear = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; | 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 | vhd_features_process(vhd_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res); | 1449 | vhd_features_process(vhd_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res); |
1621 | 1450 | ||
1622 | for (int vc_idx = 0; vc_idx < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; vc_idx++) | 1451 | for (int vc_idx = 0; vc_idx < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; vc_idx++) |
1623 | { | 1452 | { |
1624 | OBJ_KEY cur_obj_key = count_vehicle_v[vc_idx]; | 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 | if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 | 1456 | if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 |
1628 | { | 1457 | { |
@@ -1697,11 +1526,8 @@ bool snapshot_helper::vehicle_recg_analysis() | @@ -1697,11 +1526,8 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1697 | 1526 | ||
1698 | if (index_head != 0) | 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 | int resIndex = 0; | 1532 | int resIndex = 0; |
1707 | for (auto & item : mp_head) | 1533 | for (auto & item : mp_head) |
@@ -1712,7 +1538,7 @@ bool snapshot_helper::vehicle_recg_analysis() | @@ -1712,7 +1538,7 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1712 | else | 1538 | else |
1713 | { | 1539 | { |
1714 | vehicle_result &curRes = vehicle_result_v[item.first]; | 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 | resIndex++; | 1542 | resIndex++; |
1717 | } | 1543 | } |
1718 | } | 1544 | } |
@@ -1721,12 +1547,8 @@ bool snapshot_helper::vehicle_recg_analysis() | @@ -1721,12 +1547,8 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1721 | } | 1547 | } |
1722 | if (index_rear != 0) | 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 | int resIndex = 0; | 1553 | int resIndex = 0; |
1732 | for (auto & item : mp_rear) | 1554 | for (auto & item : mp_rear) |
@@ -1738,7 +1560,7 @@ bool snapshot_helper::vehicle_recg_analysis() | @@ -1738,7 +1560,7 @@ bool snapshot_helper::vehicle_recg_analysis() | ||
1738 | else | 1560 | else |
1739 | { | 1561 | { |
1740 | vehicle_result &curRes = vehicle_result_v[item.first]; | 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 | resIndex++; | 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,12 +1786,9 @@ void snapshot_helper::snapshot_res_callback(OBJ_KEY obj_key,/* OBJ_VALUE obj_val | ||
1964 | finished_analysis_ss_info[obj_key] = newVideoObj; | 1786 | finished_analysis_ss_info[obj_key] = newVideoObj; |
1965 | } | 1787 | } |
1966 | } | 1788 | } |
1967 | -#include <fstream> | 1789 | + |
1968 | void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key) | 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 | bool image_unsave = false; | 1792 | bool image_unsave = false; |
1974 | bool sna_unsave = false; | 1793 | bool sna_unsave = false; |
1975 | std::lock_guard<std::mutex> lock(threadMutex); | 1794 | std::lock_guard<std::mutex> lock(threadMutex); |
@@ -1997,46 +1816,34 @@ void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key) | @@ -1997,46 +1816,34 @@ void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key) | ||
1997 | } | 1816 | } |
1998 | if (!sna_unsave) | 1817 | if (!sna_unsave) |
1999 | { | 1818 | { |
2000 | - //os << 1 << endl; | ||
2001 | finished_save_ss_info.erase(obj_key); | 1819 | finished_save_ss_info.erase(obj_key); |
2002 | char snapShotName[260] = {}; | 1820 | char snapShotName[260] = {}; |
2003 | sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].snapshot_folder, obj_key.objID); | 1821 | sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].snapshot_folder, obj_key.objID); |
2004 | remove(snapShotName); | 1822 | remove(snapShotName); |
2005 | - //os << snapShotName << endl; | ||
2006 | } | 1823 | } |
2007 | 1824 | ||
2008 | if (!image_unsave) | 1825 | if (!image_unsave) |
2009 | { | 1826 | { |
2010 | - //os << 2 << endl; | ||
2011 | char snapShotName[260] = {}; | 1827 | char snapShotName[260] = {}; |
2012 | sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].image_folder, obj_key.objID); | 1828 | sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].image_folder, obj_key.objID); |
2013 | remove(snapShotName); | 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 | l.unlock(); | 1842 | l.unlock(); |
2036 | vector<int> compression_params; | 1843 | vector<int> compression_params; |
2037 | compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); | 1844 | compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); |
2038 | //-------debug by zsh---------------------------------------------------- | 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 | jpeg_quality_ = jpeg_quality_ > 0 ? jpeg_quality_ : 0; | 1847 | jpeg_quality_ = jpeg_quality_ > 0 ? jpeg_quality_ : 0; |
2041 | jpeg_quality_ = jpeg_quality_ < 100 ? jpeg_quality_ : 100; | 1848 | jpeg_quality_ = jpeg_quality_ < 100 ? jpeg_quality_ : 100; |
2042 | //cout << "jpeg_quality_:" << jpeg_quality_ << endl; | 1849 | //cout << "jpeg_quality_:" << jpeg_quality_ << endl; |
@@ -2049,86 +1856,74 @@ DWORD SnapshotImageWriteThreadProcess(LPVOID param) | @@ -2049,86 +1856,74 @@ DWORD SnapshotImageWriteThreadProcess(LPVOID param) | ||
2049 | { | 1856 | { |
2050 | delete[]cur_image.image.data; | 1857 | delete[]cur_image.image.data; |
2051 | cur_image.image.data = NULL; | 1858 | cur_image.image.data = NULL; |
2052 | -#ifndef _MSC_VER | ||
2053 | - malloc_trim(0); | ||
2054 | -#endif | ||
2055 | } | 1859 | } |
2056 | image.release(); | 1860 | image.release(); |
2057 | if (false == cur_image.is_image) | 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 | else | 1867 | else |
2065 | { | 1868 | { |
2066 | l.unlock(); | 1869 | l.unlock(); |
2067 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); | 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 | 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) | 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,8 +5,9 @@ | ||
5 | #include <string> | 5 | #include <string> |
6 | #include <set> | 6 | #include <set> |
7 | #include <unordered_map> | 7 | #include <unordered_map> |
8 | -#include <boost/thread/thread.hpp> | ||
9 | #include <mutex> | 8 | #include <mutex> |
9 | +#include <vector> | ||
10 | +#include <thread> | ||
10 | #include <condition_variable> | 11 | #include <condition_variable> |
11 | #include "ImageSaveCache.h" | 12 | #include "ImageSaveCache.h" |
12 | using namespace std; | 13 | using namespace std; |
@@ -200,7 +201,13 @@ private: | @@ -200,7 +201,13 @@ private: | ||
200 | int hp_wait_count, hcp_wait_count, vehicle_wait_count; | 201 | int hp_wait_count, hcp_wait_count, vehicle_wait_count; |
201 | int wait_framecount; | 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 | public: | 212 | public: |
206 | std::mutex callback_tx; | 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 *&handle, char*dbpath, int gpuid, char* auth_license) | @@ -13,7 +13,7 @@ int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) | ||
13 | params.serialize_file = "./serialize_file/VPD"; | 13 | params.serialize_file = "./serialize_file/VPD"; |
14 | params.thresld = 0.6; | 14 | params.thresld = 0.6; |
15 | params.auth_license = auth_license; | 15 | params.auth_license = auth_license; |
16 | - if (vpd_init(&handle, params) !=0) { | 16 | + if (vpd2_init(&handle, params) !=0) { |
17 | cout << "Init vhd Failed!" << endl; | 17 | cout << "Init vhd Failed!" << endl; |
18 | return FAILED; | 18 | return FAILED; |
19 | } | 19 | } |
@@ -43,20 +43,21 @@ int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) | @@ -43,20 +43,21 @@ int vf_features_init(void *&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 | for (int i = 0; i < batch_size; i++) | 48 | for (int i = 0; i < batch_size; i++) |
49 | { | 49 | { |
50 | if (batch_img[i].data_ == NULL) | 50 | if (batch_img[i].data_ == NULL) |
51 | cout << i << " data null" << endl; | 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 | for (int b = 0; b < batch_size; b++) | 55 | for (int b = 0; b < batch_size; b++) |
56 | { | 56 | { |
57 | for (int c = 0; c < result[b].count; c++) | 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,7 +114,7 @@ int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8 | ||
113 | int vhd_feature_release(void *& handle) | 114 | int vhd_feature_release(void *& handle) |
114 | { | 115 | { |
115 | if (handle) | 116 | if (handle) |
116 | - vpd_release(&handle); | 117 | + vpd2_release(&handle); |
117 | return SUCCESS; | 118 | return SUCCESS; |
118 | } | 119 | } |
119 | 120 | ||
@@ -130,7 +131,7 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int | @@ -130,7 +131,7 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int | ||
130 | #ifdef _DEBUG | 131 | #ifdef _DEBUG |
131 | printf("img: Width = %d Height = %d\n", | 132 | printf("img: Width = %d Height = %d\n", |
132 | Width, Height); | 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 | #endif | 135 | #endif |
135 | if (left <= 0) | 136 | if (left <= 0) |
136 | left = 0; | 137 | left = 0; |
@@ -152,9 +153,6 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int | @@ -152,9 +153,6 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int | ||
152 | height = Height - 1 - top; | 153 | height = Height - 1 - top; |
153 | if (height <= 0) | 154 | if (height <= 0) |
154 | height = 0; | 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,7 +2,7 @@ | ||
2 | 2 | ||
3 | #ifndef _VEHICLEFEATURES_H_ | 3 | #ifndef _VEHICLEFEATURES_H_ |
4 | #define _VEHICLEFEATURES_H_ | 4 | #define _VEHICLEFEATURES_H_ |
5 | -#include "vf.h" | 5 | +#include "vehicle_fea_int8.h" |
6 | #include "vpd.h" | 6 | #include "vpd.h" |
7 | 7 | ||
8 | #ifndef __INT8__ | 8 | #ifndef __INT8__ |
@@ -14,7 +14,7 @@ int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) | @@ -14,7 +14,7 @@ int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) | ||
14 | 14 | ||
15 | int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license); | 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 | int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8**& result); | 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,7 +725,7 @@ int main(int argc, char* argv[]) | ||
725 | // vptParam.hf_recg_config = SY_CONFIG_CLOSE; | 725 | // vptParam.hf_recg_config = SY_CONFIG_CLOSE; |
726 | // vptParam.hcf_recg_config = SY_CONFIG_CLOSE; | 726 | // vptParam.hcf_recg_config = SY_CONFIG_CLOSE; |
727 | // vptParam.vcf_recg_config = SY_CONFIG_CLOSE; | 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 | vptParam.hp_analysis_config = SY_CONFIG_OPEN; | 730 | vptParam.hp_analysis_config = SY_CONFIG_OPEN; |
731 | vptParam.hcp_analysis_config = SY_CONFIG_OPEN; | 731 | vptParam.hcp_analysis_config = SY_CONFIG_OPEN; |
@@ -733,7 +733,7 @@ int main(int argc, char* argv[]) | @@ -733,7 +733,7 @@ int main(int argc, char* argv[]) | ||
733 | vptParam.hf_recg_config = SY_CONFIG_OPEN; | 733 | vptParam.hf_recg_config = SY_CONFIG_OPEN; |
734 | vptParam.hcf_recg_config = SY_CONFIG_OPEN; | 734 | vptParam.hcf_recg_config = SY_CONFIG_OPEN; |
735 | vptParam.vcf_recg_config = SY_CONFIG_OPEN; | 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 | vptParam.vrdbpath = argv[4]; | 738 | vptParam.vrdbpath = argv[4]; |
739 | //vptParam.vrdbpath = "../../db/mvpt.bin"; | 739 | //vptParam.vrdbpath = "../../db/mvpt.bin"; |
@@ -764,30 +764,25 @@ int main(int argc, char* argv[]) | @@ -764,30 +764,25 @@ int main(int argc, char* argv[]) | ||
764 | continue; | 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 | } while(0) ; | 786 | } while(0) ; |
792 | 787 | ||
793 | printf("-------------------Begin rt_view_task 1 !----------------------\n"); | 788 | printf("-------------------Begin rt_view_task 1 !----------------------\n"); |