//#pragma once #ifndef __MutliSourceVideoProcess_H__ #define __MutliSourceVideoProcess_H__ #include #include #include "nvml.h" #include "time.h" #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include "VPTProcess.h" #include #include #include #include "common.h" #include "../cuda_src/ImageSaveGPU.h" #include "mvpt_process_assist.h" #include "snapshot_helper.h" #include #ifdef _MSC_VER #ifdef _DEBUG #pragma comment(lib, "opencv_world310d.lib") #else #pragma comment(lib, "opencv_world310.lib") #endif #endif using namespace cv; using namespace std; #ifndef _MSC_VER #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define Sleep(a) usleep((a)*1000) //typedef int BOOL; #define BOOL bool typedef unsigned int DWORD; typedef void* LPVOID; #endif #ifdef _DEBUG #define DEBUG_MSG(msg,...) \ { \ printf("%s %s [%d]: ", __FILE__, __FUNCTION__, __LINE__); \ printf(msg,##__VA_ARGS__); \ printf("\n"); \ } #else #define DEBUG_MSG(msg,...) #endif #define MAXLENGTH 416 #define MINLENGTH 224 #define THREAD_COUNT 30 #define SNAPSHOTFRAME 15 #define LOSTMAXFRAMECCOUNT 4 #define MAX_BATCH 10 struct VideoObjectSS { unsigned char * obj_person; unsigned char * obj_bike; unsigned char * obj_car; VideoObjectSS() : obj_person(NULL), obj_bike(NULL), obj_car(NULL){} }; enum TaskOperator { ADDTASK, PAUSETASK, RESTARTTASK, FINISHTASK }; struct Operator{ int changeTaskID; char videoFileName[256]; char resultFolderLittleName[256]; char resultFolderName[256]; char result_folder_face[256]; bool on_image_display; int jpeg_quality; int decMode; TaskOperator changeTaskOperator; VIDEO_OBJECT_SNAPSHOT_CALLBACK taskObjCallbackFunc; VIDEO_REALTIME_CALLBACK taskRealTimeCallbackFunc; VIDEO_FINISH_CALLBACK tFinishCallbackFunc; sy_rect minBoxsize[DETECTTYPE]; SFX_LOG_CALLBACK taskSfxLogFunc; void* logUserPtr; }; class CMutliSourceVideoProcess { public: CMutliSourceVideoProcess(); ~CMutliSourceVideoProcess(); int InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_INFO_CALLBACK tObjInfoCallbackFunc); int get_task_progress(int taskid, double & progress); void OperatorTask(); void AddOperator(int taskID, int taskOper); int AddOperator(task_param tparam); void callTaskObjInfoCallbackFunc(const VPT_Result& vptResult, int taskFrameCount, int taskId); bool AddTask(task_param tparam); void PauseTask(const int taskID); void RestartTask(const int taskID); void FinishTask(const int taskID); void ViewTask(const int taskID); void FinishViewTask(); int FinishProcessThread(); int GetRuningNb(); void algorthim_process(); public: int section_batch_size; int licence_status; int thrd_status; int mgpuid; int skip_frame_ {5}; // 控制跳帧参数 map m_taskMap; int AddTaskSucFlag; //0:��ʼ��״̬ 1����������ɹ� -1����������ʧ�� int TotalTask; int viewTaskID; OBJECT_INFO_CALLBACK taskObjInfoCallbackFunc {nullptr}; std::mutex taskMutex; std::condition_variable taskCondVar; //�㷨���ò��� sy_command m_hp_analysis_config; //�Ƿ���������ʶ�� sy_command m_hcp_analysis_config; //�Ƿ��������Ƽ��ʶ�� sy_command m_vehicle_analysis_config; //�Ƿ�����������ɫʶ�� sy_command m_vehicle_recg_config; //�Ƿ�������������ʶ�� sy_command m_vehicle_plate_det_recg_config; //�Ƿ�������Υ����Ϊ��� sy_command m_hf_recg_config; //�Ƿ�����������ʶ�� sy_command m_hcf_recg_config; //�Ƿ������ﳵ����ʶ�� sy_command m_vcf_recg_config; //�Ƿ�����������ʶ�� sy_command m_face_det_config; //�Ƿ���������� snapshot_helper m_snaphot_helper; bool m_bExit{false}; private: bool m_bProcessExit{false}; VPTProcess m_vptProcess; std::thread ProcessThread; std::mutex _tx_add_task; deque TaskOperatorQ; int capacity; double gpu_total_memory; std::thread thrd; }; #endif