Blame view

src/VPT-1/VPTProcess.h 4.23 KB
e30d6793   Zou XiKun   v0.0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  /*******************************************************************************************
  * 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);