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 e24b661..c255685 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 @@ -114,21 +114,10 @@ int DxDecoderWrap::DxCloseDecoder() } -int DxDecoderWrap::DxGetResolution( int * width, int * height ) +int DxDecoderWrap::DxGetResolution( int &width, int &height ) { - if(m_pDec) { - int w,h; - m_pDec->getResolution(w, h); - - if ( width ) { - *width = w; - } - - if ( height ) { - *height = h; - } - + m_pDec->getResolution(width, height); return 0; } 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 b89448e..d033bd5 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 @@ -56,7 +56,7 @@ public: int DxGetFrameCount(); - int DxGetResolution( int * width, int * height ); + int DxGetResolution( int &width, int &height ); bool DxFrameIsEmpty(); int DxLockFrame( DxGPUFrame * frame ); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/ImageSaveGPU.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/ImageSaveGPU.cpp index 9382a27..eb0e759 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/ImageSaveGPU.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/ImageSaveGPU.cpp @@ -3,28 +3,6 @@ #include "logger.hpp" -//int saveJPEG(const char *szOutputFile, float* d_srcRGB, int img_width, int img_height) -//{ -// return jpegNPP(szOutputFile, d_srcRGB, img_width, img_height); -// //return 0; -//} -// -//int saveJPEG(const char *szOutputFile, unsigned char* d_srcRGB, int img_width, int img_height) -//{ -// return jpegNPP(szOutputFile, d_srcRGB, img_width, img_height); -// //return 0; -//} -// -//int saveJPEG(const char *szOutputFile, unsigned char* d_srcRGB) -//{ -// return jpegNPP(szOutputFile, d_srcRGB); -//} -// -//int saveJPEG(const char *szOutputFile, float* d_srcRGB) -//{ -// return jpegNPP(szOutputFile, d_srcRGB); -//} - int resizeFrame(float* d_srcRGB, int src_width, int src_height, float* d_dstRGB, int dst_width, int dst_height) { cudaError_t cudaStatus = cuda_common::ResizeImage(d_srcRGB, src_width, src_height, d_dstRGB, dst_width, dst_height); @@ -36,18 +14,6 @@ int resizeFrame(float* d_srcRGB, int src_width, int src_height, float* d_dstRGB, return 0; } -//int initTables() -//{ -// initTable(); -// return 0; -//} -// -//int initTables(int flag, int width, int height) -//{ -// initTable(0, width, height); -// return 0; -//} - int drawImageOnGPU(float* d_srcRGB, int src_width, int src_height, int left, int top, int right, int bottom) { cuda_common::DrawImage(d_srcRGB, src_width, src_height, left, top, right, bottom); @@ -66,12 +32,6 @@ int drawLineOnGPU(float* d_srcRGB, int src_width, int src_height, int begin_x, i return 0; } -//int releaseJpegSaver() -//{ -// releaseJpegNPP(); -// return 0; -//} - int partMemCopy(unsigned char* d_srcRGB, int src_width, int src_height, unsigned char* d_dstRGB, int left, int top, int right, int bottom) { cudaError_t cudaStatus = cuda_common::PartMemCopy(d_srcRGB, src_width, src_height, d_dstRGB, left, top, right, bottom); @@ -82,8 +42,7 @@ int partMemCopy(unsigned char* d_srcRGB, int src_width, int src_height, unsigned return 0; } -//#include -//extern std::ofstream g_os; + int PartMemResizeBatch(unsigned char * d_srcRGB, int src_width, int src_height, unsigned char** d_dstRGB, int count, int* vleft, int * vtop, int* vright, int* vbottom, int *dst_w, int *dst_h, float submeanb, float submeang, float submeanr, @@ -101,23 +60,4 @@ int PartMemResizeBatch(unsigned char * d_srcRGB, int src_width, int src_height, } return 0; -} - - -//int PartMemResizeBatch(float * d_srcRGB, int src_width, int src_height, unsigned char* d_dstRGB, -// int count, int* vleft, int * vtop, int* vright, int* vbottom, int dst_w, int dst_h, -// float submeanb, float submeang, float submeanr, -// float varianceb, float varianceg, float variancer) -// -//{ -// cudaError_t cudaStatus = cuda_common::PartMemResizeBatch( -// d_srcRGB, src_width, src_height, d_dstRGB, count, vleft, vtop, vright, vbottom, dst_w, dst_h, -// submeanb, submeang, submeanr, -// varianceb, varianceg, variancer); -// if (cudaStatus != cudaSuccess) { -// fprintf(stderr, "cuda_common::PartMemCopy failed: %s\n", cudaGetErrorString(cudaStatus)); -// return -1; -// } -// -// return 0; -//} \ No newline at end of file +} \ No newline at end of file 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 9606518..de6ec07 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 @@ -419,13 +419,6 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) tasks[i].folderNameLittle = nullptr; } - - if (tasks[i].taskDataToRT) - { - free(tasks[i].taskDataToRT); - tasks[i].taskDataToRT = nullptr; - } - tasks[i].frameImage.release(); @@ -543,15 +536,19 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh return false; } - int tmp_total_frame = new_task.taskTcuvid->DxGetFrameCount(); + int total_frame = new_task.taskTcuvid->DxGetFrameCount(); - printf("finish add codec. tmp_total_frame: %d \n", tmp_total_frame); + int width = 0; + 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); + + new_task.frameImage = cv::Mat::zeros(height, width, CV_8UC3); new_task.taskState = PLAY; new_task.task_algorithm_data.frame = NULL; new_task.taskFrameCount = 0; new_task.taskLastFrameCount = 0; - new_task.taskDataToRT = NULL; new_task.taskObjCallbackFunc = nullptr; if (objCallbackFunc != nullptr) @@ -561,7 +558,7 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh if (realTimeCallbackFunc != nullptr) new_task.taskRealTimeCallbackFunc = std::bind(realTimeCallbackFunc, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); - new_task.taskTotalFrameCount = tmp_total_frame; + new_task.taskTotalFrameCount = total_frame; if (resultFolderLittle == NULL) { new_task.folderNameLittle = NULL; @@ -620,10 +617,6 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh CreateResultFolder(new_task.folderNameFace, ""); } - // printf("finish create folder\n"); - - //Sleep(10); - //std::cout << "CreateResultFolder" << std::endl; TASK_INFO new_task_info = {}; new_task_info.image_folder = new_task.folderName; new_task_info.snapshot_folder = new_task.folderNameLittle; @@ -638,6 +631,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh TaskinPlay++; tasks.push_back(new_task); + AddTaskTracker(VPT_Handle, new_task.taskID, width, height); + if (!ProcessFlag) { ProcessThread = boost::thread(ThreadProcess, this); ProcessFlag = true; @@ -1492,8 +1487,10 @@ DWORD ThreadProcess(LPVOID param) if (0 != copy_obj_count) { cudaSetDevice(pThreadParam->mgpuid); + cuCtxPushCurrent(context); PartMemResizeBatch((unsigned char*)pThreadParam->tasks[*iter].task_algorithm_data.frame, frameWidth, frameHeight, snapshot_image_data, copy_obj_count, snapshot_left, snapshot_top, snapshot_right, snapshot_bottom, snapshot_dst_width, snapshot_dst_height, 0, 0, 0, 1, 1, 1); + cuCtxPopCurrent(&context); //最新刚添加的人脸检测模块,针对存在的行人快照进行人脸检测+人脸快照框的优选 if (pThreadParam->m_face_det_config == SY_CONFIG_OPEN && !human_idx.empty()) diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.qx b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.qx index 2b1e6f5..90c6dd7 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.qx +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.qx @@ -410,13 +410,6 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) tasks[i].folderNameLittle = nullptr; } - - if (tasks[i].taskDataToRT) - { - free(tasks[i].taskDataToRT); - tasks[i].taskDataToRT = nullptr; - } - tasks[i].frameImage.release(); @@ -553,7 +546,6 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re new_task.task_algorithm_data.frame = NULL; new_task.taskFrameCount = 0; new_task.taskLastFrameCount = 0; - new_task.taskDataToRT = NULL; new_task.taskObjCallbackFunc = nullptr; if (objCallbackFunc != nullptr) @@ -1039,14 +1031,13 @@ DWORD ThreadProcess(LPVOID param) if (cudaStatus != cudaSuccess) { fprintf(stderr, "here cudaMalloc m_pRGBData[0] failed! error: %s\n", cudaGetErrorString(cudaStatus)); break; - } + } pThreadParam->tasks[i].task_algorithm_data.height = frame.height; pThreadParam->tasks[i].task_algorithm_data.width = frame.width; pThreadParam->tasks[i].task_algorithm_data.size = frame.size; pThreadParam->tasks[i].frameImage = cv::Mat::zeros(frame.height, frame.width, CV_8UC3); - pThreadParam->tasks[i].taskDataToRT = (float*)malloc(3 * frame.height * frame.width * sizeof(unsigned char)); AddTaskTracker(pThreadParam->VPT_Handle, pThreadParam->tasks[i].taskID, 1, 1); } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h index 4c8dd4d..bc97514 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h @@ -147,7 +147,6 @@ struct Task{ TaskState taskState; DxDecoderWrap *taskTcuvid; DxGPUFrame task_algorithm_data; //����¿�ܲ���resize�Ĵ���������ʱ��backup��ԭͼ��С��ͼƬ�ͽ��㷨������� - float* taskDataToRT; bool taskHasBackup; //VideoHeightWidth taskHeightWidthRatio; VideoHeightWidth taskHeightWidth; 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 b71cdbd..0143014 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 @@ -404,49 +404,48 @@ int VPT_Process_GPU(void * handle, sy_img * batch_img, int startBatch, int batch for (int i = startBatch; i < tools->taskTrackers.size(); i++) { - if (!tools->taskTrackers[i].tracker.GetState()) { + TaskTracker task_tracker = tools->taskTrackers[i]; + if (!task_tracker.tracker.GetState()) { continue; } - //cout << "task index : " << i << " lastFrameIndex: " << tools->taskTrackers[i].lastFrameIndex << " cur_frameIndex:" << vec_frameIndex[detectIndex] << endl; - int width = 1920; int height = 1080; - if (tools->taskTrackers[i].lastFrameIndex <= 0) { + if (task_tracker.lastFrameIndex <= 0) { // 第一帧,只做带检测框的跟踪 - int objCount = tools->taskTrackers[i].tracker.update(/*tools->param.w*/width* tools->taskTrackers[i].ratioWidth, /*tools->param.h*/height* tools->taskTrackers[i].ratioHeight, true, detectResult[detectIndex], result[resIndex].obj, deleteObjectID[detectIndex]); + int objCount = task_tracker.tracker.update(task_tracker.ratioWidth, task_tracker.ratioHeight, true, detectResult[detectIndex], result[resIndex].obj, deleteObjectID[detectIndex]); result[resIndex].objCount = objCount; vector>().swap(detectResult[detectIndex]); detectResult[detectIndex].clear(); - tools->taskTrackers[i].lastFrameIndex = vec_frameIndex[detectIndex]; + task_tracker.lastFrameIndex = vec_frameIndex[detectIndex]; continue; } - int update_times = vec_frameIndex[detectIndex] - tools->taskTrackers[i].lastFrameIndex - 1; + int update_times = vec_frameIndex[detectIndex] - task_tracker.lastFrameIndex - 1; if (update_times < 0) { - cout << "FrameIndex error !! lastFrameIndex= "<< tools->taskTrackers[i].lastFrameIndex <<" cur_frameindex = " << vec_frameIndex[detectIndex] << endl; + cout << "FrameIndex error !! lastFrameIndex= "<< task_tracker.lastFrameIndex <<" cur_frameindex = " << vec_frameIndex[detectIndex] << endl; } - // cout << "lastFrameIndex= " << tools->taskTrackers[i].lastFrameIndex << " cur_frameindex = " << vec_frameIndex[detectIndex] << endl; + // cout << "lastFrameIndex= " << task_tracker.lastFrameIndex << " cur_frameindex = " << vec_frameIndex[detectIndex] << endl; // cout << "update_times = " << update_times << endl; for (int j = 0; j < update_times; j++) { // 无检测框跟踪 - //cout << "taskTrackers size: " << tools->taskTrackers.size() << " batchsize:" << detectResult.size() << " update_times: "<< update_times << endl; + //cout << "taskTrackers size: " << task_tracker.size() << " batchsize:" << detectResult.size() << " update_times: "<< update_times << endl; VPT_Result unresult; VPT_ObjInfo obj[MAX_OBJ_COUNT]; - unresult.objCount = tools->taskTrackers[i].tracker.update(/*tools->param.w*/width* tools->taskTrackers[i].ratioWidth, /*tools->param.h*/height* tools->taskTrackers[i].ratioHeight, false, detectResult[detectIndex], unresult.obj, deleteObjectID[detectIndex]); + unresult.objCount =task_tracker.tracker.update(task_tracker.ratioWidth, task_tracker.ratioHeight, false, detectResult[detectIndex], unresult.obj, deleteObjectID[detectIndex]); check_VPT_Result(unresult); unUsedResult[resIndex].push_back(unresult); } //有检测框输入的跟踪 - int objCount = tools->taskTrackers[i].tracker.update(/*tools->param.w*/width* tools->taskTrackers[i].ratioWidth, /*tools->param.h*/height* tools->taskTrackers[i].ratioHeight, true, detectResult[detectIndex], result[resIndex].obj, deleteObjectID[detectIndex]); + int objCount = task_tracker.tracker.update(task_tracker.ratioWidth, task_tracker.ratioHeight, true, detectResult[detectIndex], result[resIndex].obj, deleteObjectID[detectIndex]); result[resIndex].objCount = objCount; vector>().swap(detectResult[detectIndex]); detectResult[detectIndex].clear(); // 记录帧序号 - tools->taskTrackers[i].lastFrameIndex = vec_frameIndex[detectIndex]; + task_tracker.lastFrameIndex = vec_frameIndex[detectIndex]; check_VPT_Result(result[resIndex]); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/FaceDetModule.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/FaceDetModule.cpp index c10b829..0d73b33 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/FaceDetModule.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/FaceDetModule.cpp @@ -102,15 +102,10 @@ int face_det_module::face_det_module_init(int gpuid, char* auth_license) int face_det_module::face_det_module_process(sy_img* img, int batchsize, fd_result *face_det_result, sy_point* original_size) { - //static int framcount = 0; - //printf("framcount: %d\n", framcount++); if (sy_process_param_check(m_face_det_handle, img, batchsize) == FAILED) return FAILED; sy_img *cpu_img = new sy_img[batchsize]; - //unsigned char** data = new unsigned char*[batchsize]; - cv::Mat *human_image = new cv::Mat[batchsize]; - cv::Mat *human_image_ori = new cv::Mat[batchsize]; for (int b = 0; b < batchsize; b++) { cpu_img[b].c_ = 3; @@ -134,33 +129,16 @@ int face_det_module::face_det_module_process(sy_img* img, int batchsize, fd_resu for (int b = 0; b < batchsize; b++) { int real_count = 0; - // cv::Mat tmp_img(img[b].h_, img[b].w_, CV_8UC3, cpu_img[b].data_); for (int c = 0; c < face_det_result[b].count; c++) { if (face_det_result[b].info[c].score >= 0.5) { - /*printf("score: %f\n", face_det_result[b].info[c].score); - cv::rectangle(tmp_img, cv::Rect(face_det_result[b].info[0].face_position.left_, - face_det_result[b].info[0].face_position.top_, - face_det_result[b].info[0].face_position.width_, - face_det_result[b].info[0].face_position.height_), cv::Scalar(25, 250, 25), 2, 8, 0); - cv::imshow("face", tmp_img); - cv::waitKey(0);*/ - - /*printf("face det: %d %d %d %d %d %d\n", face_det_result[b].info[0].face_position.left_, - face_det_result[b].info[0].face_position.top_, - face_det_result[b].info[0].face_position.width_, - face_det_result[b].info[0].face_position.height_, - face_det_result[b].info[0].facial_fea_point[0].x_, - face_det_result[b].info[0].facial_fea_point[0].y_);*/ - memcpy((void*)&face_det_result[b].info[real_count], (void*)&face_det_result[b].info[c], sizeof(fd_info)); real_count++; } } face_det_result[b].count = real_count; } - for (int b = 0; b < batchsize; b++) { if(cpu_img[b].data_) { @@ -168,8 +146,6 @@ int face_det_module::face_det_module_process(sy_img* img, int batchsize, fd_resu } } if (cpu_img) delete[] cpu_img; - if (human_image) delete[] human_image; - if (human_image_ori) delete[] human_image_ori; return ret; }