VPTProcess.h 4.23 KB
/*******************************************************************************************
* Version: VPT_x64_V2.0.0_20170705
* CopyRight: 中科院自动化研究所模式识别实验室图像视频组
* UpdateDate: 20170705
* Content: 人车物监测跟踪
********************************************************************************************/
#pragma once
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include "utools.h"
#include <vector>
using namespace std;
#define VTTYPECOUNT 10		//支持的最大类别数
#define MAX_OBJ_COUNT 100
typedef struct VPT_ObjInfo	//结果结构体
{
	int left;
	int top;
	int right;
	int bottom;
	int center_x;
	int center_y;
	int index;				//	行人/车辆类别,支持10类
	long id;					//	目标唯一ID,同一ID为同一目标
	int num;				//	该ID序列下的第num帧
	double confidence;		//	置信度
        int snap_flag;
}VPT_ObjInfo;

typedef struct VPT_Result
{
	int objCount;
	VPT_ObjInfo obj[MAX_OBJ_COUNT];
}VPT_Result;


typedef struct VPTProcess_PARAM
{
	int mode;				//运行模式(DEVICE_GPU / DEVICE_CPU)
	int gpuid;              //指定显卡id
	float threshold;
	int max_batch;
	int engine;    //指定运行引擎(ENGINE_MCAFFE2 / ENGINE_TENSORRT)
	char* preprocess_param;
	char* serialize_file;
	VPTProcess_PARAM() :mode(DEVICE_GPU), gpuid(0), threshold(0.6), max_batch(20) {};
}VPTProcess_PARAM;


/*************************************************************************
* FUNCTION: VPT_Init
* PURPOSE: 初始化
* PARAM:
[in] vparam		参数
* RETURN:	handle
* NOTES:
*************************************************************************/
int VPT_Init(void *&handle, VPTProcess_PARAM vparam);

/*************************************************************************
* FUNCTION: VPT_Process
* PURPOSE: 人车物检测跟踪
* PARAM:
[in] handle		- 处理句柄
[in] rgb		- 图片数据(3通道BGR数据 cv::Mat格式)
[in] width		- 图片宽度
[in] height		- 图片高度
[in] result		- 搜索结果,在外部申请足够内存
[out] traffic	- 交通流量结果结构体 内存在外部申请,大小与初始化时流量监测线个数相同,设置为NULL时不返回
* RETURN:	-1:图像错误; 其他:检测到的个数
* NOTES:
*************************************************************************/
int VPT_Process(void * handle, unsigned char ** bgr, int batchsize, VPT_Result * result);

/*************************************************************************
* FUNCTION: VPT_Process
* PURPOSE: 人车物检测跟踪
* PARAM:
[in] handle		    - 处理句柄
[in] rgb		    - 图片数据(3通道BGR数据 cv::Mat格式)
[in] width		    - 图片宽度
[in] height		    - 图片高度
[in] result		    - 搜索结果,在外部申请足够内存
[in] deleteObjectID - 删除的轨迹ID号
[out] traffic	- 交通流量结果结构体 内存在外部申请,大小与初始化时流量监测线个数相同,设置为NULL时不返回
* RETURN:	-1:图像错误; 其他:检测到的个数
* NOTES:
*************************************************************************/
//startBatch  多batch为了减少显存,串行处理  - add by lm
//int VPT_Process_GPU(void * handle, float * bgr, int width, int height, int startBatch, int batchsize, VPT_Result * result, vector<vector<int>>& deleteObjectID);
int VPT_Process_GPU(void * handle,  sy_img * batch_img,  int startBatch, int batchsize, vector<VPT_Result>& result, vector<vector<int>>& deleteObjectID);

/*************************************************************************
* FUNCTION: VPT_ProcessImage
* PURPOSE: 人车物检测-图片
* PARAM:
[in] handle		- 处理句柄
[in] rgb		- 图片数据(3通道BGR数据 cv::Mat格式)
[in] width		- 图片宽度
[in] height		- 图片高度
[in] result		- 搜索结果,在外部申请足够内存
* RETURN:	-1:图像错误; 其他:检测到的个数
* NOTES:
*************************************************************************/
int VPT_ProcessImage(void * handle, unsigned char ** bgr, int batchsize, VPT_Result * result);

/*************************************************************************
* FUNCTION: VPT_Release
* PURPOSE: 资源释放
* PARAM:
[in] handle		- 处理句柄
* RETURN:	NULL
* NOTES:
*************************************************************************/
void VPT_Release(void * handle);



void AddTaskTracker(void * handle, const int taskID, const double rWidth, const double rHeight);
void FinishTaskTracker(void * handle, const int taskID);
void PauseTaskTracker(void * handle, const int taskID);
void RestartTaskTraker(void * handle, const int taskID);
void DrawTracker(void * handle, const int taskID, cv::Mat *img);