VPT.h 4.5 KB
/*******************************************************************************************
* Version: VPT_V4.0.4
* CopyRight: 中科院自动化研究所模式识别实验室图像视频组
* UpdateDate: 20190701
* Content: 人车物监测跟踪
********************************************************************************************/
#ifndef VPT_H_
#define VPT_H_

#ifdef _MSC_VER
#ifdef VPT_EXPORTS
#define VPT_API __declspec(dllexport)
#else
#define VPT_API __declspec(dllimport)
#endif
#else
#define VPT_API __attribute__ ((visibility ("default")))
#endif

#include <stdio.h>
#include "header.h"     //回调函数定义头文件
#include <vector>

using namespace std;

typedef struct VPT_ObjInfo	//检测物体结果结构体
{
	int left;                //检测结果左坐标
	int top;                 //检测结果上坐标
	int right;               //检测结果右坐标
	int bottom;              //检测结果下坐标
	int center_x;            //检测结果中心位置X坐标
	int center_y;            //检测结果中心位置Y坐标
	int index;			         //行人/车辆类别,支持9类
	long id;			           //目标唯一ID,同一ID为同一目标
	double confidence;	     //置信度
}VPT_ObjInfo;


typedef struct VPT_Result           //检测结果结构体
{
	int objCount;                     //检测到物体总数
	VPT_ObjInfo *obj;                 //各个物体的结果信息
}VPT_Result;


//规定9个检测种类的最小检测框
//行人 自行车 摩托车 三轮车 小型车 大车 卡车 拖拉机 中巴
const int DETECTTYPE = 9;
const int EDGES = 4;

typedef struct MRECT                                    //检测框
{
	int width;                                           //检测框宽度
	int height;                                          //检测框高度
	MRECT(){ width = 0; height = 0; }                    //构造函数
	MRECT(int w, int h){ width = w; height = h; }        //构造函数
}MRECT;


typedef struct SNAPSHOT_PARAMETER
{
	bool selectFromMinbox;                               //选取快照时,是否需要剔除掉小于Minbox的快照      
	bool selectFromMindistance;                          //选取快照时,是否需要剔除掉距边框的距离小于minDistance的快照
	MRECT minBoxsize[DETECTTYPE];                        //自定义的minBoxsize大小
	int minDistance[EDGES];                              //自定义的minDistance大小
	SNAPSHOT_PARAMETER(){ selectFromMinbox = true;  selectFromMindistance = true; }     //构造函数
}SNAPSHOT_PARAMETER;


typedef struct VPT_PARAM                   //VPT设置参数结构体
{
	int gpuid;                               //显卡ID号
	int maxResultCount;                      //最大检测前景个数
	SNAPSHOT_PARAMETER  *SnaoshotParameter;  //快照保存参数设置

	VPT_PARAM(){ SnaoshotParameter = NULL; }
}VPT_PARAM;


/*************************************************************************
* FUNCTION: VPT_Init
* PURPOSE: 初始化
* PARAM:
[in] handle		                    - 句柄
[in] vparam		                    - 参数
[in] resDir                       - 快照保存路径
[in] VideoObjSnapshotCallBack     - 结果返回回调函数
* RETURN:	成功(0)或错误代码(< 0)
* NOTES:
*************************************************************************/
VPT_API int VPT_Init(void *&handle, VPT_PARAM vparam, char* resDir, VIDEO_OBJECT_SNAPSHOT_CALLBACK VideoObjSnapshotCallBack = NULL);


/*************************************************************************
* FUNCTION: VPT_ResetTracker
* PURPOSE: 重置跟踪器
* PARAM:
[in] handle		        - 操作句柄
* RETURN:	NULL
* NOTES:
*************************************************************************/
VPT_API void VPT_ResetTracker(void * handle);


/*************************************************************************
* FUNCTION: VPT_Process
* PURPOSE: 人车物检测跟踪
* PARAM:
[in] handle		      - 处理句柄
[in] rgb		        - 图片数据(3通道BGR数据 cv::Mat格式)
[in] width		      - 图片宽度
[in] height		      - 图片高度
[in] channels	      - 图片通道数
[in] frameCount	    - 视频当前的帧数
[in] result		      - 目标检测结果
[in] showTrack      - 是否显示轨迹
* RETURN:	成功(0)或错误代码(< 0)
* NOTES:
*************************************************************************/
VPT_API int VPT_Process(void * handle, unsigned char *bgr, int width, int height, int channels, int frameCount, VPT_Result *result, bool showTrack);


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


#endif