From 922efde74e8bb441dbf38fe529248e911762c2c7 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Wed, 1 Nov 2023 15:48:30 +0800 Subject: [PATCH] 子库全部重新编译 --- .vscode/launch.json | 18 ++++++++++++++++++ .vscode/settings.json | 20 +++++++++++++++++++- vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile | 23 +++++++++++++++-------- vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp | 27 ++++++++------------------- vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h | 1 - vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp | 11 ++++++++--- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp | 47 +++++++++++++++++++++++++---------------------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp | 4 +--- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp | 62 ++++++++++++++++++++++++++++++++++---------------------------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.h | 9 +++++---- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.cpp | 14 +++----------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h | 2 +- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp | 70 ++++++++-------------------------------------------------------------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h | 2 +- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h | 7 +++++++ vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp | 45 --------------------------------------------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h | 7 ------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp | 523 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h | 11 +++++++++-- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp | 16 +++++++--------- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h | 4 ++-- vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp | 29 ++++++++++++----------------- 23 files changed, 388 insertions(+), 610 deletions(-) create mode 100644 vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp create mode 100644 vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h delete mode 100644 vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp delete mode 100644 vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h diff --git a/.vscode/launch.json b/.vscode/launch.json index 1469354..e5211d5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -73,6 +73,24 @@ "ignoreFailures": true } ] + },{ + "name": "vpdr_test", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512/vpdr_test", + "args": ["file:///home/cmhu/data/video/Street.uvf?fastdecode=on","6","0","./db/mvpt.bin"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index d1ecee5..b216077 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -60,7 +60,25 @@ "utility": "cpp", "typeindex": "cpp", "typeinfo": "cpp", - "valarray": "cpp" + "valarray": "cpp", + "bit": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "concepts": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "algorithm": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "optional": "cpp", + "random": "cpp", + "string_view": "cpp", + "numbers": "cpp", + "semaphore": "cpp", + "stop_token": "cpp", + "variant": "cpp" }, "git.ignoreLimitWarning": true } \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile b/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile index bc88b66..233b5d6 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile +++ b/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile @@ -25,11 +25,10 @@ SPDLOG_ROOT = $(DEPEND_DIR)/spdlog-1.9.2/release TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so -DEFS=-DOS_LINUX -DLOG_INFO2 +# DEFS=-DOS_LINUX -DLOG_INFO2 +DEFS=-DOS_LINUX -INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ - -I $(DEPEND_DIR)/include \ - -I $(OPENCV_ROOT)/include/opencv4 \ +INCLUDE= -I $(OPENCV_ROOT)/include/opencv4 \ -I $(OPENCV_ROOT)/include/opencv4/opencv2 \ -I $(UTOOLS_SSD_ROOT) \ -I $(SRC_ROOT) \ @@ -41,7 +40,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ -I $(HIDE_MODEL_TRT) \ -I $(AUTHORITY_DIR) \ -I $(FFMPEG_ROOT)/include \ - -I $(SDK_ROOT)/face_detect2/face_detect \ + -I $(SDK_ROOT)/face_detect/face_detect \ + -I $(SDK_ROOT)/human_car_parsing_trt/src/human_car_parsing \ + -I $(SDK_ROOT)/human_parsing_trt/src/human_parsing \ + -I $(SDK_ROOT)/non_vehicle_fea_trt/src/non_vehicle_fea_trt \ + -I $(SDK_ROOT)/vehicle_color_trt/src/vehicle_color \ + -I $(SDK_ROOT)/vehicle_fea_int8/vehicle_fea_int8 \ + -I $(SDK_ROOT)/vehicle_plate_dr/vehicle_plate_dr \ + -I $(SDK_ROOT)/vehicle_rear_recognition/src/vehicle_rear_recognition \ + -I $(SDK_ROOT)/vehicle_recognize \ + -I $(SDK_ROOT)/vpd2/vpd2 \ -I $(SPDLOG_ROOT)/include \ -I $(FFNVDECODER_ROOT) \ -I $(FFNVDECODER_ROOT)/common/inc \ @@ -50,14 +58,13 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \ - -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\ + -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler \ + -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 \ -L$(UTOOLS_SSD_ROOT) -l:libutools.so \ -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \ -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ -L$(AUTHORITY_DIR) -l:libauthority.a \ - -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \ -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp index c255685..88ff6f3 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp @@ -32,10 +32,6 @@ DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg ) m_name = cfg->name; m_decMode = cfg->decMode; - CUdevice cuDevice; - cuDeviceGet(&cuDevice, cfg->devId); - cuCtxCreate(&m_cuda_cxt, 0, cuDevice); - return; } @@ -107,9 +103,6 @@ int DxDecoderWrap::DxCloseDecoder() cudaFree(m_pHwData); } - cuCtxPopCurrent(nullptr); - cuCtxDestroy(m_cuda_cxt); - return 0; } @@ -190,20 +183,16 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) AVFrame* gpuFrame = decodedFrame->gpuFrame; cudaSetDevice(atoi(m_cfg.gpuid.c_str())); - cuCtxPushCurrent(m_cuda_cxt); cudaError_t cudaStatus; size_t rgbSize = 3 * gpuFrame->width * gpuFrame->height * sizeof(unsigned char); - if(m_pHwData == nullptr){ - cudaStatus = cudaMalloc((void **)&m_pHwData, rgbSize); - if (cudaStatus != cudaSuccess) { - LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str()); - cuCtxPopCurrent(&m_cuda_cxt); - return -1; - } + unsigned char *pHwData = nullptr; + cudaStatus = cudaMalloc((void **)&pHwData, rgbSize); + if (cudaStatus != cudaSuccess) { + LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str()); + return -1; } cuda_common::setColorSpace( ITU_709, 0 ); - cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], m_pHwData, gpuFrame->width, gpuFrame->height); - cuCtxPopCurrent(&m_cuda_cxt); + cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], pHwData, gpuFrame->width, gpuFrame->height); if (cudaStatus != cudaSuccess) { LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str()); return -1; @@ -211,8 +200,8 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) frame->width = gpuFrame->width; frame->height = gpuFrame->height; - frame->size = rgbSize; - frame->frame = m_pHwData; + frame->size = gpuFrame->width; + frame->frame = pHwData; frame->timestamp = decodedFrame->ts; delete decodedFrame; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h index d033bd5..bf39fb7 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h @@ -80,7 +80,6 @@ private: std::mutex m_queue_frames_mutex; unsigned char *m_pHwData {nullptr}; - CUcontext m_cuda_cxt; int m_decMode{0}; }; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp index d28a45e..c70cfd2 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp @@ -199,6 +199,7 @@ void FFNvDecoder::decode_thread() // long start_time = get_cur_time(); unsigned long long index = 0; + unsigned long long decoded_frame_count = 0; while (m_bRunning) { if (!m_bReal) @@ -262,6 +263,8 @@ void FFNvDecoder::decode_thread() } av_packet_unref(pkt); + decoded_frame_count++; + if(gpuFrame != nullptr){ m_queue_mutex.lock(); if(mFrameQueue.size() <= 10){ @@ -290,8 +293,6 @@ void FFNvDecoder::decode_thread() decode_finished_cbk(m_finishedDecArg); - decode_finished(); - // 清空队列 while(mFrameQueue.size() > 0){ GPUFrame * frame = mFrameQueue.front(); @@ -300,7 +301,9 @@ void FFNvDecoder::decode_thread() mFrameQueue.pop(); } - LOG_INFO("[{}] - decode thread exited.", m_dec_name); + decode_finished(); + + LOG_INFO("[{}] - decode thread exited, decoded frame count: {}", m_dec_name, decoded_frame_count); } void FFNvDecoder::decode_finished(){ @@ -325,6 +328,7 @@ void FFNvDecoder::post_decode_thread(){ } unsigned long long index = 0; + int frame_count = 0; while (m_bRunning) { std::this_thread::sleep_for(std::chrono::milliseconds(2)); //给m_snapshot_mutex的喘息时间,避免截图一直截不到。避免线程资源占用。 @@ -338,6 +342,7 @@ void FFNvDecoder::post_decode_thread(){ // 跳帧 if (skip_frame == 1 || index % skip_frame == 0){ post_decoded_cbk(m_postDecArg, frame); + frame_count++; } // av_frame_free(&gpuFrame); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp index de6ec07..20e1ab8 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "../FFNvDecoder/logger.hpp" @@ -25,7 +26,6 @@ #define AUTHORIZATION //#define DQ_AUTHORIZATION -#include #ifdef DQ_AUTHORIZATION #include "license_validator.h" @@ -201,12 +201,12 @@ int CMutliSourceVideoProcess::FinishProcessThread() { if (thrd_status == 0) { - thrd.interrupt(); + m_bExit = true; thrd.join(); thrd_status = -1; } - ProcessThread.interrupt(); //interrupt thread + m_bProcessExit = true; ProcessThread.join(); //waiting thread finish VPT_Release(VPT_Handle); @@ -252,7 +252,8 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN char wtime[15]; memset(wtime, 0, 15); char * time = wtime; - if (SUCCESS == (ret = sy_licence(productSN, &time))) + ret = sy_licence(productSN, &time); + if (SUCCESS == ret) #endif #else 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 if (ret == SUCCESS) //�ɹ� { licence_status = 0; -#ifdef AUTHORIZATION - thrd = boost::thread(check_thread, this); +#ifdef AUTHORIZATION + m_bExit = false; + thrd = std::thread(check_thread, this); #endif thrd_status = 0; } @@ -374,8 +376,6 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN void CMutliSourceVideoProcess::FinishDecode(const int taskID) { - boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(400)); - for (int i = 0; i < tasks.size(); i++) { if (tasks[i].taskID == taskID && tasks[taskID].taskTcuvid != NULL) @@ -404,7 +404,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) tasks[i].taskObjCallbackFunc = nullptr; tasks[i].taskRealTimeCallbackFunc = nullptr; - 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); //�Ƿ�����������ʶ��); + 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); if (tasks[i].folderName) { @@ -542,7 +542,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh int height = 0; new_task.taskTcuvid->DxGetResolution(width, height); - LOG_INFO("[{}] - finish add codec. w:{} h:{} total_frame:", cfg.name.c_str(), width, height, total_frame); + LOG_INFO("[{}] - finish add codec. w:{} h:{} total_frame:{}", cfg.name.c_str(), width, height, total_frame); new_task.frameImage = cv::Mat::zeros(height, width, CV_8UC3); new_task.taskState = PLAY; @@ -634,7 +634,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh AddTaskTracker(VPT_Handle, new_task.taskID, width, height); if (!ProcessFlag) { - ProcessThread = boost::thread(ThreadProcess, this); + m_bProcessExit = false; + ProcessThread = std::thread(ThreadProcess, this); ProcessFlag = true; } @@ -645,12 +646,10 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh int CMutliSourceVideoProcess::AddOperator(task_param tparam) { - //boost::mutex::scoped_lock lock(process_thread_mutex); - if (!ProcessFlag) { AddTask(tparam); - boost::thread::sleep(boost::get_system_time() + boost::posix_time::microseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); } else { @@ -673,7 +672,6 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); TaskOperatorQ.push_back(newOper); taskCondVar.wait_for(l, std::chrono::seconds(20)); - // printf("finish first task in operator queue\n"); } int addRes = -1; @@ -895,7 +893,7 @@ DWORD ThreadProcess(LPVOID param) long long last_time = get_cur_time_ms(); { - while (1) + while (!pThreadParam->m_bProcessExit) { if (pThreadParam->licence_status <= -3) { @@ -1037,7 +1035,7 @@ DWORD ThreadProcess(LPVOID param) //��û�л�ȡ������·���Ľ������� ѭ���ȴ� if (k.size() < curPlayTaskCount) { - boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); goto getdata_flag; } @@ -1704,6 +1702,11 @@ DWORD ThreadProcess(LPVOID param) task_iter++; } + for (auto task_id: pThreadParam->TaskinPlayID) { + cudaFree(pThreadParam->tasks[task_id].task_algorithm_data.frame); + } + + for (int i = 0; i < deleteObjectID.size(); i++) vector().swap(deleteObjectID[i]); vector>().swap(deleteObjectID); @@ -1720,7 +1723,7 @@ DWORD ThreadProcess(LPVOID param) LOG_ERROR("object_attri_analysis last error: {}", cudaGetErrorString(cudaStatus)); } - boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); ++total_count; ++ncount; @@ -1739,8 +1742,7 @@ DWORD ThreadProcess(LPVOID param) exit(-1);*/ } long long costTime1 = get_cur_time_ms() - begintime1; - std::cout << "==================== Process Thread is Finished: " << std::endl; - printf("total frame cost time = %lld us, process times: %d total_count: %d \n", costTime1, process_times, total_count); + LOG_INFO("Process Thread is Finished. total frame cost time = {} ms, process times: {}", costTime1, process_times); pThreadParam->m_snaphot_helper.snapShotInfo.clear(); pThreadParam->ProcessFlag = false; @@ -1780,7 +1782,7 @@ void check_thread(void* handle) CMutliSourceVideoProcess *pThreadParam = (CMutliSourceVideoProcess *)handle; - while (1) + while (!pThreadParam->m_bExit) { //printf("xxx check status on process...\n"); #ifdef _MSC_VER @@ -1792,6 +1794,7 @@ void check_thread(void* handle) if (res < 0) { pThreadParam->licence_status = pThreadParam->licence_status - 1; + printf("CMutliSourceVideoProcess licence error, ret: %d \n", res); } else { @@ -1800,7 +1803,7 @@ void check_thread(void* handle) pThreadParam->licence_status = 0; } } - boost::this_thread::sleep(boost::posix_time::seconds(300)); //5min + std::this_thread::sleep_for(std::chrono::seconds(300)); } } #endif \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp index 0143014..d2362d7 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp @@ -11,7 +11,6 @@ #include #include "ErrorInfo.h" #include "fstream" -#include @@ -41,8 +40,7 @@ typedef struct objDetector { // VPT_FPNPluginFactory tensorrt_plugin_factory; int licence_status = -1; - int thrd_status = -1; - boost::thread thrd; + int thrd_status = -1; vector taskTrackers; objDetector() { diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp index 9ec7c09..35a8f3c 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp @@ -1,52 +1,44 @@ #include "VehiclePlate.h" #include + +#include "../../FFNvDecoder/logger.hpp" //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", "��", "ѧ", "ʹ", "��" }; int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license) { - vpd_param param; - param.gpuid = gpuid; - param.thresld = 0.3; + vp_detect_param param; + param.gpuid = gpuid; + param.thresld = 0.4; param.max_batch = 20; - param.serialize_file = "./serialize_file/VPD"; - param.auth_license = auth_license; + param.serialize_file = "./serialize_file/VPDetect"; + param.auth_license = "sy_va_sub_sdk_2023"; vpr_param rparam; - rparam.gpuid =gpuid; - param.max_batch = 20; - param.serialize_file = "./serialize_file/VPR"; + rparam.gpuid = gpuid; + rparam.max_batch = 20; + rparam.serialize_file = "./serialize_file/VPRecg"; + param.auth_license = "sy_va_sub_sdk_2023"; int ret = vpdr_init(&handle, param, rparam); - if (ret != 0) { - cout << "Init platedr Failed!" << endl; + cout << "vpdr_init Failed!" << endl; return FAILED; } - return SUCCESS; } -int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vplate_result *&result) +int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_plate_result *&result) { - /*��ʼ������ṹ��*/ - vplates_result * all_result = new vplates_result[batchsize] {}; - for (int i = 0; i #include "utools.h" #include -using namespace std; +#include "vehicle_plate_dr.h" + + +using namespace std; int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license); -int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img,int batchsize, vplate_result *&result); +int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img,int batchsize, vehicle_plate_result *&result); int VehiclePlateDetectRecog_Release(void *& handle); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.cpp index 2288709..38b8c62 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.cpp +++ b/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 vrr_param params; params.gpuid = gpuid; params.mode = DEVICE_GPU; - //printf("ERROR PATH\n"); - params.db_path = dbpath;//"../../db/mvpt.bin"; + params.db_path = dbpath; params.engine = ENGINE_TENSORRT; params.max_batch = 20; params.serialize_file = "./serialize_file/VRR"; params.auth_license = auth_license; - //#ifdef _MSC_VER - // params.dbPath = "../../../../vehicleRecognition_MCaffeTmpBody/db/CarBodyFeature.db"; - //#else - // params.dbPath = "/home/mliu/project/Project_MultiVPT/Video-Platform/video_structure_20190131/VehicleRecognition_body/db/CarBodyFeature.db"; - //#endif - int ret = vrr_init(&handle, params); if (ret != 0) { cout << "VRR Init Failed!" << endl; - system("pause"); return FAILED; } + return SUCCESS; } -int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vr_result) +int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result) { for (int i = 0; i < batchsize; i++) { @@ -37,7 +30,6 @@ int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr vrr_batch(handle, batch_img, batchsize, vr_result); - return SUCCESS; } int VehicleRearRecg_Release(void *& handle) diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h index d402987..c221da3 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRearRecg.h @@ -9,5 +9,5 @@ using namespace std; int VehicleRearRecg_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); -int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vr_result); +int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result); int VehicleRearRecg_Release(void *& handle); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp index e45284d..0cdf4f0 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp @@ -6,87 +6,33 @@ using namespace std; int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license) { vr_param params; - params.gpuid = gpuid; - params.mode = DEVICE_GPU; - - params.db_path = dbpath;//"../../db/mvpt.bin"; + params.gpuid = 0; + params.mode = DEVICE_GPU; params.engine = ENGINE_TENSORRT; params.max_batch = 20; - params.serialize_file = "./serialize_file/VR"; - params.auth_license = auth_license; -//#ifdef _MSC_VER -// params.dbPath = "../../../../vehicleRecognition_MCaffeTmpBody/db/CarBodyFeature.db"; -//#else -// params.dbPath = "/home/mliu/project/Project_MultiVPT/Video-Platform/video_structure_20190131/VehicleRecognition_body/db/CarBodyFeature.db"; -//#endif + params.vehicle_brand_serialize_file = "./serialize_file/VEHICLE_BRAND"; + params.vr5905cls_serialize_file = "./serialize_file/VR5905CLS"; + params.vehicle_type_serialize_file = "./serialize_file/VEHICLE_TYPE"; + params.auth_license = "sy_va_sub_sdk_2023"; + int ret = vr_init(&handle, params); if (ret != 0) { cout << "VR Init Failed!" << endl; - system("pause"); return FAILED; } return SUCCESS; } -int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vrresult) +int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_recog_result *&vrresult) { - //VR_Result *vr_result = new VR_Result[batchsize]; - /*vrresult = new vr_result[batchsize]; - for (int i = 0; i < batchsize; i++) - { - vrresult[i].vehicle_brand = new char[260]; - vrresult[i].vehicle_subbrand = new char[260]; - vrresult[i].vehicle_issue_year = new char[260]; - vrresult[i].vehicle_type = new char[260]; - vrresult[i].freight_ton = new char[260]; - }*/ for (int i = 0; i < batchsize; i++) { if (batch_img[i].data_ == NULL) cout << i << " data null" << endl; } - //cout << "begin vr_batch" << endl; vr_batch(handle, batch_img, batchsize, vrresult); - //cout << "end vr_batch" << endl; - /* for (int i = 0; i < batchsize; i++) - { - cout << i << ".ʶ������" << endl; - cout << " ʶ�����Ŷ�: " << vr_result[i].name_score << endl; - cout << " ����Ʒ�� - " << vr_result[i].vehicleBrand << endl; - cout << " ������Ʒ�� - " << vr_result[i].vehicleSubBrand << endl; - cout << " ������� - " << vr_result[i].vehicleIssueYear << endl; - cout << " �������� - " << vr_result[i].vehicleType << endl; - cout << " �����ּ� - " << vr_result[i].freightTon << endl; - cout << endl; - - if (vr_result[i].vehicleBrand != NULL) - { - delete[] vr_result[i].vehicleBrand; - vr_result[i].vehicleBrand = NULL; - } - if (vr_result[i].vehicleSubBrand != NULL) - { - delete[] vr_result[i].vehicleSubBrand; - vr_result[i].vehicleSubBrand = NULL; - } - if (vr_result[i].vehicleIssueYear != NULL) - { - delete[] vr_result[i].vehicleIssueYear; - vr_result[i].vehicleIssueYear = NULL; - } - if (vr_result[i].vehicleType != NULL) - { - delete[] vr_result[i].vehicleType; - vr_result[i].vehicleType = NULL; - } - if (vr_result[i].freightTon != NULL) - { - delete[] vr_result[i].freightTon; - vr_result[i].freightTon = NULL; - } - }*/ return SUCCESS; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h index e7babea..cf20b04 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h @@ -11,5 +11,5 @@ using namespace std; int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); -int VehicleRecognition_Process(void * handle, sy_img * batch_img,int batchsize, vr_result *&vr_result); +int VehicleRecognition_Process(void * handle, sy_img * batch_img,int batchsize, vehicle_recog_result*&vr_result); int VehicleRecognition_Release(void *& handle); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp new file mode 100644 index 0000000..d7ec000 --- /dev/null +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp @@ -0,0 +1,46 @@ +#include "non_vehicle_fea.h" +#include "sy_common.h" +#include +int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) +{ + + int ret = SUCCESS; + + human_fea_param fea_param; + fea_param.mode = DEVICE_GPU; + fea_param.gpuid = gpuid; + fea_param.thres = 0.6; + fea_param.engine = ENGINE_TENSORRT; + + //δ��Ч + fea_param.max_batch = 20; + fea_param.serialize_file = "./serialize_file/HF"; + fea_param.auth_license = auth_license; + if (human_fea_init(&handle, fea_param) != SUCCESS) + { + printf("sy_human_parsing_fea_init(error): init end. (ret = %d)\n", ret); + ret = HUMANPARSING_INIT_ERROR; + } + + return SUCCESS; + +} + +int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result) +{ + for (int i = 0; i < batch_size; i++) + { + if (batch_img[i].data_ == NULL) + std::cout << i << " NonVehicleFea data null" << std::endl; + } + + return human_fea_batch(handle, batch_img, batch_size, result); + +} + +int NonVehicleFea_Release(void *& handle) +{ + human_fea_release(&handle); + handle = NULL; + return SUCCESS; +} \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h new file mode 100644 index 0000000..e66be18 --- /dev/null +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h @@ -0,0 +1,7 @@ +#pragma once +#include "non_vehicle_fea_trt.h" +#include "utools.h" + +int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license); +int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result); +int NonVehicleFea_Release(void *& handle); \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp deleted file mode 100644 index cb5a611..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "non_vehicle_fea_trt.h" -#include -int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) -{ - - int ret = SUCCESS; - - human_fea_param fea_param; - fea_param.mode = DEVICE_GPU; - fea_param.gpuid = gpuid; - fea_param.thres = 0.6; - fea_param.engine = ENGINE_TENSORRT; - - //δЧ - fea_param.max_batch = 20; - fea_param.serialize_file = "./serialize_file/HF"; - fea_param.auth_license = auth_license; - if (human_fea_init(&handle, fea_param) != SUCCESS) - { - printf("sy_human_parsing_fea_init(error): init end. (ret = %d)\n", ret); - ret = HUMANPARSING_INIT_ERROR; - } - - return SUCCESS; - -} - -int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result) -{ - for (int i = 0; i < batch_size; i++) - { - if (batch_img[i].data_ == NULL) - std::cout << i << " NonVehicleFea data null" << std::endl; - } - - return human_fea_batch(handle, batch_img, batch_size, result); - -} - -int NonVehicleFea_Release(void *& handle) -{ - human_fea_release(&handle); - handle = NULL; - return SUCCESS; -} \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h deleted file mode 100644 index b22d5f2..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea_trt.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include "human_fea.h" -#include "utools.h" - -int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license); -int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result); -int NonVehicleFea_Release(void *& handle); \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp index a42f24d..25cd04e 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp @@ -1,14 +1,12 @@ #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include "snapshot_helper.h" -#include -#include #include "HumanParsing.h" #include "HumanCarParsing.h" #include "VehiclePlate.h" #include "VehicleRecognition.h" #include "VehicleColor.h" -#include "non_vehicle_fea_trt.h" +#include "non_vehicle_fea.h" //#include "HumanFeatures.h" #include "vehicle_features.h" #include "VehicleRearRecg.h" @@ -16,12 +14,14 @@ #include +#include "../FFNvDecoder/logger.hpp" + using namespace std; string ObjTypes[9] = { "行人", "自行车", "摩托车", "三轮车", "小型车", "大车", "卡车", "拖拉机", "中巴" }; string ObjTypesEnglish[9] = { "person", "bike", "motor", "tricycle", "car", "bigbus", "lorry", "tractor", "midibus" }; -DWORD SnapshotThreadProcess(LPVOID param); -DWORD SnapshotImageWriteThreadProcess(LPVOID param); + + #ifdef _MSC_VER char* GbkToUtf8(const char *src_str) { @@ -74,10 +74,22 @@ private: long end_time{ 0 }; char* opt_name; }; +#endif +void SnapshotThreadProcess(const void * userPtr){ + snapshot_helper* _this = (snapshot_helper*)userPtr; + if(nullptr != _this){ + _this->snapshot_thread_process(); + } +} +void SnapshotImageWriteThreadProcess(const void * userPtr){ + snapshot_helper* _this = (snapshot_helper*)userPtr; + if(nullptr != _this){ + _this->snapshot_imagewrite_thread_process(); + } +} -#endif 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, \ 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) { @@ -150,37 +162,18 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c batch_vehicle = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{}; batch_vehicle_vf = new sy_img[OBJ_BATCH_COUNT_VEHICLE]{}; - //count_vehivle_finishanalysis = 0; - ProcessSnapshotThread = boost::thread(SnapshotThreadProcess, this); - auto writeThread1 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread1.detach(); - auto writeThread2 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread2.detach(); - auto writeThread3 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread3.detach(); - auto writeThread4 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread4.detach(); - auto writeThread5 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread5.detach(); - auto writeThread6 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread6.detach(); - auto writeThread7 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread7.detach(); - auto writeThread8 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread8.detach(); - auto writeThread9 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread9.detach(); - auto writeThread10 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread10.detach(); - auto writeThread11 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread11.detach(); - auto writeThread12 = std::thread(SnapshotImageWriteThreadProcess, this); - writeThread12.detach(); - + m_bExit = false; + ProcessSnapshotThread = new std::thread(SnapshotThreadProcess, this); + for (size_t i = 0; i < 12; i++) + { + std::thread* writeThread = new std::thread(SnapshotImageWriteThreadProcess, this); + m_vec_writeThread.push_back(writeThread); + } } void snapshot_helper::snapshot_helper_release() { + m_bExit = true; HumanParsing_Release(hp_handle); HumanCarParsing_Release(hcp_handle); VehicleColor_Release(vc_handle); @@ -229,8 +222,11 @@ void snapshot_helper::snapshot_helper_release() } } - ProcessSnapshotThread.interrupt(); //interrupt thread - ProcessSnapshotThread.join(); //waiting thread finish + ProcessSnapshotThread->join(); //waiting thread finish + for (size_t i = 0; i < m_vec_writeThread.size(); i++) + { + m_vec_writeThread[i]->join(); + } } @@ -262,14 +258,15 @@ int snapshot_helper::save_face_snapshot(OBJ_KEY obj_key) 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, 0, 0, obj_value.snapShotFace.width, obj_value.snapShotFace.height); + // if (tempSnapShotFaceHost) + // { + // delete[] tempSnapShotFaceHost; + // tempSnapShotFaceHost = NULL; + // } + cudaFree(obj_value.snapShotFace.frame); obj_value.snapShotFace.frame = nullptr; obj_value.snapShotFace.height = -1; //表示有人脸检测到 存过人脸快照图 用于确定最终是否返回人脸快照保存位置 - if (tempSnapShotFaceHost) - { - delete[] tempSnapShotFaceHost; - tempSnapShotFaceHost = NULL; - } } return 0; @@ -468,7 +465,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi { vector hp_keys; vector hcp_keys; - vector vehicle_keys; + queue vehicle_keys; vector vehicle_else; //仅保存的 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 hcp_keys.push_back(iter->first); 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 && iter->second.snapShotLittle.frame != NULL && iter->second.snapShotLittle.height == VEHICLE_HEIGHT && iter->second.snapShotLittle.width == VEHICLE_WIDTH) - vehicle_keys.push_back(iter->first); + vehicle_keys.push(iter->first); else vehicle_else.push_back(iter->first); } @@ -699,98 +696,80 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi if (!vehicle_keys.empty()) { - const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE; - const int vehicle_batch_size = vehicle_keys.size(); - int vehicle_batch_count = obj_batch_count; - for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i) - { - if (i == (vehicle_batch_size / obj_batch_count)) - vehicle_batch_count = vehicle_batch_size % obj_batch_count; + int det_batch_size = 10; + while (!vehicle_keys.empty()) { - if (vehicle_batch_count == 0) continue; - - sy_img finish_vehicle_img[vehicle_batch_count]; - for (int j = 0; j < vehicle_batch_count; j++) + if(vehicle_keys.size() >= 10) { + det_batch_size = 10; + } else { + det_batch_size = vehicle_keys.size(); + } + + sy_img finish_vehicle_img[det_batch_size]; + vector det_vehicle_keys; + for (int j = 0; j < det_batch_size; j++) { - OBJ_KEY cur_obj_key = vehicle_keys[j]; + OBJ_KEY cur_obj_key = vehicle_keys.front(); + det_vehicle_keys.push_back(cur_obj_key); finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); + vehicle_keys.pop(); } - vc_result *vcresult = new vc_result[vehicle_batch_count]{}; - vplate_result *vp_result = new vplate_result[vehicle_batch_count]{}; - vr_result *vrresult = new vr_result[vehicle_batch_count]{}; - if (vehicle_analysis_config == SY_CONFIG_OPEN) - { - VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult); - VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result); - VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count); + vc_result *vcresult = new vc_result[det_batch_size]{}; + vehicle_plate_result *vp_result = new vehicle_plate_result[det_batch_size]{}; + vr_result *vrresult = new vr_result[det_batch_size]{}; + if (vehicle_analysis_config == SY_CONFIG_OPEN) { + if(det_batch_size == 3) { + printf("batchsize: %d \n", det_batch_size); + } + VehicleColor_Process(vc_handle, finish_vehicle_img, det_batch_size, vcresult); + VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, det_batch_size, vp_result); + VehicleRecog_Process(finish_vehicle_img, det_batch_size, vrresult, det_vehicle_keys.data()); } int8 ** fea = nullptr; - if (vcf_recg_config == SY_CONFIG_OPEN) - { - - fea = new int8*[vehicle_batch_count] {}; - for (int ii = 0; ii < vehicle_batch_count; ++ii) - { + if (vcf_recg_config == SY_CONFIG_OPEN) { + fea = new int8*[det_batch_size] {}; + for (int ii = 0; ii < det_batch_size; ++ii) { fea[ii] = new int8[FEATURESIZE]{}; } - //TimeCounting t("vf_features_process"); - vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea); + vf_features_process(vf_handle, finish_vehicle_img, det_batch_size, fea); } - - int resIndex = 0; int feaIndex = 0; - for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++) + for (int vc_idx = 0; vc_idx < det_batch_size; vc_idx++) { - auto iter = snapShotInfo.find(vehicle_keys[vc_idx]); - - if (iter == snapShotInfo.end()) - resIndex++; //cout << iter_key.videoID << " " <::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); ) + for (auto iter_v = count_vehicle_v.begin(); iter_v != count_vehicle_v.end(); ) { - if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID) - iter = count_vehicle_v.erase(iter); + if (iter_v->videoID == det_vehicle_keys[vc_idx].videoID && iter_v->objID == det_vehicle_keys[vc_idx].objID) + iter_v = count_vehicle_v.erase(iter_v); else { - ++iter; + ++iter_v; } } if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里 { - save_snapshot(vehicle_keys[vc_idx]); + save_snapshot(det_vehicle_keys[vc_idx]); } if (iter->second.snapShotLittle.frame) @@ -808,7 +787,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi if (fea != nullptr) { - for (int ii = 0; ii < vehicle_batch_count; ++ii) + for (int ii = 0; ii < det_batch_size; ++ii) { delete[] fea[ii]; } @@ -832,8 +811,6 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi delete[] vrresult; vrresult = NULL; } - - vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count); } v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS; @@ -862,21 +839,6 @@ void snapshot_helper::hp_analysis() //if (count_person.size() >= OBJ_BATCH_COUNT) { -#ifdef LOG_INFO - std::cout << "------ begin HumanParsing_Process -----" << std::endl; -#ifdef _MSC_VER - LARGE_INTEGER nFreq, nBeginTime, nEndTime; - LARGE_INTEGER nSaveBeginTime, nSaveEndTime; - - QueryPerformanceFrequency(&nFreq); - QueryPerformanceCounter(&nBeginTime); - double time_val = 0.0; -#else - gettimeofday(&t1, NULL); - -#endif -#endif - //选择前N个做行人属性分析 const int OBJ_BATCH_COUNT_bk = OBJ_BATCH_COUNT; const int OBJ_SCALE_COUNT_bk = OBJ_SCALE; @@ -933,19 +895,6 @@ void snapshot_helper::hp_analysis() //TimeCounting t("NonVehicleFea_Process"); NonVehicleFea_Process(nvf_handle, batch_hp, obj_batch_count, result_f); } -#ifdef LOG_INFO -#ifdef _MSC_VER - QueryPerformanceCounter(&nEndTime); - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart; - std::printf("HumanParsing_Process: %.2f ms \n", time_val); -#else - /* - gettimeofday(&t2, NULL); - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0; - printf("HumanParsing_Process = %lf ms\n", time_val); - */ -#endif -#endif //删除已经进行保存和二次属性分析的目标 int resIndex = 0; @@ -986,20 +935,6 @@ void snapshot_helper::hp_analysis() delete[] result_f; result_f = nullptr; } -#ifdef LOG_INFO -#ifdef _MSC_VER - QueryPerformanceCounter(&nEndTime); - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart; - std::printf("total: %.2f ms \n", time_val); -#else - /* - gettimeofday(&t2, NULL); - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0; - printf("HumanParsing_Process = %lf ms\n", time_val); - */ -#endif - std::cout << "----- end HumanParsing_Process -----" << std::endl; -#endif } OBJ_BATCH_COUNT = OBJ_BATCH_COUNT_bk; @@ -1027,20 +962,6 @@ void snapshot_helper::hcp_analysis() { vector erase_obj_key; -#ifdef LOG_INFO - std::cout << "----- begin HumanCarParsing_Process -----" << endl; -#ifdef _MSC_VER - LARGE_INTEGER nFreq, nBeginTime, nEndTime; - LARGE_INTEGER nSaveBeginTime, nSaveEndTime; - - QueryPerformanceFrequency(&nFreq); - QueryPerformanceCounter(&nBeginTime); - double time_val = 0.0; -#else - gettimeofday(&t1, NULL); - -#endif -#endif int obj_batch_count = 0; hcp_analysis_result *result = nullptr; human_fea_result * result_f = nullptr; @@ -1088,21 +1009,6 @@ void snapshot_helper::hcp_analysis() NonVehicleFea_Process(nvf_handle, batch_hcp, obj_batch_count, result_f); } - -#ifdef LOG_INFO -#ifdef _MSC_VER - QueryPerformanceCounter(&nEndTime); - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart; - printf("HumanCarParsing_Process: %.2f ms \n", time_val); -#else - /* - gettimeofday(&t2, NULL); - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0; - printf("HumanCarParsing_Process = %lf ms\n", time_val); - */ -#endif - cout << "----- end HumanCarParsing_Process -----" << endl; -#endif int resIndex = 0; for (auto iter_key : erase_obj_key) { @@ -1173,20 +1079,6 @@ bool snapshot_helper::vehicle_color_analysis() for (int index = 0; index < OBJ_SCALE; ++index) { -#ifdef LOG_INFO - cout << "----- begin VehicleColor_Process -----" << endl; -#ifdef _MSC_VER - LARGE_INTEGER nFreq, nBeginTime, nEndTime; - LARGE_INTEGER nSaveBeginTime, nSaveEndTime; - - QueryPerformanceFrequency(&nFreq); - QueryPerformanceCounter(&nBeginTime); - double time_val = 0.0; -#else - gettimeofday(&t1, NULL); - -#endif -#endif int start_idx = cur_iter_count * index; 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() //TimeCounting t("VehicleColor_Process"); VehicleColor_Process(vc_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vcresult); } - - -#ifdef LOG_INFO -#ifdef _MSC_VER - QueryPerformanceCounter(&nEndTime); - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart; - printf("VehicleColor_Process: %.2f ms \n", time_val); -#else - /* - gettimeofday(&t2, NULL); - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0; - printf("VehicleColor_Process = %lf ms\n", time_val); - */ -#endif -#endif for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) { @@ -1287,21 +1164,6 @@ bool snapshot_helper::vehicle_plate_dr_analysis() for (int index = 0; index < OBJ_SCALE; ++index) { -#ifdef LOG_INFO - cout << "----- begin VEHICLEPLATEAnalysis -----" << endl; - -#ifdef _MSC_VER - LARGE_INTEGER nFreq, nBeginTime, nEndTime; - LARGE_INTEGER nSaveBeginTime, nSaveEndTime; - - QueryPerformanceFrequency(&nFreq); - QueryPerformanceCounter(&nBeginTime); - double time_val = 0.0; -#else - gettimeofday(&t1, NULL); - -#endif -#endif int start_idx = cur_iter_count * index; int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; @@ -1331,26 +1193,8 @@ bool snapshot_helper::vehicle_plate_dr_analysis() } batch_vehicle[i].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); } - vplate_result *vp_result = new vplate_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; - { - //TimeCounting t("VehiclePlateDetectRecog_Process"); - VehiclePlateDetectRecog_Process(vp_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result); - } - - -#ifdef LOG_INFO -#ifdef _MSC_VER - QueryPerformanceCounter(&nEndTime); - time_val = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart; - printf("VEHICLEPLATEAnalysis: %.2f ms \n", time_val); -#else - /* - gettimeofday(&t2, NULL); - time_val = ((t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec) / 1000.0; - printf("VehicleColor_Process = %lf ms\n", time_val); - */ -#endif -#endif + vehicle_plate_result *vp_result = new vehicle_plate_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; + VehiclePlateDetectRecog_Process(vp_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result); int resIndex = 0; 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() { vehicle_result &curRes = vehicle_result_v[i + start_idx]; - memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vplate_result)); + memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vehicle_plate_result)); resIndex++; } } @@ -1392,13 +1236,17 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr sy_img * batch_vehicle_head = new sy_img[batchsize]{}; sy_img * batch_vehicle_rear = new sy_img[batchsize]{}; - vpd_result * vhd_res = new vpd_result[batchsize]{}; + vpd2_result* vhd_res = new vpd2_result[batchsize]; + for (int b = 0; b < batchsize; b++) + { + vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT]; + } vhd_features_process(vhd_handle, batch_img, batchsize, vhd_res); for (int vc_idx = 0; vc_idx < batchsize; vc_idx++) { OBJ_KEY cur_obj_key = obj_keys[vc_idx]; - vpd_result & result = vhd_res[vc_idx]; + vpd2_result & result = vhd_res[vc_idx]; if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 { @@ -1472,18 +1320,15 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr if (index_head != 0) { - vr_result *vrresult = new vr_result[index_head]{}; - { - //TimeCounting t("VehicleRecognition_Process"); - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); - } + LOG_DEBUG("index_head : {}", index_head); + vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{}; + VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); int resIndex = 0; for (auto & item : mp_head) { - vr_result &curRes = vresult[item]; - memcpy(&vresult[item], &vrresult[resIndex], sizeof(vr_result)); + memcpy(&vresult[item], &vrresult[resIndex], sizeof(vehicle_recog_result)); resIndex++; } delete[] vrresult; @@ -1492,18 +1337,13 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr if (index_rear != 0) { - vr_result *vrresult = new vr_result[index_rear]{}; - - { - //TimeCounting t("VehicleRearRecg_Process"); - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); - } + vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{}; + VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); int resIndex = 0; for (auto & item : mp_rear) { - vr_result &curRes = vresult[item]; - memcpy(&vresult[item], &vrresult[resIndex], sizeof(vr_result)); + memcpy(&vresult[item], &vrresult[resIndex], sizeof(vehicle_rear_result)); resIndex++; } delete[] vrresult; @@ -1561,21 +1401,6 @@ bool snapshot_helper::vehicle_recg_analysis() // OBJ_BATCH_COUNT_VEHICLE, OBJ_SCALE, cur_iter_count); for (int index = 0; index < OBJ_SCALE; ++index) { -#ifdef LOG_INFO - cout << "----- begin VehicleColor_Process -----" << endl; - -#ifdef _MSC_VER - LARGE_INTEGER nFreq, nBeginTime, nEndTime; - LARGE_INTEGER nSaveBeginTime, nSaveEndTime; - - QueryPerformanceFrequency(&nFreq); - QueryPerformanceCounter(&nBeginTime); - double time_val = 0.0; -#else - gettimeofday(&t1, NULL); - -#endif -#endif int cur_batchsize = index == 0 ? cur_iter_count : OBJ_BATCH_COUNT_VEHICLE - cur_iter_count; for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) @@ -1616,13 +1441,17 @@ bool snapshot_helper::vehicle_recg_analysis() sy_img * batch_vehicle_head = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; sy_img * batch_vehicle_rear = new sy_img[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; - vpd_result * vhd_res = new vpd_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; + vpd2_result* vhd_res = new vpd2_result[cur_batchsize]; + for (int b = 0; b < cur_batchsize; b++) + { + vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT]; + } vhd_features_process(vhd_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res); for (int vc_idx = 0; vc_idx < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; vc_idx++) { OBJ_KEY cur_obj_key = count_vehicle_v[vc_idx]; - vpd_result & result = vhd_res[vc_idx]; + vpd2_result & result = vhd_res[vc_idx]; if (result.count == 0) //若没有检测到车头/车尾,即认定为车身,车身直接原图送车尾车型识别 { @@ -1697,11 +1526,8 @@ bool snapshot_helper::vehicle_recg_analysis() if (index_head != 0) { - vr_result *vrresult = new vr_result[index_head]{}; - { - //TimeCounting t("VehicleRecognition_Process"); - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); - } + vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{}; + VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); int resIndex = 0; for (auto & item : mp_head) @@ -1712,7 +1538,7 @@ bool snapshot_helper::vehicle_recg_analysis() else { vehicle_result &curRes = vehicle_result_v[item.first]; - memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result)); + memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vehicle_recog_result)); resIndex++; } } @@ -1721,12 +1547,8 @@ bool snapshot_helper::vehicle_recg_analysis() } if (index_rear != 0) { - vr_result *vrresult = new vr_result[index_rear]{}; - - { - //TimeCounting t("VehicleRearRecg_Process"); - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); - } + vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{}; + VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); int resIndex = 0; for (auto & item : mp_rear) @@ -1738,7 +1560,7 @@ bool snapshot_helper::vehicle_recg_analysis() else { vehicle_result &curRes = vehicle_result_v[item.first]; - memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result)); + memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vehicle_rear_result)); resIndex++; } } @@ -1964,12 +1786,9 @@ void snapshot_helper::snapshot_res_callback(OBJ_KEY obj_key,/* OBJ_VALUE obj_val finished_analysis_ss_info[obj_key] = newVideoObj; } } -#include + void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key) { - //std::ofstream os("D:\\vptlog1_2.txt", std::ofstream::out | std::ofstream::trunc); - //os << unitbuf; - //os << obj_key.videoID << " and " << obj_key.objID << endl; bool image_unsave = false; bool sna_unsave = false; std::lock_guard lock(threadMutex); @@ -1997,46 +1816,34 @@ void snapshot_helper::erase_snapshotImage(OBJ_KEY obj_key) } if (!sna_unsave) { - //os << 1 << endl; finished_save_ss_info.erase(obj_key); char snapShotName[260] = {}; sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].snapshot_folder, obj_key.objID); remove(snapShotName); - //os << snapShotName << endl; } if (!image_unsave) { - //os << 2 << endl; char snapShotName[260] = {}; sprintf(snapShotName, "%s/%d.jpg", m_task_info[obj_key.videoID].image_folder, obj_key.objID); remove(snapShotName); - //os << snapShotName << endl; } - //os << 3 << endl; } -//SNAPSHOT_IMAGE_UNIT cur_image; -#ifndef _MSC_VER -#include -#endif - -DWORD SnapshotImageWriteThreadProcess(LPVOID param) +void snapshot_helper:: snapshot_imagewrite_thread_process() { - snapshot_helper *pThreadParam = (snapshot_helper *)param; - - while (true) + while (!m_bExit) { - std::unique_lock l(pThreadParam->threadMutex); - if (!pThreadParam->snapshotImageQueue.empty()) + std::unique_lock l(threadMutex); + if (!snapshotImageQueue.empty()) { - SNAPSHOT_IMAGE_UNIT cur_image = pThreadParam->snapshotImageQueue.front(); - pThreadParam->snapshotImageQueue.pop(); + SNAPSHOT_IMAGE_UNIT cur_image = snapshotImageQueue.front(); + snapshotImageQueue.pop(); l.unlock(); vector compression_params; compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); //-------debug by zsh---------------------------------------------------- - int jpeg_quality_ = pThreadParam->m_task_info[cur_image.obj_key.videoID].jpeg_quality_; + int jpeg_quality_ = m_task_info[cur_image.obj_key.videoID].jpeg_quality_; jpeg_quality_ = jpeg_quality_ > 0 ? jpeg_quality_ : 0; jpeg_quality_ = jpeg_quality_ < 100 ? jpeg_quality_ : 100; //cout << "jpeg_quality_:" << jpeg_quality_ << endl; @@ -2049,86 +1856,74 @@ DWORD SnapshotImageWriteThreadProcess(LPVOID param) { delete[]cur_image.image.data; cur_image.image.data = NULL; -#ifndef _MSC_VER - malloc_trim(0); -#endif } image.release(); if (false == cur_image.is_image) { - std::unique_lock ll(pThreadParam->finishedThreadMutex); - pThreadParam->finished_save_ss_info_que.push(cur_image.obj_key); + std::unique_lock ll(finishedThreadMutex); + finished_save_ss_info_que.push(cur_image.obj_key); } - } else { l.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } - } - return 0; + return ; } -DWORD SnapshotThreadProcess(LPVOID param) +void snapshot_helper::snapshot_thread_process() { - snapshot_helper *pThreadParam = (snapshot_helper *)param; - //std::ofstream os("./vptlog1.txt", std::ofstream::out | std::ofstream::trunc); - //os << unitbuf; - //try + while (!m_bExit) { - while (true) + std::unique_lock l(finishedThreadMutex); + while (!finished_save_ss_info_que.empty()) { - std::unique_lock l(pThreadParam->finishedThreadMutex); - while (!pThreadParam->finished_save_ss_info_que.empty()) - { - pThreadParam->finished_save_ss_info.insert(pThreadParam->finished_save_ss_info_que.front()); - pThreadParam->finished_save_ss_info_que.pop(); - } - l.unlock(); - for (auto iter = pThreadParam->finished_save_ss_info.begin(); iter != pThreadParam->finished_save_ss_info.end();) + finished_save_ss_info.insert(finished_save_ss_info_que.front()); + finished_save_ss_info_que.pop(); + } + l.unlock(); + for (auto iter = finished_save_ss_info.begin(); iter != finished_save_ss_info.end();) + { + std::lock_guard lock(analysisThreadMutex); + auto iter_snapshot = finished_analysis_ss_info.find(*iter); + if (iter_snapshot != finished_analysis_ss_info.end()) { - std::lock_guard lock(pThreadParam->analysisThreadMutex); - if (pThreadParam->finished_analysis_ss_info.find(*iter) != pThreadParam->finished_analysis_ss_info.end()) + video_object_snapshot v_object_snapshot = finished_analysis_ss_info[*iter]; + if (m_task_info[iter->videoID].obj_callback != nullptr) { - if (pThreadParam->m_task_info[iter->videoID].obj_callback != nullptr) + //os << iter->videoID << " " << iter->objID << "; "; + std::lock_guard l(callback_tx); + m_task_info[iter->videoID].obj_callback(&v_object_snapshot); + } + + { + if (v_object_snapshot.analysisRes != NULL) { - //os << iter->videoID << " " << iter->objID << "; "; - std::lock_guard l(pThreadParam->callback_tx); - pThreadParam->m_task_info[iter->videoID].obj_callback(&pThreadParam->finished_analysis_ss_info[*iter]); + delete v_object_snapshot.analysisRes; + v_object_snapshot.analysisRes = NULL; } + if (v_object_snapshot.face_res != nullptr) { - if (pThreadParam->finished_analysis_ss_info[*iter].analysisRes != NULL) - { - delete pThreadParam->finished_analysis_ss_info[*iter].analysisRes; - pThreadParam->finished_analysis_ss_info[*iter].analysisRes = NULL; - } - - if (pThreadParam->finished_analysis_ss_info[*iter].face_res != nullptr) - { - delete pThreadParam->finished_analysis_ss_info[*iter].face_res; - pThreadParam->finished_analysis_ss_info[*iter].face_res = nullptr; - } - - pThreadParam->finished_analysis_ss_info.erase(pThreadParam->finished_analysis_ss_info.find(*iter)); + delete v_object_snapshot.face_res; + v_object_snapshot.face_res = nullptr; } - iter = pThreadParam->finished_save_ss_info.erase(iter); + + finished_analysis_ss_info.erase(iter_snapshot); } - else - iter++; + iter = finished_save_ss_info.erase(iter); } - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); - + else + iter++; } - } - //catch (...) - { - std::cout << "Save Process Thread is Finished" << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } - return 0; + std::cout << "Save Process Thread is Finished" << std::endl; + + return ; } 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) diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h index a585ccc..04b74c5 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h @@ -5,8 +5,9 @@ #include #include #include -#include #include +#include +#include #include #include "ImageSaveCache.h" using namespace std; @@ -200,7 +201,13 @@ private: int hp_wait_count, hcp_wait_count, vehicle_wait_count; int wait_framecount; - boost::thread ProcessSnapshotThread; + std::thread* ProcessSnapshotThread; + std::vector m_vec_writeThread; + bool m_bExit {false}; + +public: + void snapshot_thread_process(); + void snapshot_imagewrite_thread_process(); public: std::mutex callback_tx; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp index 8759fee..2dc3d29 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp +++ b/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) params.serialize_file = "./serialize_file/VPD"; params.thresld = 0.6; params.auth_license = auth_license; - if (vpd_init(&handle, params) !=0) { + if (vpd2_init(&handle, params) !=0) { cout << "Init vhd Failed!" << endl; return FAILED; } @@ -43,20 +43,21 @@ int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd_result*& result) +int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result) { for (int i = 0; i < batch_size; i++) { if (batch_img[i].data_ == NULL) cout << i << " data null" << endl; } - vpd_process(handle, batch_img, batch_size, result); + vpd2_process(handle, batch_img, batch_size, result); for (int b = 0; b < batch_size; b++) { for (int c = 0; c < result[b].count; c++) { - 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_); + sy_rect rect = result[b].vpd_res[c].rect; + RectboundCheck(batch_img[b].w_, batch_img[b].h_, rect.left_, rect.top_, rect.width_, rect.height_); } } @@ -113,7 +114,7 @@ int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8 int vhd_feature_release(void *& handle) { if (handle) - vpd_release(&handle); + vpd2_release(&handle); return SUCCESS; } @@ -130,7 +131,7 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int #ifdef _DEBUG printf("img: Width = %d Height = %d\n", Width, Height); - printf("Src: width = %d height = %d, x = %d, y =%d\n", width, height, left, top); + printf("Src: width = %d height = %d, x = %d, y =%d\n", Width, Height, left, top); #endif if (left <= 0) left = 0; @@ -152,9 +153,6 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int height = Height - 1 - top; if (height <= 0) height = 0; -#ifdef _DEBUG - printf("Dst: width = %d, height = %d, x = %d, y =%d\n", width, height, left, top); -#endif } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h index b5b3d4b..6753921 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h @@ -2,7 +2,7 @@ #ifndef _VEHICLEFEATURES_H_ #define _VEHICLEFEATURES_H_ -#include "vf.h" +#include "vehicle_fea_int8.h" #include "vpd.h" #ifndef __INT8__ @@ -14,7 +14,7 @@ int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license); -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd_result*& result); +int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result); int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8**& result); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp index 57bd890..89d210e 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp @@ -725,7 +725,7 @@ int main(int argc, char* argv[]) // vptParam.hf_recg_config = SY_CONFIG_CLOSE; // vptParam.hcf_recg_config = SY_CONFIG_CLOSE; // vptParam.vcf_recg_config = SY_CONFIG_CLOSE; - // vptParam.face_det_config = SY_CONFIG_CLOSE; + vptParam.face_det_config = SY_CONFIG_CLOSE; vptParam.hp_analysis_config = SY_CONFIG_OPEN; vptParam.hcp_analysis_config = SY_CONFIG_OPEN; @@ -733,7 +733,7 @@ int main(int argc, char* argv[]) vptParam.hf_recg_config = SY_CONFIG_OPEN; vptParam.hcf_recg_config = SY_CONFIG_OPEN; vptParam.vcf_recg_config = SY_CONFIG_OPEN; - vptParam.face_det_config = SY_CONFIG_OPEN; + // vptParam.face_det_config = SY_CONFIG_OPEN; vptParam.vrdbpath = argv[4]; //vptParam.vrdbpath = "../../db/mvpt.bin"; @@ -764,30 +764,25 @@ int main(int argc, char* argv[]) continue; } - create_task("/home/cmhu/data/video/bayue.mp4", total_index++); + // create_task("/home/cmhu/data/video/bayue.mp4", total_index++); - create_task("/home/cmhu/data/video/duan1.avi", total_index++); + // create_task("/home/cmhu/data/video/duan1.avi", total_index++); - create_task("/home/cmhu/data/video/Street.uvf", total_index++); + // create_task("/home/cmhu/data/video/Street.uvf", total_index++); - create_task("/home/cmhu/data/video/1.mp4", total_index++); + // create_task("/home/cmhu/data/video/1.mp4", total_index++); - create_task("/home/cmhu/data/video/720.avi", total_index++); + // create_task("/home/cmhu/data/video/720.avi", total_index++); - create_task("/home/cmhu/data/video/face1.mp4", total_index++); + // create_task("/home/cmhu/data/video/face1.mp4", total_index++); - // for (int i = 0; i < addTaskCount; i++) { + for (int i = 0; i < addTaskCount; i++) { - // create_task(videoFileName, total_index); + create_task(videoFileName, total_index); - // total_index++ ; + total_index++ ; - // #ifdef _MSC_VER - // Sleep(2000); - // #else - // usleep(40000); - // #endif - // } + } } while(0) ; printf("-------------------Begin rt_view_task 1 !----------------------\n"); -- libgit2 0.21.4