header.hold
8.83 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#pragma once
#ifdef _MSC_VER
#include <windows.h>
#else
#include <stddef.h>
#endif
#include "sy_common.h"
#define DETECTTYPE 9
#ifndef VD_INFO_
#define VD_INFO_
//结果
typedef struct vd_info
{
sy_rect rect;
float score;
}vd_info;
#endif
#ifndef VCWD_INFO_
#define VCWD_INFO_
//结果
typedef struct vcwd_info
{
vd_info c_info; //车辆信息
vd_info w_info; //车窗信息
}vcwd_info;
#endif
#ifndef VCWD_RESULT_
#define VCWD_RESULT_
#define VD_MAXDETECTCOUNT 100 //车头车尾数量最大值
#define FEATURESIZE 256
typedef struct vcwd_result
{
vcwd_info * vhd_info; //车头信息
int h_count; //车头数量
vcwd_info * vrd_info; //车尾信息
int r_count; //车尾数量
}vcwd_result;
#endif
//二次属性分析结果结构体
#ifndef __HF_OBJ_RESULT__
#define __HF_OBJ_RESULT__
const int Hf_FIR_INDEX_SIZE = 1280;
typedef struct hf_result
{
float res_objs[Hf_FIR_INDEX_SIZE]{}; //分类结果
} hf_result;
#endif
//二次属性分析结果结构体
#ifndef __CLASSIFY_OBJ_RESULT__
#define __CLASSIFY_OBJ_RESULT__
typedef struct classify_obj_res //分类结果结构体
{
int res_index; //分类结果
float res_prob; //分类结构体
classify_obj_res() : res_index(0), res_prob(0) {};
} classify_obj_res;
#endif
#ifndef __HF_FEA_RESULT__
#define __HF_FEA_RESULT__
const int HF_FEA_SIZE = 576;
#endif
#ifndef __HP_OBJ_RESULT__
#define __HP_OBJ_RESULT__
const int HP_FIR_INDEX_SIZE = 16;
typedef struct hp_res
{
classify_obj_res res_objs[HP_FIR_INDEX_SIZE]; //分类结果
float feature[HF_FEA_SIZE]; //行人特征
} hp_res;
#endif
typedef struct hp_result
{
hp_res res_objs{}; //分类结果
float feature[Hf_FIR_INDEX_SIZE]{}; //特征
} hp_result;
#ifndef __HCF_FEA_RES__
#define __HCF_FEA_RES__
const int HCF_FEA_SIZE = 1280;
#endif
#ifndef __HCP_OBJ_RESULT__
#define __HCP_OBJ_RESULT__
const int HCP_FIR_INDEX_SIZE = 14;
typedef struct hcp_res
{
classify_obj_res res_objs[HCP_FIR_INDEX_SIZE]; //分类结果
float feature[HCF_FEA_SIZE]; //人骑车特征
} hcp_res;
#endif
typedef struct hcp_result
{
hcp_res res_objs{}; //分类结果
float feature[Hf_FIR_INDEX_SIZE]{}; //特征
} hcp_result;
//VEHICLE
#define PLATENUM 8 //车牌号码位数
#define MAX_PALTE_COUNT 10 //每张图片中最多检测出10个车牌
#define SINGLETYPE_BLUE 0 //单排蓝色
#define SINGLETYPE_YELLOW 1 //单排黄色
#define SINGLETYPE_WHITE 2 //单排白色
#define SINGLETYPE_BLACK 3 //单排黑色
#define DOUBLETYPE_YELLOW 4 //双排黄色
#define DOUBLETYPE_WHITE 5 //双排白色
#define NEWENERGYTYPE_YELLOWGREEN 6 //新能源黄绿色
#define NEWENERGYTYPE_WHITEGRA 7 //新能源白绿色
//车牌号码
#ifndef VPLATENUM_RESULT_
#define VPLATENUM_RESULT_
typedef struct vplate_num
{
char character[4]; //识别结果字符
float maxprob; //识别置信度
}vplate_num;
#endif
#ifndef VP_RESULT_
#define VP_RESULT_
typedef struct vplate_result
{
sy_rect rect; //位置
float detect_score; //检测置信度
vplate_num recg[PLATENUM]; //识别结果
float num_score; //识别置信度
int type; //车牌类型
}vplate_result;
#endif
#ifndef VR_RESULT_
#define VR_RESULT_
typedef struct vr_result //结果
{
char vehicle_brand[260]; //车辆品牌
char vehicle_subbrand[260]; //车辆子品牌
char vehicle_issue_year[260]; //车辆年款
char vehicle_type[260]; //车辆类型
char freight_ton[260]; //货车吨级
float name_score; //识别置信度
}vr_result;
#endif
//2.车颜色结果
#ifndef VC_RESULT_
#define VC_RESULT_
typedef struct vc_result
{
float score;
int index;
}vc_result;
#endif
//#ifndef __VEHICLE_RESULT__
//#define __VEHICLE_RESULT__
//typedef struct vehicle_res //车二次属性分析结果
//{
// vr_result vr_res; //车型识别结果
// vc_result vc_res; //车颜色识别结果
// vplate_result vp_res; //车牌检测结果
//} vehicle_res;
//
//#endif
#ifndef __VEHICLE_RESULT__
#define __VEHICLE_RESULT__
typedef struct vehicle_result //车二次属性分析结果
{
vr_result vr_res; //车型识别结果
vc_result vc_res; //车颜色识别结果
vplate_result vp_res; //车牌检测结果
float feature[FEATURESIZE]{}; //车辆特征
} vehicle_result;
#endif
//返回的检测物体快照结果
#ifndef __VIDEO_OBJECT_SNAPSHOT__
#define __VIDEO_OBJECT_SNAPSHOT__
typedef struct video_object_snapshot
{
int task_id; //该物体属于的任务ID号
int object_id; //该物体的ID号
char video_image_path[256]; //该物体快照的视频截图保存路径
char snapshot_image_path[256]; //该物体快照抠图保存路径
int object_type_index; //该物体所属类别的索引
char obj_type[64]; //该物体属于的类别
double progress; //该路视频的检测进度
int left; //该物体位置的左坐标
int top; //该物体位置的上坐标
int right; //该物体位置的右坐标
int bottom; //该物体位置的下坐标
double confidence; //置信度
void* analysisRes; //二次属性分析结果
} video_object_snapshot;
#endif
//返回的检测物体结果信息
#ifndef __VIDEO_OBJECT_INFO__
#define __VIDEO_OBJECT_INFO__
typedef struct video_object_info
{
int task_id; //该物体属于的任务ID号
int task_frame_count; //该物体当前出现的帧号
int object_id; //该物体的ID号
int left; //该物体位置的左坐标
int top; //该物体位置的上坐标
int right; //该物体位置的右坐标
int bottom; //该物体位置的下坐标
int index; //该物体所属类别的编号
double confidence; //该物体的置信度
} video_object_info;
#endif
//回调函数,通知处理结束的视频,返回任务ID号
typedef void(*VIDEO_OBJECT_INFO_CALLBACK)(void * handle, video_object_info *obj_info);
//回调函数,返回检测物体的快照信息
typedef void(*VIDEO_OBJECT_SNAPSHOT_CALLBACK)(void * handle, video_object_snapshot *snapshot_info);
//回调函数,返回实时查看时视频的图像
typedef void(*VIDEO_REALTIME_CALLBACK)(void * handle, unsigned char *img_data, int img_height, int img_width);
//回调函数,通知处理结束的视频,返回任务ID号
typedef void(*VIDEO_FINISH_CALLBACK)(void * handle, const int task_id);
//TASK初始化参数
#ifndef __TASK_PARAM__
#define __TASK_PARAM__
typedef struct task_param
{
const char* video_filename;
const char* result_folder_little;
const char* result_folder;
sy_rect minBoxsize[DETECTTYPE]; //自定义的minBoxsize大小
VIDEO_OBJECT_SNAPSHOT_CALLBACK obj_snapshot_callback_func;
VIDEO_REALTIME_CALLBACK rt_view_callback_func;
}task_param;
#endif
//VPT初始化参数
#ifndef __MVPT_PARAM__
#define __MVPT_PARAM__
typedef struct mvpt_param
{
int gpuid; //指定显卡id
char* vrdbpath; //指定车行识别的车型数据库的路径
//算法配置参数
sy_command hp_analysis_config; //是否开启行人结构化识别
sy_command hcp_analysis_config; //是否开启人骑车结构化识别
sy_command vehicle_analysis_config; //是否开启车型识别
sy_command hf_recg_config; //是否开启行人特征识别
sy_command hcf_recg_config; //是否开启人骑车特征识别
sy_command vcf_recg_config; //是否开启车辆特征识别
VIDEO_OBJECT_INFO_CALLBACK task_obj_info_callback_func; //目标检测结果实时返回回调函数
VIDEO_FINISH_CALLBACK task_finish_callbackfunc; //任务分析结束结果回调函数
}mvpt_param;
#endif
#ifndef _MSC_VER
#include <sys/time.h>
#define MACRO_COUNT_TIME_START struct timeval macro_tv_start;\
struct timeval macro_tv_end;\
gettimeofday(¯o_tv_start,NULL);
#define MACRO_COUNT_TIME_END(___total_count___) gettimeofday(¯o_tv_end,NULL);\
if(___total_count___<=0)\
printf("time cost: %.2f ms \n", ( (double)(macro_tv_end.tv_sec-macro_tv_start.tv_sec)*1000000+(double)(macro_tv_end.tv_usec-macro_tv_start.tv_usec) )/1000);\
else\
printf("time cost: %.2f ms \n", ( (double)(macro_tv_end.tv_sec-macro_tv_start.tv_sec)*1000000+(double)(macro_tv_end.tv_usec-macro_tv_start.tv_usec) )/1000/___total_count___);
#endif