Commit 1ebb33a8d80b62de731f6ac5ddc7aaf872de2b85
1 parent
b6c85a1e
图搜代码加入到项目中一起编译,方便调试bug
Showing
4 changed files
with
4142 additions
and
2 deletions
build/src/Makefile
@@ -15,6 +15,7 @@ ACL_PATH = $(ASCEND_AICPU_PATH)/acllib | @@ -15,6 +15,7 @@ ACL_PATH = $(ASCEND_AICPU_PATH)/acllib | ||
15 | OPENCV_PATH = $(PROJ_ALL_PATH)/3rdparty/opencv_4_1 | 15 | OPENCV_PATH = $(PROJ_ALL_PATH)/3rdparty/opencv_4_1 |
16 | SPDLOG_ROOT = $(PROJ_ALL_PATH)/3rdparty/spdlog-1.9.2/release | 16 | SPDLOG_ROOT = $(PROJ_ALL_PATH)/3rdparty/spdlog-1.9.2/release |
17 | ALGORITHM_PATH = $(PROJ_ALL_PATH)/algorithm | 17 | ALGORITHM_PATH = $(PROJ_ALL_PATH)/algorithm |
18 | +VA_PATH = /home/cmhu/village_ascend_arm/atlas300ipro_pic_search | ||
18 | 19 | ||
19 | INCLUDES = -I$(PROJ_ALL_PATH)/src/common \ | 20 | INCLUDES = -I$(PROJ_ALL_PATH)/src/common \ |
20 | -I$(PROJ_ALL_PATH)/src/common/dvpp \ | 21 | -I$(PROJ_ALL_PATH)/src/common/dvpp \ |
@@ -33,6 +34,20 @@ INCLUDES = -I$(PROJ_ALL_PATH)/src/common \ | @@ -33,6 +34,20 @@ INCLUDES = -I$(PROJ_ALL_PATH)/src/common \ | ||
33 | -I$(ALGORITHM_PATH)/vid_clothes2/vid_clothes \ | 34 | -I$(ALGORITHM_PATH)/vid_clothes2/vid_clothes \ |
34 | -I$(ALGORITHM_PATH)/hp2/hp \ | 35 | -I$(ALGORITHM_PATH)/hp2/hp \ |
35 | -I$(ALGORITHM_PATH)/hcp2/hcp \ | 36 | -I$(ALGORITHM_PATH)/hcp2/hcp \ |
37 | + -I$(VA_PATH)/vpt2/vpt \ | ||
38 | + -I$(VA_PATH)/vpd2/vpd \ | ||
39 | + -I$(VA_PATH)/vc2/vc \ | ||
40 | + -I$(VA_PATH)/vp2/vp \ | ||
41 | + -I$(VA_PATH)/vf_head2/vf_head \ | ||
42 | + -I$(VA_PATH)/vf_win2/vf_win \ | ||
43 | + -I$(VA_PATH)/vf_rear2/vf_rear \ | ||
44 | + -I$(VA_PATH)/vr2/vr \ | ||
45 | + -I$(VA_PATH)/vrr2/vrr \ | ||
46 | + -I$(VA_PATH)/vid2/vid \ | ||
47 | + -I$(VA_PATH)/vr_vehicle_type_15cls2/vr_vehicle_type_15cls \ | ||
48 | + -I$(VA_PATH)/vlogo2/vlogo \ | ||
49 | + -I$(VA_PATH)/vr_3885cls2/vr_3885cls \ | ||
50 | + -I$(VA_PATH)/hs2/hs \ | ||
36 | 51 | ||
37 | 52 | ||
38 | # CXXFLAGS = -O0 -std=c++11 $(INCLUDES) -DENABLE_DVPP_INTERFACE -D_GLIBCXX_USE_CXX11_ABI=0 | 53 | # CXXFLAGS = -O0 -std=c++11 $(INCLUDES) -DENABLE_DVPP_INTERFACE -D_GLIBCXX_USE_CXX11_ABI=0 |
@@ -49,10 +64,23 @@ local_shared_libs := \ | @@ -49,10 +64,23 @@ local_shared_libs := \ | ||
49 | ascendcl \ | 64 | ascendcl \ |
50 | acl_dvpp \ | 65 | acl_dvpp \ |
51 | spdlog \ | 66 | spdlog \ |
52 | - vehicle_analysis \ | ||
53 | vid_clothes \ | 67 | vid_clothes \ |
54 | hp \ | 68 | hp \ |
55 | hcp \ | 69 | hcp \ |
70 | + vpt_det \ | ||
71 | + vcolor \ | ||
72 | + vpd_process \ | ||
73 | + vehicle_recognition \ | ||
74 | + vehicle_rear_recognition \ | ||
75 | + vf_head \ | ||
76 | + vf_win \ | ||
77 | + vf_rear \ | ||
78 | + vid \ | ||
79 | + vpr_det \ | ||
80 | + vtype15 \ | ||
81 | + vlogo_dr_process \ | ||
82 | + vtype3885 \ | ||
83 | + hs_process \ | ||
56 | 84 | ||
57 | 85 | ||
58 | SHARED_LIBRARIES := $(foreach shared_lib, $(local_shared_libs), -l$(shared_lib)) | 86 | SHARED_LIBRARIES := $(foreach shared_lib, $(local_shared_libs), -l$(shared_lib)) |
src/ai_engine_module/VehicleAnalysisDevice.cpp
0 → 100644
1 | +#include "vehicle_analysis.h" | ||
2 | +#include "vehicle_result.h" | ||
3 | + | ||
4 | + | ||
5 | +#include "vpt.h" | ||
6 | + | ||
7 | +#include "vpd.h" | ||
8 | +#include "vid.h" | ||
9 | +#include "vf_head.h"//������-��ͷ | ||
10 | +#include "vf_win.h"//������-���� | ||
11 | +#include "vf_rear.h"//������-��β | ||
12 | +#include "vehicle_color.h" | ||
13 | +#include "vehicle_recognition.h" //��ͷ����ʶ�� | ||
14 | +#include "vehicle_rear_recognition.h" // ��β����ʶ�� | ||
15 | +#include "vehicle_plate_dr.h" | ||
16 | +//#include "vs_det_cls.h" | ||
17 | +//#include "muck_truck_cover.h" | ||
18 | +#include "vr_type.h" | ||
19 | +//#include "stain_vplate.h" | ||
20 | +//����ʶ��ʶ�� | ||
21 | +#include "vr_vehicle_type_15cls.h" //���Ͳ���ʶ��--����15���� | ||
22 | +#include "vehicle_logo_dr.h" //���Ͳ���ʶ��--��logoʶ�� | ||
23 | +#include "vr_vehicle_type_3885cls.h" //���Ͳ���ʶ��--���������� | ||
24 | + | ||
25 | +//MTAĦ�г����ֳ����� | ||
26 | +#include "human_car_parsing.h"//���ﳵ���������ͷ�����ԣ� | ||
27 | +#include "head_shoulder_det.h"//ͷ�磨����������ˣ� | ||
28 | + | ||
29 | + | ||
30 | +// #include "VehicleAnalysisDevice.h" | ||
31 | + | ||
32 | +#include "include.h" | ||
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | +#define SUCCESS 0 | ||
38 | + | ||
39 | +#define VD_MAXDETECTCOUNT 100 | ||
40 | +#define VPD_MAXNUM 300 | ||
41 | +#define FEATURESIZE 256 //�������� | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | +#define VR_HEAD_THRE 0.7 //��ͷ����ʶ����ֵ | ||
46 | +#define VR_REAR_THRE 0.8 //��β����ʶ����ֵ | ||
47 | +#define VR_CLS_THRE 0.25 //������������ֵ | ||
48 | +#define VR_CLS_OFFSET 0.3 //�������������Ŷ����ϸ���ֵ | ||
49 | +#define VR_LOGO_THRE 0.9 //��logo����ֵ | ||
50 | +#define VR_15CLS_THRE 0.8 //����15�������ֵ | ||
51 | + | ||
52 | +#define IF_DEBUG_INFO 0 //�Ƿ��ӡdebug��Ϣ | ||
53 | + | ||
54 | +#define VERSION_WUXI 0 //�л����а汾�������汾�������汾��ֻ��topn���������������Ͳ���ʶ�𣬵�Ҫ���ӳ���15������������ȱʧ�ij����͡� | ||
55 | +#define VR_WUXI_LOGO 1 //�����汾���Ƿ�����logo������ | ||
56 | +#define VPT_TOPN 10 //�˳���ȡtopn���з��� | ||
57 | + | ||
58 | +#define MAX_BATCHSIZE 10 | ||
59 | + | ||
60 | +using namespace std; | ||
61 | + | ||
62 | + | ||
63 | +//static int va_acl_flag=0; | ||
64 | + | ||
65 | +typedef struct va_handle | ||
66 | +{ | ||
67 | + void* vpt_handle; | ||
68 | + void* vc_handle; | ||
69 | + | ||
70 | + void* vr_handle;//����ʶ�� | ||
71 | + void* vrr_handle;//��β����ʶ�� | ||
72 | + void* vr_logo_dr_handle;//����ʶ��ʶ��(��ͷ��βlogoʶ��) | ||
73 | + void* vr_vr15cls_handle;//����ʶ��ʶ��(����15����) | ||
74 | + void* vr_vr3885cls_handle;//����ʶ��ʶ��(����������) | ||
75 | + | ||
76 | + void* vp_handle; | ||
77 | + void* vpd_handle; | ||
78 | + void* vid_handle; | ||
79 | + void* vf_head_handle; | ||
80 | + void* vf_win_handle; | ||
81 | + void* vf_rear_handle;//������� | ||
82 | + //void* vs_handle;//����Ʒ�ʶ�� | ||
83 | + //void* muck_truck_cover_handle; //�������Ǹ� | ||
84 | + | ||
85 | + //void* viq_handle; | ||
86 | + | ||
87 | + void* hcp_handle;//mta�е����ﳵ(Ħ�г���ʻԱͷ������) | ||
88 | + void* hs_handle;//���˷��� | ||
89 | + | ||
90 | + //void* stain_vp_handle;//�����ڵ�ʶ�� | ||
91 | + | ||
92 | + //void* vf_face_handle;//�������������� | ||
93 | + | ||
94 | + va_param param; //�Ѳ�������handle���� | ||
95 | + | ||
96 | + aclrtContext ctx; | ||
97 | + | ||
98 | + void *skt_handle = NULL;//��Ȩ | ||
99 | +}va_handle; | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | +int rect_driver_copilot(sy_rect vpd_rect, sy_rect body_rect); | ||
104 | +int process_vptresult( sy_img *imgdata, int batch_size, vpt_result * vpt_result_); | ||
105 | +void process_vpdresult(sy_rect body_rect, vpd_result * src, vpd_result * dest); | ||
106 | +sy_rect rect_extend(sy_rect obj_rect,int image_w,int image_h,float scale);//Ŀ���������� | ||
107 | +//int lorry_manned(va_handle *tools,sy_img * lorry_img, sy_rect win_rect, lorry_manned_result *result); | ||
108 | +//int process_vidresult(void * handle, int batch_size, va_result *result);//��Υ���복������ϲ��� | ||
109 | +int manned_analysis(va_handle *tools,sy_img * img, int type, sy_rect win_rect, manned_result *result); | ||
110 | +int process_vidresult_atlas(void * handle, int batch_size, va_result *result);//��Υ���복������ϲ���,atlas���Ƶģ���Υ�����ֻ�ò�ϵ��ȫ���IJ��ԣ� | ||
111 | +//void CvBGR2NV21(cv::Mat& bgr, unsigned char* yuv); | ||
112 | +int logo_strcmp(char * logo,char * brand); | ||
113 | +int logo_check_wuxi(char * logo); | ||
114 | +int vr_supplement_wuxi(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result);//�����汾�ij��Ͳ���ʶ�� | ||
115 | +int vr_supplement(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result);//���а汾�ij��Ͳ���ʶ�� | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | +const char * va_get_version() | ||
120 | +{ | ||
121 | + return "sy_va_version:1.2.0.20231129.atlas310p.arm.withOfflineAuthorization"; | ||
122 | +} | ||
123 | + | ||
124 | + | ||
125 | +int va_acl_init() | ||
126 | +{ | ||
127 | + if(IF_DEBUG_INFO) { | ||
128 | + LOG_INFO("start aclInit "); | ||
129 | + } | ||
130 | + ACL_CALL(aclInit(nullptr), ACL_ERROR_NONE, SY_FAILED); | ||
131 | + if(IF_DEBUG_INFO){ | ||
132 | + LOG_DEBUG("end aclInit "); | ||
133 | + } | ||
134 | + | ||
135 | + return SUCCESS; | ||
136 | +} | ||
137 | + | ||
138 | +int va_init(void ** handle, va_param param) | ||
139 | +{ | ||
140 | + string log_path = param.log_path + "/va.log"; | ||
141 | + | ||
142 | + set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days); | ||
143 | + | ||
144 | + va_handle *tools=new va_handle(); | ||
145 | + *handle=(void *)tools; | ||
146 | + | ||
147 | + int ret = SUCCESS; | ||
148 | + tools->param = param; | ||
149 | + | ||
150 | + | ||
151 | + string str1=tools->param.models_Path; | ||
152 | + | ||
153 | + | ||
154 | + LOG_DEBUG("start init Context "); | ||
155 | + int devId = tools->param.gpuid; | ||
156 | + LOG_INFO("devId:{}", devId); | ||
157 | + ACL_CALL(aclrtSetDevice(devId), ACL_ERROR_NONE, SY_FAILED); | ||
158 | + //aclrtContext ctx; | ||
159 | + //ACL_CALL(aclrtCreateContext(&ctx, devId), ACL_ERROR_NONE, SY_FAILED); | ||
160 | + ACL_CALL(aclrtCreateContext(&tools->ctx, devId), ACL_ERROR_NONE, SY_FAILED); | ||
161 | + LOG_DEBUG("end init Context "); | ||
162 | + | ||
163 | + //1.�������init | ||
164 | + if(tools->param.vehicle_detect_config==SY_CONFIG_OPEN) | ||
165 | + { | ||
166 | + LOG_DEBUG("vehicle_detect_config"); | ||
167 | + //string str2=str1 + "vtp0609.om"; | ||
168 | + string str2=str1 + "vpt0715_310p.om"; | ||
169 | + | ||
170 | + LOG_DEBUG("1.vpt init "); | ||
171 | + //vpt�˳����ʼ�� | ||
172 | + vpt_param vpt_param_; | ||
173 | + //vpt_param_.modelNames = "/home/HwHiAiUser/WH/vehicle_analysis202105/vehicle_analysis/all_models/vtp.om"; | ||
174 | + vpt_param_.modelNames = (char *)str2.c_str(); | ||
175 | + LOG_DEBUG("vpt modelNames:%s ",vpt_param_.modelNames); | ||
176 | + vpt_param_.threshold = tools->param.vehicle_det_thresld; | ||
177 | + vpt_param_.devId = tools->param.gpuid; | ||
178 | + vpt_param_.isTrk = false; | ||
179 | + | ||
180 | + int init_state=vpt_init(&(tools->vpt_handle), vpt_param_); | ||
181 | + if (init_state != SUCCESS) | ||
182 | + { | ||
183 | + //HIAI_ENGINE_LOG(HIAI_IDE_ERROR, "vpt_init failed"); | ||
184 | + LOG_ERROR("sy_va_va_init(error):vpt_init failed "); | ||
185 | + return init_state; | ||
186 | + } | ||
187 | + | ||
188 | + } | ||
189 | + | ||
190 | + //2.VPD 23����Լ��ʶ�� | ||
191 | + if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) | ||
192 | + { | ||
193 | + LOG_DEBUG("vehicle_pendant_det_config"); | ||
194 | + | ||
195 | + string str2=str1 + "vpd0629_310p.om"; | ||
196 | + | ||
197 | + LOG_DEBUG("2.1 vpd init "); | ||
198 | + vehicle_pendant_det_param vpdet_param; | ||
199 | + vpdet_param.dmodelNames = (char *)str2.c_str(); | ||
200 | + vpdet_param.devId = tools->param.gpuid; | ||
201 | + vpdet_param.dthresld = tools->param.vehicle_attribute_det_thresld; | ||
202 | + vpdet_param.dlogo_thresld = 0.5; | ||
203 | + | ||
204 | + int init_state=vpd_init(&(tools->vpd_handle), vpdet_param); | ||
205 | + if (init_state != SUCCESS) | ||
206 | + { | ||
207 | + LOG_ERROR("sy_va_va_init(error): vpd init end.(ret = {})", init_state); | ||
208 | + return init_state; | ||
209 | + } | ||
210 | + | ||
211 | + } | ||
212 | + | ||
213 | + //3.����ɫinit | ||
214 | + if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) | ||
215 | + { | ||
216 | + LOG_DEBUG("vehicle_color_config"); | ||
217 | + | ||
218 | + string str2=str1 + "carcolor310p.om"; | ||
219 | + | ||
220 | + LOG_DEBUG("3.vc init "); | ||
221 | + //vpt�˳����ʼ�� | ||
222 | + vc_param vc_param_; | ||
223 | + //vpt_param_.modelNames = "/home/HwHiAiUser/WH/vehicle_analysis202105/vehicle_analysis/all_models/vtp.om"; | ||
224 | + vc_param_.modelNames = (char *)str2.c_str(); | ||
225 | + vc_param_.thresld = tools->param.vc_thresld; | ||
226 | + vc_param_.devId = tools->param.gpuid; | ||
227 | + | ||
228 | + int ret=vc_init(&(tools->vc_handle), vc_param_); | ||
229 | + if (ret != SUCCESS) | ||
230 | + { | ||
231 | + //HIAI_ENGINE_LOG(HIAI_IDE_ERROR, "vc_init failed"); | ||
232 | + LOG_ERROR("sy_va_va_init(error):vc_init failed "); | ||
233 | + return ret; | ||
234 | + } | ||
235 | + | ||
236 | + } | ||
237 | + | ||
238 | + | ||
239 | + | ||
240 | + //4.VR����ʶ�� | ||
241 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) | ||
242 | + { | ||
243 | + LOG_DEBUG("vehicle_recg_config"); | ||
244 | + | ||
245 | + string str2=str1 + "vr_head0725_310p.om"; | ||
246 | + LOG_DEBUG("4.1.vr init "); | ||
247 | + vr_param vr_param_; | ||
248 | + vr_param_.modelNames = (char *)str2.c_str(); | ||
249 | + vr_param_.devId = tools->param.gpuid; | ||
250 | + vr_param_.db_path=tools->param.dbPath; | ||
251 | + int ret=vr_init(&(tools->vr_handle), vr_param_); | ||
252 | + if (ret != SUCCESS) | ||
253 | + { | ||
254 | + LOG_ERROR("sy_va_va_init(error): vr init end.(ret = {})", ret); | ||
255 | + return ret; | ||
256 | + } | ||
257 | + | ||
258 | + string str3=str1 + "vr_rear1230x_310p.om"; | ||
259 | + LOG_DEBUG("4.2.vrr init "); | ||
260 | + vrr_param vrr_param_; | ||
261 | + vrr_param_.modelNames = (char *)str3.c_str(); | ||
262 | + vrr_param_.devId = tools->param.gpuid; | ||
263 | + vrr_param_.db_path=tools->param.dbPath; | ||
264 | + ret=vrr_init(&(tools->vrr_handle), vrr_param_); | ||
265 | + if (ret != SUCCESS) | ||
266 | + { | ||
267 | + LOG_ERROR("sy_va_va_init(error): vrr init end.(ret = {})", ret); | ||
268 | + return ret; | ||
269 | + } | ||
270 | + | ||
271 | + if(VERSION_WUXI ) | ||
272 | + { | ||
273 | + if(VR_WUXI_LOGO) | ||
274 | + { | ||
275 | + LOG_DEBUG("4.3 start vlogodr_init "); | ||
276 | + | ||
277 | + string str2 = str1 + "vlogo_det310p.om"; | ||
278 | + | ||
279 | + vlogod_param vlogod_param_; | ||
280 | + vlogod_param_.dmodelNames = (char *)str2.c_str(); | ||
281 | + vlogod_param_.dthresld = tools->param.vehicle_logo_det_thresld; | ||
282 | + vlogod_param_.devId = tools->param.gpuid; | ||
283 | + | ||
284 | + string str3 = str1 + "vlogo_reg310p.om"; | ||
285 | + vlogor_param vlogor_param_; | ||
286 | + vlogor_param_.rmodelNames = (char *)str3.c_str(); | ||
287 | + vlogor_param_.rthresld = 0;//0.8 | ||
288 | + | ||
289 | + int init_state = vlogodr_init(&(tools->vr_logo_dr_handle),vlogod_param_, vlogor_param_); | ||
290 | + if (init_state != SUCCESS) | ||
291 | + { | ||
292 | + LOG_ERROR("sy_va_va_init(error): vlogodr_init end.(ret = {})", init_state); | ||
293 | + return init_state; | ||
294 | + } | ||
295 | + } | ||
296 | + | ||
297 | + LOG_DEBUG("4.4 start vr_vehicle_type_15cls_init "); | ||
298 | + string str6 = str1 + "vtype15_2106_310p.om"; | ||
299 | + vr_vehicle_type_15cls_param vehicle_type_15cls_params; | ||
300 | + vehicle_type_15cls_params.devId = tools->param.gpuid; | ||
301 | + vehicle_type_15cls_params.thresld = 0;//0.8 | ||
302 | + vehicle_type_15cls_params.modelNames = (char *)str6.c_str(); | ||
303 | + int init_state = vr_vehicle_type_15cls_init(&(tools->vr_vr15cls_handle), vehicle_type_15cls_params); | ||
304 | + if (init_state != SUCCESS) | ||
305 | + { | ||
306 | + LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_15cls_init end.(ret = {})", init_state); | ||
307 | + return init_state; | ||
308 | + } | ||
309 | + | ||
310 | + } | ||
311 | + if(!VERSION_WUXI && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN)//����ʶ��ʶ��logo���ʶ��+����15���ࣩ | ||
312 | + { | ||
313 | + LOG_DEBUG("vehicle_recg_supplement_config"); | ||
314 | + | ||
315 | + LOG_DEBUG("4.3 start vlogodr_init "); | ||
316 | + | ||
317 | + string str2 = str1 + "vlogo_det310p.om"; | ||
318 | + | ||
319 | + vlogod_param vlogod_param_; | ||
320 | + vlogod_param_.dmodelNames = (char *)str2.c_str(); | ||
321 | + vlogod_param_.dthresld = tools->param.vehicle_logo_det_thresld; | ||
322 | + vlogod_param_.devId = tools->param.gpuid; | ||
323 | + | ||
324 | + string str3 = str1 + "vlogo_reg310p.om"; | ||
325 | + vlogor_param vlogor_param_; | ||
326 | + vlogor_param_.rmodelNames = (char *)str3.c_str(); | ||
327 | + vlogor_param_.rthresld = 0;//0.8 | ||
328 | + | ||
329 | + int init_state = vlogodr_init(&(tools->vr_logo_dr_handle),vlogod_param_, vlogor_param_); | ||
330 | + if (init_state != SUCCESS) | ||
331 | + { | ||
332 | + LOG_ERROR("sy_va_va_init(error): vlogodr_init end.(ret = {})", init_state); | ||
333 | + return init_state; | ||
334 | + } | ||
335 | + | ||
336 | + LOG_DEBUG("4.4 start vr_vehicle_type_15cls_init"); | ||
337 | + string str6 = str1 + "vtype15_2106_310p.om"; | ||
338 | + vr_vehicle_type_15cls_param vehicle_type_15cls_params; | ||
339 | + vehicle_type_15cls_params.devId = tools->param.gpuid; | ||
340 | + vehicle_type_15cls_params.thresld = 0;//0.8 | ||
341 | + vehicle_type_15cls_params.modelNames = (char *)str6.c_str(); | ||
342 | + init_state = vr_vehicle_type_15cls_init(&(tools->vr_vr15cls_handle), vehicle_type_15cls_params); | ||
343 | + if (init_state != SUCCESS) | ||
344 | + { | ||
345 | + LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_15cls_init end.(ret = {})", init_state); | ||
346 | + return init_state; | ||
347 | + } | ||
348 | + | ||
349 | + LOG_DEBUG("4.5 start vr_vehicle_type_3885cls_init "); | ||
350 | + string str7 = str1 + "vtype3885x_310p.om"; | ||
351 | + vr_vehicle_type_3885cls_param vr_vehicle_type_3885cls_params; | ||
352 | + vr_vehicle_type_3885cls_params.devId = tools->param.gpuid; | ||
353 | + vr_vehicle_type_3885cls_params.modelNames = (char *)str7.c_str(); | ||
354 | + init_state = vr_vehicle_type_3885cls_init(&(tools->vr_vr3885cls_handle), vr_vehicle_type_3885cls_params); | ||
355 | + if (init_state != SUCCESS) | ||
356 | + { | ||
357 | + LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_3885cls_init end.(ret = {})", init_state); | ||
358 | + return init_state; | ||
359 | + } | ||
360 | + | ||
361 | + } | ||
362 | + } | ||
363 | + | ||
364 | + | ||
365 | + | ||
366 | + //5.VP���Ƽ��ʶ�� | ||
367 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
368 | + { | ||
369 | + LOG_DEBUG("vehicle_plate_det_recg_config"); | ||
370 | + | ||
371 | + string str2 = str1 + "yolo_plate_det310p.om"; | ||
372 | + | ||
373 | + LOG_DEBUG("5.vp init "); | ||
374 | + vpd_param vpd_param_; | ||
375 | + vpd_param_.modelNames = (char *)str2.c_str(); | ||
376 | + vpd_param_.devId = tools->param.gpuid; | ||
377 | + vpd_param_.thresld=tools->param.vehicle_plate_det_thresld; | ||
378 | + | ||
379 | + | ||
380 | + string str3 = str1 + "plate3cls_310p.om"; | ||
381 | + string str4 = str1 + "plate_reg230316_310p.om"; | ||
382 | + vpr_param vpr_param_; | ||
383 | + vpr_param_.cls_modelNames = (char *)str3.c_str(); | ||
384 | + vpr_param_.reg_modelNames = (char *)str4.c_str(); | ||
385 | + | ||
386 | + int init_state=vpdr_init(&(tools->vp_handle), vpd_param_, vpr_param_); | ||
387 | + if (init_state != SUCCESS) | ||
388 | + { | ||
389 | + LOG_ERROR("sy_va_va_init(error): vpdr init end.(ret = {})", init_state); | ||
390 | + return init_state; | ||
391 | + } | ||
392 | + } | ||
393 | + | ||
394 | + | ||
395 | + | ||
396 | + //6.VID���� | ||
397 | + if(tools->param.vehicle_illegal_config==SY_CONFIG_OPEN) | ||
398 | + { | ||
399 | + string str2 = str1 + "vid2x_310p.om"; | ||
400 | + | ||
401 | + LOG_DEBUG("6.vid init "); | ||
402 | + vid_param vid_param_; | ||
403 | + vid_param_.modelNames = (char *)str2.c_str(); | ||
404 | + vid_param_.nobody_thre = 0.8; | ||
405 | + vid_param_.phone_thre = 0.55;//0.7; | ||
406 | + vid_param_.call_thre = 0.6;//0.84; | ||
407 | + vid_param_.nosafebelt_thre = 0.9; | ||
408 | + vid_param_.smoke_thre = 0.85;//0.91; | ||
409 | + vid_param_.devId = tools->param.gpuid; | ||
410 | + int init_state=vid_init(&(tools->vid_handle), vid_param_); | ||
411 | + | ||
412 | + if (init_state != SUCCESS) | ||
413 | + { | ||
414 | + LOG_ERROR("sy_va_va_init(error): vid init end.(ret = {})", init_state); | ||
415 | + return init_state; | ||
416 | + } | ||
417 | + | ||
418 | + } | ||
419 | + | ||
420 | + | ||
421 | + | ||
422 | + //7.VF��������ȡ | ||
423 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
424 | + { | ||
425 | + LOG_DEBUG("vehicle_feature_config"); | ||
426 | + | ||
427 | + string str2 = str1 + "vf_headx310p.om"; | ||
428 | + LOG_DEBUG("7.1 vf head init "); | ||
429 | + vf_head_param vf_head_param_; | ||
430 | + vf_head_param_.modelNames = (char *)str2.c_str(); | ||
431 | + vf_head_param_.thresld = 0.65; | ||
432 | + vf_head_param_.devId = tools->param.gpuid; | ||
433 | + int init_state=vf_head_init(&(tools->vf_head_handle), vf_head_param_); | ||
434 | + if (init_state != SUCCESS) | ||
435 | + { | ||
436 | + LOG_ERROR("sy_va_va_init(error): vf head init end.(ret = {})", init_state); | ||
437 | + return init_state; | ||
438 | + } | ||
439 | + | ||
440 | + string str3 = str1 + "vf_winx_310p.om"; | ||
441 | + LOG_DEBUG("7.2 vf win init "); | ||
442 | + vf_win_param vf_win_param_; | ||
443 | + vf_win_param_.modelNames = (char *)str3.c_str(); | ||
444 | + vf_win_param_.thresld = 0.8; | ||
445 | + vf_win_param_.devId = tools->param.gpuid; | ||
446 | + init_state=vf_win_init(&(tools->vf_win_handle), vf_win_param_); | ||
447 | + if (init_state != SUCCESS) | ||
448 | + { | ||
449 | + LOG_ERROR("sy_va_va_init(error): vf win init end.(ret = {})", init_state); | ||
450 | + return init_state; | ||
451 | + } | ||
452 | + | ||
453 | + | ||
454 | + string str4 = str1 + "vf_rear1025_310p.om"; | ||
455 | + //������� | ||
456 | + LOG_DEBUG("7.3 vf rear init "); | ||
457 | + vf_rear_param param; | ||
458 | + param.modelNames = (char *)str4.c_str(); | ||
459 | + param.devId= tools->param.gpuid; | ||
460 | + param.thresld = 0.6; | ||
461 | + | ||
462 | + init_state=vf_rear_init(&(tools->vf_rear_handle), param); | ||
463 | + if (init_state != SUCCESS) | ||
464 | + { | ||
465 | + LOG_ERROR("sy_va_va_init(error): vf_rear init end.(ret = {})", init_state); | ||
466 | + return init_state; | ||
467 | + } | ||
468 | + } | ||
469 | + | ||
470 | + | ||
471 | + | ||
472 | + //motor���� | ||
473 | + if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) | ||
474 | + { | ||
475 | + LOG_DEBUG("vehicle_motor_tricycle_analysis_config"); | ||
476 | + | ||
477 | + string str2 = str1 + "hcp0629x_310p.om"; | ||
478 | + LOG_DEBUG("8.1 hcp init "); | ||
479 | + hcp_param hcp_param_; | ||
480 | + hcp_param_.modelNames = (char *)str2.c_str(); | ||
481 | + hcp_param_.devId = tools->param.gpuid; | ||
482 | + int init_state=hcp_init(&(tools->hcp_handle), hcp_param_); | ||
483 | + if (init_state != SUCCESS) | ||
484 | + { | ||
485 | + LOG_ERROR("sy_va_va_init(error): hcp_init end.(ret = {})", init_state); | ||
486 | + return init_state; | ||
487 | + } | ||
488 | + | ||
489 | + } | ||
490 | + | ||
491 | + | ||
492 | + | ||
493 | + //���˷��� | ||
494 | + if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN) | ||
495 | + { | ||
496 | + LOG_DEBUG("vehicle_manned_config"); | ||
497 | + | ||
498 | + string str2 = str1 + "hs_sim0610x_310p.om"; | ||
499 | + LOG_DEBUG("8.1 hs init "); | ||
500 | + hs_det_param hs_param_; | ||
501 | + hs_param_.modelNames = (char *)str2.c_str(); | ||
502 | + hs_param_.thresld = 0.3;//��ʱ�ⲿ���ɵ� | ||
503 | + hs_param_.devId = tools->param.gpuid; | ||
504 | + int init_state=hs_det_init(&(tools->hs_handle), hs_param_); | ||
505 | + if (init_state != SUCCESS) | ||
506 | + { | ||
507 | + LOG_ERROR("sy_va_va_init(error): hs_det_init end.(ret = {})", init_state); | ||
508 | + return init_state; | ||
509 | + } | ||
510 | + | ||
511 | + } | ||
512 | + | ||
513 | + return SUCCESS; | ||
514 | +} | ||
515 | + | ||
516 | + | ||
517 | +double msecond() { | ||
518 | + struct timeval tv; | ||
519 | + gettimeofday(&tv, 0); | ||
520 | + return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0); | ||
521 | +} | ||
522 | + | ||
523 | +//----------����ϵ��----// | ||
524 | +//wh20210713����img_data_array��device����,batch_size�̶�Ϊ10 | ||
525 | +int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result *result) | ||
526 | +{ | ||
527 | + if (handle == NULL) | ||
528 | + { | ||
529 | + LOG_ERROR("sy_va_va_batch(error): handle == null."); | ||
530 | + return -1; | ||
531 | + } | ||
532 | + if ((*img_data_array).data_ == NULL || (*img_data_array).w_ == 0 || (*img_data_array).h_ == 0) | ||
533 | + { | ||
534 | + LOG_ERROR("sy_va_va_batch(error): imgdata == null or w == 0 or h == 0."); | ||
535 | + return -1; | ||
536 | + } | ||
537 | + if (batch_size == 0) | ||
538 | + { | ||
539 | + LOG_ERROR("sy_va_va_batch(error): batch size == 0."); | ||
540 | + return -1; | ||
541 | + } | ||
542 | + | ||
543 | + va_handle *tools=(va_handle *)handle; | ||
544 | + | ||
545 | + //�������뿪�� | ||
546 | + if(tools->param.vehicle_detect_config==SY_CONFIG_CLOSE) | ||
547 | + { | ||
548 | + LOG_ERROR("sy_va_va_batch(error): vehicle_detect_config error."); | ||
549 | + return -1; | ||
550 | + } | ||
551 | + | ||
552 | + | ||
553 | + //wh:init��process����һ���̵߳û�����Ҫ�趨Context����Ӧ������ | ||
554 | + //ACL_CALL(aclrtSetDevice(0), ACL_ERROR_NONE, SY_FAILED); | ||
555 | + ACL_CALL(aclrtSetCurrentContext(tools->ctx), ACL_ERROR_NONE, SY_FAILED); | ||
556 | + | ||
557 | + | ||
558 | + | ||
559 | + LOG_DEBUG("prepare data"); | ||
560 | + //wh20220301 | ||
561 | + //step2----����batch_img��ͼ�����1000��ָ�� img_data_array ��ͼ��С��1000����pad��ָ�� | ||
562 | + sy_img batch_img[batch_size]; // | ||
563 | + ImageData img_data_dvpp[batch_size];//������ͼ����dvpp,���ں���Ŀ�ͼ | ||
564 | + for(int b=0;b<batch_size;b++) | ||
565 | + { | ||
566 | + int w= img_data_array[b].w_; | ||
567 | + int h= img_data_array[b].h_; | ||
568 | + | ||
569 | + if(w >1000 || h > 1000)//ͼ�����1000��ָ�� batch_img_bfpad | ||
570 | + { | ||
571 | + batch_img[b].w_ = img_data_array[b].w_; | ||
572 | + batch_img[b].h_ = img_data_array[b].h_; | ||
573 | + batch_img[b].data_ = img_data_array[b].data_; | ||
574 | + | ||
575 | + Utils::CopysyImageDataToDvpp(img_data_dvpp[b], img_data_array[b]); | ||
576 | + } | ||
577 | + else | ||
578 | + { | ||
579 | + | ||
580 | + w = (w + 127)/128 *128; | ||
581 | + h = (h+ 15) / 16 * 16; | ||
582 | + //devתcpu | ||
583 | + sy_img img_data_array_host; | ||
584 | + img_data_array_host.data_ = NULL; | ||
585 | + img_data_array_host.w_ = w; | ||
586 | + img_data_array_host.h_ = h; | ||
587 | + uint32_t size = w * h * 1.5; | ||
588 | + img_data_array_host.data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(img_data_array[b].data_, size); | ||
589 | + | ||
590 | + int w2 = w *1.5;//width pad 1.5�� | ||
591 | + //if(w2%2!=0)w2+=1;//ż�� | ||
592 | + w2 = (w2 + 127)/128 *128; | ||
593 | + int h2 = h; | ||
594 | + uint32_t size2 = w2 * h2 *1.5; | ||
595 | + sy_img img_data_array_pad; | ||
596 | + img_data_array_pad.w_ = w2; | ||
597 | + img_data_array_pad.h_ = h2; | ||
598 | + img_data_array_pad.data_=new unsigned char[size2]; | ||
599 | + memset(img_data_array_pad.data_,0,sizeof(unsigned char)*size2); | ||
600 | + for(int jj=0;jj< h ;jj++) | ||
601 | + { | ||
602 | + memcpy(&img_data_array_pad.data_[jj*w2], &img_data_array_host.data_[jj*w], w * sizeof(unsigned char)); //Y | ||
603 | + } | ||
604 | + int hw = h*w; | ||
605 | + int h2w2 = h2*w2; | ||
606 | + for(int jj=0;jj< h/2 ;jj++) | ||
607 | + { | ||
608 | + memcpy(&img_data_array_pad.data_[h2w2+jj*w2], &img_data_array_host.data_[hw+jj*w], w * sizeof(unsigned char)); //UV | ||
609 | + } | ||
610 | + | ||
611 | + //cpu��gpu | ||
612 | + Utils::CopysyImageDataToDvpp(img_data_dvpp[b], img_data_array_pad); | ||
613 | + | ||
614 | + //set_data | ||
615 | + batch_img[b].w_ = w2; | ||
616 | + batch_img[b].h_ = h2; | ||
617 | + batch_img[b].data_ = img_data_dvpp[b].data.get(); | ||
618 | + | ||
619 | + //delete | ||
620 | + if(img_data_array_host.data_ != NULL) | ||
621 | + { | ||
622 | + delete[] img_data_array_host.data_; | ||
623 | + img_data_array_host.data_ = NULL; | ||
624 | + } | ||
625 | + | ||
626 | + if(img_data_array_pad.data_ != NULL) | ||
627 | + { | ||
628 | + delete[] img_data_array_pad.data_; | ||
629 | + img_data_array_pad.data_ = NULL; | ||
630 | + } | ||
631 | + } | ||
632 | + } | ||
633 | + //end step2----���� batch_img | ||
634 | + | ||
635 | + | ||
636 | + | ||
637 | + | ||
638 | + //��ʼ��dvpp | ||
639 | + aclrtStream stream = nullptr; | ||
640 | + ACL_CALL(aclrtCreateStream(&stream), ACL_ERROR_NONE, SY_FAILED); | ||
641 | + DvppProcess* dvpp = new DvppProcess(); | ||
642 | + dvpp->InitResource(stream); | ||
643 | + | ||
644 | + | ||
645 | + | ||
646 | + //��ʼ�������� | ||
647 | + sy_rect rect_init; | ||
648 | + rect_init.left_= 0; | ||
649 | + rect_init.top_ =0; | ||
650 | + rect_init.width_ = 0; | ||
651 | + rect_init.height_=0; | ||
652 | + for (int b = 0; b < batch_size; b++) | ||
653 | + { | ||
654 | + result[b].count=0; | ||
655 | + for(int c=0;c<VD_MAXDETECTCOUNT;c++) | ||
656 | + { | ||
657 | + | ||
658 | + //1.vd | ||
659 | + result[b].info[c].vehicle_body_detect_res.rect = rect_init; | ||
660 | + result[b].info[c].vehicle_body_detect_res.score = 0; | ||
661 | + | ||
662 | + result[b].info[c].vehicle_detect_res.rect = rect_init; | ||
663 | + result[b].info[c].vehicle_detect_res.score = 0; | ||
664 | + | ||
665 | + result[b].info[c].vehicle_win_detect_res.rect = rect_init; | ||
666 | + result[b].info[c].vehicle_win_detect_res.score = 0; | ||
667 | + | ||
668 | + //3.vc����ɫ | ||
669 | + result[b].info[c].vehicle_color_res.index = -1; | ||
670 | + result[b].info[c].vehicle_color_res.score = 0; | ||
671 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE + 8] = 0;//20201201wh�������ij���ɫ��Ϣ | ||
672 | + | ||
673 | + //4.vr���� | ||
674 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
675 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
676 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
677 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
678 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
679 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
680 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
681 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE +9] = 0;//20201201wh��������vr��Ϣ | ||
682 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE +10] = 0;//20201201wh��������vr��Ϣ | ||
683 | + | ||
684 | + | ||
685 | + //5.���Ƽ��ʶ�� | ||
686 | + result[b].info[c].vehicle_plate_det_recg_res.special_type = 0;//������������20200225 | ||
687 | + result[b].info[c].vehicle_plate_det_recg_res.type = -1; | ||
688 | + result[b].info[c].vehicle_plate_det_recg_res.num_score = 0; | ||
689 | + result[b].info[c].vehicle_plate_det_recg_res.detect_score = 0; | ||
690 | + | ||
691 | + result[b].info[c].vehicle_plate_det_recg_res.rect = rect_init; | ||
692 | + | ||
693 | + for(int p=0;p<PLATENUM;p++) | ||
694 | + { | ||
695 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].index = -1; | ||
696 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].maxprob = 0; | ||
697 | + memset(result[b].info[c].vehicle_plate_det_recg_res.recg[p].character, '\0', sizeof(result[b].info[c].vehicle_plate_det_recg_res.recg[p].character)); | ||
698 | + } | ||
699 | + for(int p=0;p<PLATENUM;p++)//20201201wh��������vp��Ϣ | ||
700 | + { | ||
701 | + result[b].info[c].vehicle_fea_res.feature[FEATURESIZE*2+p] = 0; | ||
702 | + } | ||
703 | + | ||
704 | + //6.������ | ||
705 | + result[b].info[c].vehicle_pendant_det_res.count=0; | ||
706 | + for(int p=0; p<VPD_MAXNUM; p++) | ||
707 | + { | ||
708 | + //result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect = vpd_result_[win_idx].vpd_res[p].rect; | ||
709 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect = rect_init; | ||
710 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence = 0; | ||
711 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index = -1; | ||
712 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info = 0; //wh20210618����������������֮�� | ||
713 | + //memset(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].feature,0,sizeof(float)*VPD_FACE_FEATURESIZE);//wh20210618������������������ | ||
714 | + } | ||
715 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE +11] = 0;//20201201wh��������vpd��Ϣ | ||
716 | + | ||
717 | + //7.vid���� | ||
718 | + result[b].info[c].vehicle_illegal_det_res.driver.person.status = UNCERTAINTY; | ||
719 | + result[b].info[c].vehicle_illegal_det_res.driver.person.confidence = 0; | ||
720 | + result[b].info[c].vehicle_illegal_det_res.driver.belt.status = UNCERTAINTY; | ||
721 | + result[b].info[c].vehicle_illegal_det_res.driver.belt.confidence = 0; | ||
722 | + result[b].info[c].vehicle_illegal_det_res.driver.smoke.status = UNCERTAINTY; | ||
723 | + result[b].info[c].vehicle_illegal_det_res.driver.smoke.confidence = 0; | ||
724 | + result[b].info[c].vehicle_illegal_det_res.driver.phone.status = UNCERTAINTY; | ||
725 | + result[b].info[c].vehicle_illegal_det_res.driver.phone.confidence = 0; | ||
726 | + result[b].info[c].vehicle_illegal_det_res.driver.call.status = UNCERTAINTY; | ||
727 | + result[b].info[c].vehicle_illegal_det_res.driver.call.confidence = 0; | ||
728 | + | ||
729 | + result[b].info[c].vehicle_illegal_det_res.copilot.person.status = UNCERTAINTY; | ||
730 | + result[b].info[c].vehicle_illegal_det_res.copilot.person.confidence = 0; | ||
731 | + result[b].info[c].vehicle_illegal_det_res.copilot.belt.status = UNCERTAINTY; | ||
732 | + result[b].info[c].vehicle_illegal_det_res.copilot.belt.confidence = 0; | ||
733 | + result[b].info[c].vehicle_illegal_det_res.copilot.smoke.status = UNCERTAINTY; | ||
734 | + result[b].info[c].vehicle_illegal_det_res.copilot.smoke.confidence = 0; | ||
735 | + result[b].info[c].vehicle_illegal_det_res.copilot.phone.status = UNCERTAINTY; | ||
736 | + result[b].info[c].vehicle_illegal_det_res.copilot.phone.confidence = 0; | ||
737 | + result[b].info[c].vehicle_illegal_det_res.copilot.call.status = UNCERTAINTY; | ||
738 | + result[b].info[c].vehicle_illegal_det_res.copilot.call.confidence = 0; | ||
739 | + | ||
740 | + //8.vf������ | ||
741 | + memset(result[b].info[c].vehicle_fea_res.feature,0,sizeof(float)*VA_FEATURESIZE); | ||
742 | + | ||
743 | + //mat | ||
744 | + result[b].info[c].mta_res.motor_driver_helmeted.status=-1; | ||
745 | + result[b].info[c].mta_res.motor_driver_helmeted.confidence=0; | ||
746 | + result[b].info[c].mta_res.motor_manned.status=-1; | ||
747 | + result[b].info[c].mta_res.motor_manned.confidence=0; | ||
748 | + result[b].info[c].mta_res.tricycle_manned.status=-1; | ||
749 | + result[b].info[c].mta_res.tricycle_manned.confidence=0; | ||
750 | + | ||
751 | + result[b].info[c].mta_res.motor_driver_hs_rect.rect = rect_init; | ||
752 | + result[b].info[c].mta_res.motor_driver_hs_rect.score=0; | ||
753 | + | ||
754 | + //���˷���manned_analysis | ||
755 | + //result[b].info[c].manned_res.status = 0; | ||
756 | + //result[b].info[c].manned_res.confidence = 0; | ||
757 | + result[b].info[c].manned_res.hs_count = 0; | ||
758 | + memset(result[b].info[c].manned_res.hs_rect,0,sizeof(vd_result)*10); | ||
759 | + | ||
760 | + } | ||
761 | + }//end result��ֵ | ||
762 | + | ||
763 | + | ||
764 | + | ||
765 | + | ||
766 | + | ||
767 | + //��ͷ��β�����ı�ǩ | ||
768 | + int car_body_num=0;//body������� | ||
769 | + int body_num=0;//body������ | ||
770 | + int win_num=0; | ||
771 | + int head_num=0; | ||
772 | + int rear_num=0; | ||
773 | + int motor_num = 0; | ||
774 | + int tricycle_num = 0; | ||
775 | + | ||
776 | + int res_status; | ||
777 | + vpt_result *vpt_result_; | ||
778 | + LOG_DEBUG("vpt_batch"); | ||
779 | + res_status = vpt_batch(tools->vpt_handle, batch_img, batch_size, &vpt_result_);//device���� | ||
780 | + if (res_status != SUCCESS) | ||
781 | + { | ||
782 | + LOG_ERROR("sy_va_va_batch_vd(error): vpt_batch failed. (ret = {})", res_status); | ||
783 | + return res_status; | ||
784 | + } | ||
785 | + LOG_DEBUG("vpt_batch end"); | ||
786 | + | ||
787 | + LOG_DEBUG("process_vptresult"); | ||
788 | + process_vptresult(batch_img, batch_size, vpt_result_); | ||
789 | + | ||
790 | + //output | ||
791 | + int body_idx=0; | ||
792 | + for (int b = 0; b < batch_size; b++) | ||
793 | + { | ||
794 | + int idx =0; | ||
795 | + for(int c=0;c<vpt_result_[b].obj_count_;c++) | ||
796 | + { | ||
797 | + int index = vpt_result_[b].obj_results_[c].obj_index; | ||
798 | + float score = vpt_result_[b].obj_results_[c].obj_score; | ||
799 | + if(score > tools->param.vehicle_det_thresld) | ||
800 | + { | ||
801 | + result[b].info[idx].vpt_type = index; | ||
802 | + if(VERSION_WUXI && c>=VPT_TOPN )//�����汾ֻ����topn | ||
803 | + { | ||
804 | + result[b].info[idx].type=5;//����(������) | ||
805 | + result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; | ||
806 | + result[b].info[idx].vehicle_body_detect_res.score = score; | ||
807 | + | ||
808 | + idx++; | ||
809 | + } | ||
810 | + else | ||
811 | + { | ||
812 | + int manned_label =0;//�Ƿ������˷��� | ||
813 | + | ||
814 | + if((index == 0) )//人车物0是行人 | ||
815 | + { | ||
816 | + result[b].info[idx].type=6;//行人 | ||
817 | + result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; | ||
818 | + result[b].info[idx].vehicle_body_detect_res.score = score; | ||
819 | + idx++; | ||
820 | + } | ||
821 | + | ||
822 | + //Ħ�г������ֳ�����СĿ��ߴ��һ����ˣ����̱߶����� | ||
823 | + if((index== 2 || index== 3 ) && (vpt_result_[b].obj_results_[c].obj_rect.width_ >= tools->param.min_obj_size/2 && vpt_result_[b].obj_results_[c].obj_rect.height_ >= tools->param.min_obj_size/2))//�˳���2-motor 3-tricycle | ||
824 | + { | ||
825 | + result[b].info[idx].type= index;//2-motor 3-tricycle | ||
826 | + result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; | ||
827 | + result[b].info[idx].vehicle_body_detect_res.score = score; | ||
828 | + //idx++; | ||
829 | + manned_label =1; | ||
830 | + | ||
831 | + if(index== 2 )motor_num++; | ||
832 | + if(index== 3 )tricycle_num++; | ||
833 | + | ||
834 | + | ||
835 | + } | ||
836 | + //if((index>= 4 && index<= 8 ) )//�˳���4-8 | ||
837 | + if((index>= 4 && index<= 8 ) && (vpt_result_[b].obj_results_[c].obj_rect.width_ >= tools->param.min_obj_size && vpt_result_[b].obj_results_[c].obj_rect.height_ >= tools->param.min_obj_size))//�˳���4-8 | ||
838 | + { | ||
839 | + result[b].info[idx].type=4;//���� | ||
840 | + result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; | ||
841 | + result[b].info[idx].vehicle_body_detect_res.score = score; | ||
842 | + | ||
843 | + | ||
844 | + manned_label =1; | ||
845 | + //idx++; | ||
846 | + body_idx++; | ||
847 | + | ||
848 | + } | ||
849 | + | ||
850 | + //���˷��� | ||
851 | + if(manned_label ==1) | ||
852 | + { | ||
853 | + if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN) | ||
854 | + { | ||
855 | + LOG_DEBUG("1.manned ----------- "); | ||
856 | + sy_img lorry_img_data[1]; | ||
857 | + lorry_img_data[0].data_ = NULL; | ||
858 | + //�����dz������� | ||
859 | + sy_rect lorry_rect =result[b].info[idx].vehicle_body_detect_res.rect; | ||
860 | + | ||
861 | + uint32_t alignWidth = (lorry_rect.width_ + 127) / 128 * 128; | ||
862 | + uint32_t alignHeight = (lorry_rect.height_ + 15) / 16 * 16; | ||
863 | + ImageData cropImg; | ||
864 | + ACL_CALL(dvpp->PatchCropAndPaste(cropImg, img_data_dvpp[b], lorry_rect.left_, lorry_rect.top_, lorry_rect.left_+lorry_rect.width_, lorry_rect.top_+lorry_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
865 | + | ||
866 | + lorry_img_data[0].w_ = alignWidth;//cropImg.width; | ||
867 | + lorry_img_data[0].h_ = alignHeight;//cropImg.height; | ||
868 | + //lorry_img_data[0].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(cropImg.data.get(), cropImg.size); //cropImg.data.get(); | ||
869 | + lorry_img_data[0].data_ = cropImg.data.get(); | ||
870 | + | ||
871 | + float scale_w = (float)lorry_rect.width_ / alignWidth;//��alignWidth��alignHeightӳ�䵽ԭsize | ||
872 | + float scale_h = (float)lorry_rect.height_ / alignHeight; | ||
873 | + | ||
874 | + //ͷ��SDK-------- | ||
875 | + LOG_DEBUG("hs_det_process_batch ----------- "); | ||
876 | + hs_det_result hst_result[1]; | ||
877 | + int res_status = hs_det_process_batch(tools->hs_handle, lorry_img_data, 1, hst_result); | ||
878 | + if (res_status != SUCCESS) | ||
879 | + { | ||
880 | + LOG_ERROR("sy_va_va_batch_vd(error): lorry_manned process failed. (ret = {})", res_status); | ||
881 | + return res_status; | ||
882 | + } | ||
883 | + LOG_DEBUG("end hs_det_process_batch ----------- "); | ||
884 | + int hs_num=hst_result[0].objcount;//ͷ���� | ||
885 | + if(hs_num>10) | ||
886 | + hs_num=10;//������ʱֻ���10��ͷ�� | ||
887 | + result[b].info[idx].manned_res.hs_count = hs_num; | ||
888 | + for(int i=0;i<hs_num;i++) | ||
889 | + { | ||
890 | + result[b].info[idx].manned_res.hs_rect[i].score =hst_result[0].objinfo[i].confidence ; | ||
891 | + result[b].info[idx].manned_res.hs_rect[i].rect.left_ =hst_result[0].objinfo[i].left* scale_w + lorry_rect.left_; | ||
892 | + result[b].info[idx].manned_res.hs_rect[i].rect.top_ = hst_result[0].objinfo[i].top* scale_h + lorry_rect.top_; | ||
893 | + result[b].info[idx].manned_res.hs_rect[i].rect.width_ = (hst_result[0].objinfo[i].right - hst_result[0].objinfo[i].left)* scale_w ; | ||
894 | + result[b].info[idx].manned_res.hs_rect[i].rect.height_ = (hst_result[0].objinfo[i].bottom - hst_result[0].objinfo[i].top)* scale_h ; | ||
895 | + } | ||
896 | + | ||
897 | + } | ||
898 | + | ||
899 | + idx++; | ||
900 | + } | ||
901 | + } | ||
902 | + } | ||
903 | + } | ||
904 | + | ||
905 | + result[b].count = idx; | ||
906 | + body_num+=idx; | ||
907 | + } | ||
908 | + car_body_num = body_idx; | ||
909 | + LOG_DEBUG("body_idx={}",body_idx); | ||
910 | + LOG_DEBUG("car_body_num={}",car_body_num); | ||
911 | + | ||
912 | + | ||
913 | + //�����Է��� | ||
914 | + if(car_body_num>0) | ||
915 | + { | ||
916 | + if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) | ||
917 | + { | ||
918 | + //��ȡ��������ͼ�� vpd_img_data ����������˳����ԣ�----- | ||
919 | + LOG_DEBUG("1-2 vpd crop body_img----- "); | ||
920 | + int body_iter=car_body_num/MAX_BATCHSIZE; | ||
921 | + int body_remainder=car_body_num%MAX_BATCHSIZE; | ||
922 | + if(body_remainder!=0) | ||
923 | + body_iter+=1; | ||
924 | + | ||
925 | + sy_img **vpd_img_data = NULL; | ||
926 | + vpd_img_data = new sy_img*[body_iter]; | ||
927 | + for(int iter=0;iter<body_iter;iter++)//��ʼ�� | ||
928 | + { | ||
929 | + vpd_img_data[iter]=new sy_img[MAX_BATCHSIZE]; | ||
930 | + for(int b = 0; b < MAX_BATCHSIZE; b++) | ||
931 | + { | ||
932 | + vpd_img_data[iter][b].data_ = NULL; | ||
933 | + } | ||
934 | + } | ||
935 | + | ||
936 | + ImageData vpd_cropImg[car_body_num]; | ||
937 | + sy_rect vpd_rect[car_body_num]; | ||
938 | + float scale_w[car_body_num]; | ||
939 | + float scale_h[car_body_num]; | ||
940 | + | ||
941 | + int idx=0; | ||
942 | + for (int b = 0; b < batch_size; b++) | ||
943 | + { | ||
944 | + int img_w=batch_img[b].w_; | ||
945 | + int img_h=batch_img[b].h_; | ||
946 | + for(int c=0;c<result[b].count;c++) | ||
947 | + { | ||
948 | + if(result[b].info[c].type == 4)///���� | ||
949 | + { | ||
950 | + sy_rect body_rect=result[b].info[c].vehicle_body_detect_res.rect;//���� | ||
951 | + //�����dz�����������1.5�� | ||
952 | + vpd_rect[idx] = rect_extend(body_rect, img_w, img_h,0.25); | ||
953 | + | ||
954 | + uint32_t alignWidth = (vpd_rect[idx].width_ + 127) / 128 * 128; | ||
955 | + uint32_t alignHeight = (vpd_rect[idx].height_ + 15) / 16 * 16; | ||
956 | + ACL_CALL(dvpp->PatchCropAndPaste(vpd_cropImg[idx], img_data_dvpp[b], vpd_rect[idx].left_, vpd_rect[idx].top_, vpd_rect[idx].left_+vpd_rect[idx].width_, vpd_rect[idx].top_+vpd_rect[idx].height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
957 | + | ||
958 | + int iter=idx/MAX_BATCHSIZE; | ||
959 | + int index=idx%MAX_BATCHSIZE; | ||
960 | + | ||
961 | + vpd_img_data[iter][index].w_ = alignWidth;//cropImg.width; | ||
962 | + vpd_img_data[iter][index].h_ = alignHeight;//cropImg.height; | ||
963 | + vpd_img_data[iter][index].data_ = vpd_cropImg[idx].data.get();//(uint8_t*)Utils::CopyDataDeviceToLocal(body_cropImg[idx].data.get(), body_cropImg[idx].size); //cropImg.data.get(); | ||
964 | + | ||
965 | + scale_w[idx] = (float)vpd_rect[idx].width_ / alignWidth;//��alignWidth��alignHeightӳ�䵽ԭsize | ||
966 | + scale_h[idx] = (float)vpd_rect[idx].height_ / alignHeight; | ||
967 | + | ||
968 | + idx++; | ||
969 | + | ||
970 | + } | ||
971 | + } | ||
972 | + } | ||
973 | + LOG_DEBUG("end 1-2 vpd crop vpd_img_data----- "); | ||
974 | + | ||
975 | + | ||
976 | + //23�����Լ��(Ĭ��һ������ֻ�ܼ�һ����ͷ���߳�β��һ������) | ||
977 | + LOG_DEBUG("1-2 vpd_process----- "); | ||
978 | + vpd_result vpd_result_temp[car_body_num]; | ||
979 | + vpd_result vpd_result_[car_body_num]; | ||
980 | + for(int b=0;b<car_body_num;b++) | ||
981 | + { | ||
982 | + vpd_result_temp[b].count = 0; | ||
983 | + vpd_result_temp[b].vpd_res=new vpd_info[OBJ_MAX_COUNT]; | ||
984 | + | ||
985 | + vpd_result_[b].count = 0; | ||
986 | + vpd_result_[b].vpd_res=new vpd_info[OBJ_MAX_COUNT]; | ||
987 | + } | ||
988 | + | ||
989 | + int p_idx=0; | ||
990 | + for(int iter=0;iter<body_iter;iter++) | ||
991 | + { | ||
992 | + int temp_batch; | ||
993 | + if(iter==body_iter-1 && body_remainder!=0) | ||
994 | + { | ||
995 | + temp_batch=body_remainder; | ||
996 | + res_status=vpd_process(tools->vpd_handle, vpd_img_data[iter], temp_batch, &vpd_result_temp[p_idx]); | ||
997 | + } | ||
998 | + else | ||
999 | + { | ||
1000 | + temp_batch=MAX_BATCHSIZE; | ||
1001 | + //res_status=vpd_process10(tools->vpd_handle, vpd_img_data[iter], temp_batch, &vpd_result_temp[p_idx]); | ||
1002 | + res_status=vpd_process(tools->vpd_handle, vpd_img_data[iter], temp_batch, &vpd_result_temp[p_idx]); | ||
1003 | + } | ||
1004 | + | ||
1005 | + p_idx += temp_batch; | ||
1006 | + } | ||
1007 | + | ||
1008 | + | ||
1009 | + //����������ӳ�䵽��ͼ�� | ||
1010 | + for(int b=0;b<car_body_num;b++) | ||
1011 | + { | ||
1012 | + for(int i=0; i<vpd_result_temp[b].count; i++) | ||
1013 | + { | ||
1014 | + vpd_result_temp[b].vpd_res[i].rect.left_ = vpd_result_temp[b].vpd_res[i].rect.left_ * scale_w[b] + vpd_rect[b].left_; | ||
1015 | + vpd_result_temp[b].vpd_res[i].rect.top_ = vpd_result_temp[b].vpd_res[i].rect.top_ * scale_h[b] + vpd_rect[b].top_; | ||
1016 | + vpd_result_temp[b].vpd_res[i].rect.width_ = vpd_result_temp[b].vpd_res[i].rect.width_ * scale_w[b]; | ||
1017 | + vpd_result_temp[b].vpd_res[i].rect.height_ = vpd_result_temp[b].vpd_res[i].rect.height_ * scale_h[b]; | ||
1018 | + } | ||
1019 | + } | ||
1020 | + | ||
1021 | + //output | ||
1022 | + int body_idx=0; | ||
1023 | + for(int b=0;b<batch_size;b++) | ||
1024 | + { | ||
1025 | + for(int c=0;c<result[b].count;c++) | ||
1026 | + { | ||
1027 | + if(result[b].info[c].type == 4)//�dz��� | ||
1028 | + { | ||
1029 | + | ||
1030 | + process_vpdresult(result[b].info[c].vehicle_body_detect_res.rect, &vpd_result_temp[body_idx], &vpd_result_[body_idx]);//�����Խ�����˺��� | ||
1031 | + | ||
1032 | + //output | ||
1033 | + int head_rear=0;//��ͷ�ͳ�βֻ���1�� | ||
1034 | + int win=0;//����ֻ���1�� | ||
1035 | + int vpd12_idx=0;//12����Ե���� | ||
1036 | + int vpd_count = vpd_result_[body_idx].count; | ||
1037 | + for(int i=0; i<vpd_count; i++) | ||
1038 | + { | ||
1039 | + int index = vpd_result_[body_idx].vpd_res[i].index; | ||
1040 | + //if(index ==0)index =1;//temp test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
1041 | + float score = vpd_result_[body_idx].vpd_res[i].confidence; | ||
1042 | + | ||
1043 | + if(score > tools->param.vehicle_attribute_det_thresld) | ||
1044 | + { | ||
1045 | + if(index == 0 && head_rear==0)//��ͷ | ||
1046 | + { | ||
1047 | + result[b].info[c].vehicle_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; | ||
1048 | + result[b].info[c].vehicle_detect_res.score = score; | ||
1049 | + result[b].info[c].type = 0; | ||
1050 | + | ||
1051 | + head_num++; | ||
1052 | + head_rear=1; | ||
1053 | + } | ||
1054 | + else if(index == 1 && head_rear==0)//��β | ||
1055 | + { | ||
1056 | + result[b].info[c].vehicle_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; | ||
1057 | + result[b].info[c].vehicle_detect_res.score = score; | ||
1058 | + result[b].info[c].type = 1; | ||
1059 | + | ||
1060 | + rear_num++; | ||
1061 | + head_rear=1; | ||
1062 | + } | ||
1063 | + else if(index == 2 && win==0)//���� | ||
1064 | + { | ||
1065 | + result[b].info[c].vehicle_win_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; | ||
1066 | + result[b].info[c].vehicle_win_detect_res.score = score; | ||
1067 | + | ||
1068 | + win_num++; | ||
1069 | + win=1; | ||
1070 | + } | ||
1071 | + //else if(index >=8 && index <=19)//������index=8~19��12�� | ||
1072 | + else if(index >=3 && index <=14)//������index=3~14��12�� | ||
1073 | + { | ||
1074 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].rect = vpd_result_[body_idx].vpd_res[i].rect; | ||
1075 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].confidence = vpd_result_[body_idx].vpd_res[i].confidence; | ||
1076 | + //result[b].info[idx].vehicle_pendant_det_res.vpd_res[vpd12_idx].index = index-8; | ||
1077 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].index = index-3; | ||
1078 | + | ||
1079 | + //���ݸ�����Ϣ | ||
1080 | + //if(index == 8 || index == 9 || index == 10 || index == 11|| index == 16|| index == 19)//8-˾�� ��9-������10-��ȫ����11-�����塢16-��绰��19-���� ��Ҫ�ж����ݸ��� | ||
1081 | + if(index == 3 || index == 4 || index == 5 || index == 6|| index == 11|| index == 14)//3-˾�� ��4-������5-��ȫ����6-�����塢11-��绰��14-���� ��Ҫ�ж����ݸ��� | ||
1082 | + { | ||
1083 | + int driver_copilot_info = rect_driver_copilot(result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].rect, result[b].info[c].vehicle_body_detect_res.rect); | ||
1084 | + result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].driver_copilot_info = driver_copilot_info; | ||
1085 | + } | ||
1086 | + | ||
1087 | + | ||
1088 | + vpd12_idx++;//12����Եĸ��� | ||
1089 | + } | ||
1090 | + } | ||
1091 | + }//end ������output | ||
1092 | + result[b].info[c].vehicle_pendant_det_res.count = vpd12_idx; //12����Եĸ��� | ||
1093 | + | ||
1094 | + body_idx++; | ||
1095 | + } | ||
1096 | + | ||
1097 | + | ||
1098 | + } | ||
1099 | + } | ||
1100 | + | ||
1101 | + | ||
1102 | + //delete | ||
1103 | + if (vpd_img_data != NULL) | ||
1104 | + { | ||
1105 | + for(int iter=0;iter<body_iter;iter++) | ||
1106 | + { | ||
1107 | + if (vpd_img_data[iter]!= NULL) | ||
1108 | + { | ||
1109 | + delete[] vpd_img_data[iter]; | ||
1110 | + vpd_img_data[iter] = NULL; | ||
1111 | + } | ||
1112 | + | ||
1113 | + } | ||
1114 | + delete[] vpd_img_data; | ||
1115 | + vpd_img_data = NULL; | ||
1116 | + } | ||
1117 | + | ||
1118 | + //delete | ||
1119 | + for(int b=0;b<car_body_num;b++) | ||
1120 | + { | ||
1121 | + if(vpd_result_temp[b].vpd_res !=NULL) | ||
1122 | + { | ||
1123 | + delete[] vpd_result_temp[b].vpd_res; | ||
1124 | + vpd_result_temp[b].vpd_res = NULL; | ||
1125 | + } | ||
1126 | + | ||
1127 | + if(vpd_result_[b].vpd_res !=NULL) | ||
1128 | + { | ||
1129 | + delete[] vpd_result_[b].vpd_res; | ||
1130 | + vpd_result_[b].vpd_res = NULL; | ||
1131 | + } | ||
1132 | + } | ||
1133 | + LOG_DEBUG("1-2 vpd_process----- "); | ||
1134 | + | ||
1135 | + } | ||
1136 | + } | ||
1137 | + LOG_DEBUG("body_num={} car_body_num={} motor_num={} tricycle_num={} ",body_num,car_body_num,motor_num,tricycle_num); | ||
1138 | + LOG_DEBUG("head_num={} rear_num={} win_num={} ",head_num,rear_num,win_num); | ||
1139 | + LOG_DEBUG("end 1.vpt_batch + vpd----------- "); | ||
1140 | + | ||
1141 | + //wh20210930���鳵���ͳ�ͷβ����������ȳ�ͷβҪС���ó�ͷβ���泵�������ꡣ��ΪһЩ��Сͼ���˳�����ʱ������������С��������ȫ�� | ||
1142 | + if(1) | ||
1143 | + { | ||
1144 | + for (int b = 0; b < batch_size; b++) | ||
1145 | + { | ||
1146 | + for(int c=0;c<result[b].count;c++) | ||
1147 | + { | ||
1148 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 )//�dz�ͷ��β | ||
1149 | + { | ||
1150 | + int head_rear_area = result[b].info[c].vehicle_detect_res.rect.width_ * result[b].info[c].vehicle_detect_res.rect.height_; | ||
1151 | + int body_area = result[b].info[c].vehicle_body_detect_res.rect.width_ * result[b].info[c].vehicle_body_detect_res.rect.height_; | ||
1152 | + | ||
1153 | + if(body_area < head_rear_area) | ||
1154 | + result[b].info[c].vehicle_body_detect_res.rect = result[b].info[c].vehicle_detect_res.rect; | ||
1155 | + } | ||
1156 | + } | ||
1157 | + } | ||
1158 | + } | ||
1159 | + | ||
1160 | + | ||
1161 | + //��ͷ���� | ||
1162 | + if(head_num>0) | ||
1163 | + { | ||
1164 | + //2.1 ��ȡ��ͷ����ͼ��batch�� head_img_data ���������ʶ�𡢳��Ƽ��ʶ�� | ||
1165 | + LOG_DEBUG("head2.1 crop head_img----- "); | ||
1166 | + | ||
1167 | + sy_img head_img_data[head_num]; | ||
1168 | + for(int b=0;b<head_num;b++) | ||
1169 | + { | ||
1170 | + head_img_data[b].data_ = NULL; | ||
1171 | + } | ||
1172 | + sy_img head_img_data_host[head_num]; | ||
1173 | + for(int b=0;b<head_num;b++) | ||
1174 | + { | ||
1175 | + head_img_data_host[b].data_ = NULL; | ||
1176 | + } | ||
1177 | + ImageData car_cropImg[head_num];//��car_img_data��Ӧ | ||
1178 | + float scale_w[head_num]; | ||
1179 | + float scale_h[head_num]; | ||
1180 | + | ||
1181 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN | ||
1182 | + ||tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN | ||
1183 | + ||tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
1184 | + { | ||
1185 | + int head_idx=0; | ||
1186 | + for (int b = 0; b < batch_size; b++) | ||
1187 | + { | ||
1188 | + for(int c=0;c<result[b].count;c++) | ||
1189 | + { | ||
1190 | + if(result[b].info[c].type == 0)//�dz�ͷ | ||
1191 | + { | ||
1192 | + sy_rect head_rect=result[b].info[c].vehicle_detect_res.rect; | ||
1193 | + | ||
1194 | + uint32_t alignWidth = (head_rect.width_ + 127) / 128 * 128; | ||
1195 | + uint32_t alignHeight = (head_rect.height_ + 15) / 16 * 16; | ||
1196 | + | ||
1197 | + ACL_CALL(dvpp->PatchCropAndPaste(car_cropImg[head_idx], img_data_dvpp[b], head_rect.left_, head_rect.top_, head_rect.left_+head_rect.width_, head_rect.top_+head_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
1198 | + head_img_data[head_idx].w_ = alignWidth;//cropImg.width; | ||
1199 | + head_img_data[head_idx].h_ = alignHeight;//cropImg.height; | ||
1200 | + head_img_data_host[head_idx].w_ = alignWidth;//cropImg.width; | ||
1201 | + head_img_data_host[head_idx].h_ = alignHeight;//cropImg.height; | ||
1202 | + | ||
1203 | + head_img_data_host[head_idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(car_cropImg[head_idx].data.get(), car_cropImg[head_idx].size); //car_cropImg[head_idx].data.get(); | ||
1204 | + head_img_data[head_idx].data_ = car_cropImg[head_idx].data.get(); //car_cropImg[head_idx].data.get(); | ||
1205 | + | ||
1206 | + scale_w[head_idx] = (float)head_rect.width_/alignWidth; | ||
1207 | + scale_h[head_idx] = (float)head_rect.height_/alignHeight; | ||
1208 | + | ||
1209 | + head_idx++; | ||
1210 | + } | ||
1211 | + } | ||
1212 | + } | ||
1213 | + | ||
1214 | + if(head_idx != head_num) | ||
1215 | + LOG_ERROR("error:head_idx != head_num"); | ||
1216 | + } | ||
1217 | + LOG_DEBUG("end head2.1 crop head_img----- "); | ||
1218 | + //end for ��ȡ��ͷ--------- | ||
1219 | + | ||
1220 | + | ||
1221 | + | ||
1222 | + //2.2.VR����ʶ��---------------------------------------- | ||
1223 | + //��MAX_BATCHSIZE���� | ||
1224 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) | ||
1225 | + { | ||
1226 | + LOG_DEBUG("head2.2.vr process----- "); | ||
1227 | + | ||
1228 | + int vr_batch_size=head_num;// | ||
1229 | + | ||
1230 | + vr_result * vr_result_ = new vr_result[vr_batch_size]; | ||
1231 | + int res_status = vr_batch(tools->vr_handle, head_img_data, vr_batch_size, vr_result_); | ||
1232 | + if (SUCCESS != res_status) { | ||
1233 | + LOG_ERROR("sy_va_va_batch_vd(error): vr_batch failed. (ret = {})", res_status); | ||
1234 | + return res_status; | ||
1235 | + } | ||
1236 | + | ||
1237 | + //output | ||
1238 | + int head_idx=0; | ||
1239 | + for(int b=0;b<batch_size;b++) | ||
1240 | + { | ||
1241 | + for(int c=0;c<result[b].count;c++) | ||
1242 | + { | ||
1243 | + if(result[b].info[c].type == 0)//�dz�ͷ | ||
1244 | + { | ||
1245 | + float score = vr_result_[head_idx].name_score; | ||
1246 | + if(score>0) | ||
1247 | + { | ||
1248 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_result_[head_idx].vehicle_brand, sizeof(char)*260); | ||
1249 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_result_[head_idx].vehicle_subbrand, sizeof(char)*260); | ||
1250 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_result_[head_idx].vehicle_issue_year, sizeof(char)*260); | ||
1251 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_result_[head_idx].vehicle_type, sizeof(char)*260); | ||
1252 | + memcpy(result[b].info[c].vehicle_recg_res.freight_ton, vr_result_[head_idx].freight_ton, sizeof(char)*260); | ||
1253 | + result[b].info[c].vehicle_recg_res.name_score = vr_result_[head_idx].name_score; | ||
1254 | + result[b].info[c].vehicle_recg_res.index = vr_result_[head_idx].index; | ||
1255 | + | ||
1256 | + } | ||
1257 | + head_idx++; | ||
1258 | + } | ||
1259 | + } | ||
1260 | + } | ||
1261 | + | ||
1262 | + //release vr_result_ | ||
1263 | + if (vr_result_ != NULL) | ||
1264 | + { | ||
1265 | + delete[] vr_result_; | ||
1266 | + } | ||
1267 | + LOG_DEBUG("head2.2.vr_batch end."); | ||
1268 | + } | ||
1269 | + | ||
1270 | + | ||
1271 | + | ||
1272 | + //2.3.VP���Ƽ��ʶ������1and2stn_vp-------------------------------------------- | ||
1273 | + //2.3.1.VF��ͷ�������������dz�ͷ����Ҫ�ѳ���������0 | ||
1274 | + //��MAX_BATCHSIZE���� | ||
1275 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
1276 | + { | ||
1277 | + LOG_DEBUG("head2.3.vp process & vf_head process----- "); | ||
1278 | + | ||
1279 | + int vp_batch_size = head_num;// | ||
1280 | + | ||
1281 | + if(vp_batch_size>0) | ||
1282 | + { | ||
1283 | + //��ʼ����ͷ���� | ||
1284 | + float ** fea=new float*[vp_batch_size]; | ||
1285 | + for (int b = 0; b < vp_batch_size; b++) | ||
1286 | + { | ||
1287 | + fea[b]=new float[FEATURESIZE]; | ||
1288 | + memset(fea[b],0,sizeof(float)*FEATURESIZE); | ||
1289 | + } | ||
1290 | + | ||
1291 | + | ||
1292 | + //��ʼ�����ƽ���ṹ�� | ||
1293 | + vplates_result *vp_result = new vplates_result[vp_batch_size]; | ||
1294 | + //5.���Ƽ��ʶ�� | ||
1295 | + res_status=vpdr_batch(tools->vp_handle, head_img_data, vp_batch_size, vp_result); | ||
1296 | + if (res_status != SUCCESS) | ||
1297 | + { | ||
1298 | + LOG_ERROR("sy_va_va_batch_vd(error): vpdr process failed. (ret = {})", res_status); | ||
1299 | + return res_status; | ||
1300 | + } | ||
1301 | + | ||
1302 | + | ||
1303 | + //8-1��ͷ������������λ����0 | ||
1304 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
1305 | + { | ||
1306 | + LOG_DEBUG("head2.3.1 vf head process---------- "); | ||
1307 | + | ||
1308 | + //�������0 | ||
1309 | + for(int idx=0;idx<vp_batch_size;idx++) | ||
1310 | + { | ||
1311 | + //��ȡ���Ƶ�λ�� | ||
1312 | + //ͳ�Ʒ�����ߵij��� | ||
1313 | + int max_index = -1; | ||
1314 | + float max_score = 0; | ||
1315 | + for (int m = 0; m < vp_result[idx].count; m++) | ||
1316 | + { | ||
1317 | + if (vp_result[idx].vehicle_plate_infos[m].detect_score > max_score && vp_result[idx].vehicle_plate_infos[m].num_score!=0) | ||
1318 | + { | ||
1319 | + max_score = vp_result[idx].vehicle_plate_infos[m].detect_score; | ||
1320 | + max_index = m; | ||
1321 | + } | ||
1322 | + } | ||
1323 | + if (vp_result[idx].count>0 && max_index != -1 )//������ | ||
1324 | + { | ||
1325 | + int left = vp_result[idx].vehicle_plate_infos[max_index].rect.left_; | ||
1326 | + int top = vp_result[idx].vehicle_plate_infos[max_index].rect.top_; | ||
1327 | + int width = vp_result[idx].vehicle_plate_infos[max_index].rect.width_; | ||
1328 | + int height = vp_result[idx].vehicle_plate_infos[max_index].rect.height_; | ||
1329 | + | ||
1330 | + int w=head_img_data_host[idx].w_; | ||
1331 | + int h=head_img_data_host[idx].h_; | ||
1332 | + for(int jj=top;jj<top +height ;jj++) | ||
1333 | + { | ||
1334 | + for(int ii=left;ii<left+width ;ii++) | ||
1335 | + { | ||
1336 | + head_img_data_host[idx].data_[jj*w +ii]=0; | ||
1337 | + if (jj % 2 == 0 && ii % 2 == 0) | ||
1338 | + { | ||
1339 | + head_img_data_host[idx].data_[h*w +jj/2*w+ii]=128; | ||
1340 | + head_img_data_host[idx].data_[h*w +jj/2*w+ii+1]=128; | ||
1341 | + } | ||
1342 | + } | ||
1343 | + } | ||
1344 | + } | ||
1345 | + } | ||
1346 | + | ||
1347 | + //Process | ||
1348 | + res_status=vf_head_feature_batch(tools->vf_head_handle, head_img_data, vp_batch_size, fea); | ||
1349 | + if (res_status != SUCCESS) | ||
1350 | + { | ||
1351 | + LOG_ERROR("sy_va_va_batch_vd(error): vf head process failed. (ret = {})", res_status); | ||
1352 | + return res_status; | ||
1353 | + } | ||
1354 | + } | ||
1355 | + | ||
1356 | + | ||
1357 | + //output | ||
1358 | + int head_idx=0;//�������� | ||
1359 | + for(int b=0;b<batch_size;b++) | ||
1360 | + { | ||
1361 | + for(int c=0;c<result[b].count;c++) | ||
1362 | + { | ||
1363 | + auto& info_c = result[b].info[c]; | ||
1364 | + if(info_c.type == 0)//�dz�ͷ | ||
1365 | + { | ||
1366 | + //ͳ�Ʒ�����ߵij��� | ||
1367 | + int max_index = -1; | ||
1368 | + float max_score = 0; | ||
1369 | + for (int m = 0; m < vp_result[head_idx].count; m++) | ||
1370 | + { | ||
1371 | + if (vp_result[head_idx].vehicle_plate_infos[m].detect_score > max_score && vp_result[head_idx].vehicle_plate_infos[m].num_score!=0) | ||
1372 | + { | ||
1373 | + max_score = vp_result[head_idx].vehicle_plate_infos[m].detect_score; | ||
1374 | + max_index = m; | ||
1375 | + } | ||
1376 | + } | ||
1377 | + | ||
1378 | + if (vp_result[head_idx].count==0 || max_index == -1 )//û������ | ||
1379 | + { | ||
1380 | + info_c.vehicle_plate_det_recg_res.special_type = 0;//���������20200225//���泵�ơ����ٳ��ơ���ʱ���ơ�0-common,1-low_speed_license_plate,2-temporary_license_plate. | ||
1381 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = 0; | ||
1382 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = -1; | ||
1383 | + | ||
1384 | + info_c.vehicle_plate_det_recg_res.type = 0; | ||
1385 | + info_c.vehicle_plate_det_recg_res.num_score = 0; | ||
1386 | + info_c.vehicle_plate_det_recg_res.detect_score = 0; | ||
1387 | + | ||
1388 | + info_c.vehicle_plate_det_recg_res.rect.left_ = 0; | ||
1389 | + info_c.vehicle_plate_det_recg_res.rect.top_ = 0; | ||
1390 | + info_c.vehicle_plate_det_recg_res.rect.width_ = 0; | ||
1391 | + info_c.vehicle_plate_det_recg_res.rect.height_ = 0; | ||
1392 | + | ||
1393 | + for(int p=0;p<PLATENUM;p++) | ||
1394 | + { | ||
1395 | + info_c.vehicle_plate_det_recg_res.recg[p].index = 0; | ||
1396 | + info_c.vehicle_plate_det_recg_res.recg[p].maxprob = 0; | ||
1397 | + //info_c.vehicle_plate_det_recg_res.recg[p].character = NULL; | ||
1398 | + memset(info_c.vehicle_plate_det_recg_res.recg[p].character, '\0', sizeof(info_c.vehicle_plate_det_recg_res.recg[p].character)); | ||
1399 | + } | ||
1400 | + | ||
1401 | + //20201201wh���������ӳ������� | ||
1402 | + for(int p=0;p<PLATENUM;p++) | ||
1403 | + { | ||
1404 | + info_c.vehicle_fea_res.feature[FEATURESIZE*2+p] = 0; | ||
1405 | + } | ||
1406 | + | ||
1407 | + } | ||
1408 | + else{//������ | ||
1409 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = vp_result[head_idx].vehicle_plate_infos[max_index].state_score; | ||
1410 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = vp_result[head_idx].vehicle_plate_infos[max_index].state; | ||
1411 | + | ||
1412 | + info_c.vehicle_plate_det_recg_res.type = vp_result[head_idx].vehicle_plate_infos[max_index].type; | ||
1413 | + info_c.vehicle_plate_det_recg_res.num_score = vp_result[head_idx].vehicle_plate_infos[max_index].num_score; | ||
1414 | + info_c.vehicle_plate_det_recg_res.detect_score = vp_result[head_idx].vehicle_plate_infos[max_index].detect_score; | ||
1415 | + if (info_c.vehicle_plate_det_recg_res.detect_score > 0.1 && info_c.vehicle_plate_det_recg_res.stain_vp_result.type == 1) | ||
1416 | + { | ||
1417 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = 2; | ||
1418 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = info_c.vehicle_plate_det_recg_res.detect_score; | ||
1419 | + } | ||
1420 | + | ||
1421 | + | ||
1422 | + info_c.vehicle_plate_det_recg_res.rect.left_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.left_ * scale_w[head_idx]+ info_c.vehicle_detect_res.rect.left_; | ||
1423 | + info_c.vehicle_plate_det_recg_res.rect.top_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.top_ * scale_h[head_idx]+ info_c.vehicle_detect_res.rect.top_; | ||
1424 | + info_c.vehicle_plate_det_recg_res.rect.width_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.width_ * scale_w[head_idx]; | ||
1425 | + info_c.vehicle_plate_det_recg_res.rect.height_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.height_* scale_h[head_idx]; | ||
1426 | + | ||
1427 | + for(int p=0;p<PLATENUM;p++) | ||
1428 | + { | ||
1429 | + info_c.vehicle_plate_det_recg_res.recg[p].index = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].index; | ||
1430 | + info_c.vehicle_plate_det_recg_res.recg[p].maxprob = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].maxprob; | ||
1431 | + //info_c.vehicle_plate_det_recg_res.recg[p].character = vp_result[idx][j].recg[p].character; | ||
1432 | + info_c.vehicle_plate_det_recg_res.recg[p].character[0] = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].character[0]; | ||
1433 | + info_c.vehicle_plate_det_recg_res.recg[p].character[1] = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].character[1]; | ||
1434 | + info_c.vehicle_plate_det_recg_res.recg[p].character[2] = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].character[2]; | ||
1435 | + info_c.vehicle_plate_det_recg_res.recg[p].character[3] = vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].character[3]; | ||
1436 | + } | ||
1437 | + | ||
1438 | + //20201201wh���������ӳ�����Ϣ | ||
1439 | + for(int p=0;p<PLATENUM;p++) | ||
1440 | + { | ||
1441 | + info_c.vehicle_fea_res.feature[FEATURESIZE*2+p] = (float)vp_result[head_idx].vehicle_plate_infos[max_index].recg[p].index; | ||
1442 | + } | ||
1443 | + | ||
1444 | + //����������20200225 | ||
1445 | + //1.�ڳ�����ij���Ϊ��ʱ���� | ||
1446 | + sy_rect win_rect = info_c.vehicle_win_detect_res.rect; | ||
1447 | + sy_rect vp_rect = info_c.vehicle_plate_det_recg_res.rect; | ||
1448 | + if(vp_rect.left_ < win_rect.left_+win_rect.width_ && vp_rect.left_ + vp_rect.width_ > win_rect.left_ && vp_rect.top_ < win_rect.top_+win_rect.height_ && vp_rect.top_ + vp_rect.height_ > win_rect.top_ ) | ||
1449 | + { | ||
1450 | + info_c.vehicle_plate_det_recg_res.special_type = 1;//��ʱ����//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. | ||
1451 | + } | ||
1452 | + //2.��ɫ˫�㳵�ƣ������ڳ�ͷ����һ��Ϊ���ٳ������� | ||
1453 | + else if(info_c.vehicle_plate_det_recg_res.type == 4) | ||
1454 | + { | ||
1455 | + info_c.vehicle_plate_det_recg_res.special_type = 2;//���ٳ���//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. | ||
1456 | + } | ||
1457 | + else | ||
1458 | + { | ||
1459 | + info_c.vehicle_plate_det_recg_res.special_type = 0;//���泵�� | ||
1460 | + } | ||
1461 | + } | ||
1462 | + | ||
1463 | + //��ͷ������� | ||
1464 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
1465 | + { | ||
1466 | + memcpy(info_c.vehicle_fea_res.feature,fea[head_idx],sizeof(float)*FEATURESIZE); | ||
1467 | + } | ||
1468 | + | ||
1469 | + head_idx++; | ||
1470 | + } | ||
1471 | + } | ||
1472 | + }//end output | ||
1473 | + | ||
1474 | + | ||
1475 | + //release vp_result | ||
1476 | + if (vp_result != NULL) | ||
1477 | + { | ||
1478 | + delete[] vp_result; | ||
1479 | + vp_result = NULL; | ||
1480 | + } | ||
1481 | + //release fea | ||
1482 | + if(fea!= NULL) | ||
1483 | + { | ||
1484 | + for (int b = 0; b < vp_batch_size; b++) | ||
1485 | + { | ||
1486 | + if(fea[b]!= NULL){ | ||
1487 | + delete[] fea[b]; | ||
1488 | + fea[b]= NULL; | ||
1489 | + } | ||
1490 | + } | ||
1491 | + delete[] fea; | ||
1492 | + fea = NULL; | ||
1493 | + } | ||
1494 | + | ||
1495 | + LOG_DEBUG("end head2.3 vp process & vf_head process----- "); | ||
1496 | + } | ||
1497 | + }//end head 2.3 VP���Ƽ��ʶ��----------------------- | ||
1498 | + | ||
1499 | + //delete------ | ||
1500 | + for(int b=0;b<head_num;b++) | ||
1501 | + { | ||
1502 | + if(head_img_data_host[b].data_ != NULL) | ||
1503 | + { | ||
1504 | + delete[] head_img_data_host[b].data_; | ||
1505 | + head_img_data_host[b].data_ = NULL; | ||
1506 | + } | ||
1507 | + } | ||
1508 | + }//end head��ͷ���� | ||
1509 | + | ||
1510 | + | ||
1511 | + | ||
1512 | + | ||
1513 | + if(rear_num>0)//����β | ||
1514 | + { | ||
1515 | + //��ȡ��β����ͼ��batch�� rear_img_data ���������ʶ�𡢳��Ƽ��ʶ�𡢳����� | ||
1516 | + LOG_DEBUG("rear 3.1 crop rear_img----- "); | ||
1517 | + | ||
1518 | + sy_img rear_img_data[rear_num]; | ||
1519 | + for(int b=0;b<rear_num;b++) | ||
1520 | + { | ||
1521 | + rear_img_data[b].data_ = NULL; | ||
1522 | + } | ||
1523 | + ImageData rear_cropImg[rear_num]; | ||
1524 | + float scale_w[rear_num]; | ||
1525 | + float scale_h[rear_num]; | ||
1526 | + | ||
1527 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN | ||
1528 | + ||tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN | ||
1529 | + ||tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
1530 | + { | ||
1531 | + int rear_idx=0; | ||
1532 | + for (int b = 0; b < batch_size; b++) | ||
1533 | + { | ||
1534 | + for(int c=0;c<result[b].count;c++) | ||
1535 | + { | ||
1536 | + if(result[b].info[c].type == 1)//�dz�β | ||
1537 | + { | ||
1538 | + sy_rect rear_rect=result[b].info[c].vehicle_body_detect_res.rect;//����� | ||
1539 | + | ||
1540 | + uint32_t alignWidth = (rear_rect.width_ + 127) / 128 * 128; | ||
1541 | + uint32_t alignHeight = (rear_rect.height_ + 15) / 16 * 16; | ||
1542 | + ACL_CALL(dvpp->PatchCropAndPaste(rear_cropImg[rear_idx], img_data_dvpp[b], rear_rect.left_, rear_rect.top_, rear_rect.left_+rear_rect.width_, rear_rect.top_+rear_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
1543 | + rear_img_data[rear_idx].w_ = alignWidth;//cropImg.width; | ||
1544 | + rear_img_data[rear_idx].h_ = alignHeight;//cropImg.height; | ||
1545 | + //rear_img_data[rear_idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(rear_cropImg[rear_idx].data.get(), rear_cropImg[rear_idx].size); //cropImg.data.get(); | ||
1546 | + rear_img_data[rear_idx].data_ = rear_cropImg[rear_idx].data.get(); | ||
1547 | + | ||
1548 | + scale_w[rear_idx] = (float)rear_rect.width_/alignWidth; | ||
1549 | + scale_h[rear_idx] = (float)rear_rect.height_/alignHeight; | ||
1550 | + | ||
1551 | + rear_idx++; | ||
1552 | + } | ||
1553 | + } | ||
1554 | + } | ||
1555 | + | ||
1556 | + if(rear_idx != rear_num) | ||
1557 | + LOG_ERROR("error:rear_idx != head_num"); | ||
1558 | + } | ||
1559 | + LOG_DEBUG("end rear3.1 crop head_img----- "); | ||
1560 | + //end for ��ȡ��β--------- | ||
1561 | + | ||
1562 | + //3.1.VR����ʶ��------------------------------��β����ʶ�������dz���---- | ||
1563 | + //��MAX_BATCHSIZE���� | ||
1564 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) | ||
1565 | + { | ||
1566 | + LOG_DEBUG("rear 3.2.vrr process----- "); | ||
1567 | + int vrr_batch_size = rear_num;// | ||
1568 | + | ||
1569 | + //��ʼ������ṹ�� | ||
1570 | + vr_result *vrr_result_= new vr_result[vrr_batch_size]; | ||
1571 | + for(int i=0;i<vrr_batch_size;i++) | ||
1572 | + { | ||
1573 | + memset(vrr_result_[i].vehicle_brand, '\0', sizeof(vrr_result_[i].vehicle_brand)); | ||
1574 | + memset(vrr_result_[i].vehicle_subbrand, '\0', sizeof(vrr_result_[i].vehicle_subbrand)); | ||
1575 | + memset(vrr_result_[i].vehicle_issue_year, '\0', sizeof(vrr_result_[i].vehicle_issue_year)); | ||
1576 | + memset(vrr_result_[i].vehicle_type, '\0', sizeof(vrr_result_[i].vehicle_type)); | ||
1577 | + memset(vrr_result_[i].freight_ton, '\0', sizeof(vrr_result_[i].freight_ton)); | ||
1578 | + vrr_result_[i].name_score = 0; | ||
1579 | + vrr_result_[i].index = 0; | ||
1580 | + } | ||
1581 | + | ||
1582 | + //process | ||
1583 | + res_status=vrr_batch(tools->vrr_handle, rear_img_data, vrr_batch_size, vrr_result_); | ||
1584 | + if (res_status != SUCCESS) | ||
1585 | + { | ||
1586 | + LOG_ERROR("sy_va_va_batch_vd(error): vrr process failed. (ret = {})", res_status); | ||
1587 | + return res_status; | ||
1588 | + } | ||
1589 | + | ||
1590 | + //output | ||
1591 | + int rear_idx=0;//�������� | ||
1592 | + for(int b=0;b<batch_size;b++) | ||
1593 | + { | ||
1594 | + for(int c=0;c<result[b].count;c++) | ||
1595 | + { | ||
1596 | + if(result[b].info[c].type == 1)//�dz�β | ||
1597 | + { | ||
1598 | + float score = vrr_result_[rear_idx].name_score; | ||
1599 | + if(score>0) | ||
1600 | + { | ||
1601 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vrr_result_[rear_idx].vehicle_brand,sizeof(char)*260); | ||
1602 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vrr_result_[rear_idx].vehicle_subbrand,sizeof(char)*260); | ||
1603 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vrr_result_[rear_idx].vehicle_issue_year,sizeof(char)*260); | ||
1604 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vrr_result_[rear_idx].vehicle_type,sizeof(char)*260); | ||
1605 | + memcpy(result[b].info[c].vehicle_recg_res.freight_ton, vrr_result_[rear_idx].freight_ton,sizeof(char)*260); | ||
1606 | + result[b].info[c].vehicle_recg_res.name_score = vrr_result_[rear_idx].name_score; | ||
1607 | + result[b].info[c].vehicle_recg_res.index = vrr_result_[rear_idx].index; | ||
1608 | + | ||
1609 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE + 9] = (float)vrr_result_[iter][index].index; //20201201wh���������ӳ���ɫ���� | ||
1610 | + //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE + 10] = (float)vrr_result_[iter][index].name_score; //20201201wh���������ӳ���ɫ���� | ||
1611 | + } | ||
1612 | + rear_idx++; | ||
1613 | + } | ||
1614 | + } | ||
1615 | + } | ||
1616 | + | ||
1617 | + | ||
1618 | + //release vrr_result_ | ||
1619 | + if (vrr_result_ != NULL) | ||
1620 | + { | ||
1621 | + delete[] vrr_result_; | ||
1622 | + } | ||
1623 | + LOG_DEBUG("end rear 3.2.vrr process----- "); | ||
1624 | + } | ||
1625 | + //end for 4.VR����ʶ��---------------------------------------- | ||
1626 | + | ||
1627 | + | ||
1628 | + | ||
1629 | + | ||
1630 | + //3.3.VF��������-----------------------------����������dz���------------- | ||
1631 | + //��MAX_BATCHSIZE���� | ||
1632 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) | ||
1633 | + { | ||
1634 | + LOG_DEBUG("rear 3.3 vf process---------- "); | ||
1635 | + int vf_rear_batch_size=rear_num;//��ͷ����//�ɰ汾�dz���Ϊ���� | ||
1636 | + | ||
1637 | + float ** fea=NULL; | ||
1638 | + if(vf_rear_batch_size>0)//�г� | ||
1639 | + { | ||
1640 | + //fea | ||
1641 | + fea=new float*[vf_rear_batch_size]; | ||
1642 | + for (int b = 0; b < vf_rear_batch_size; b++) | ||
1643 | + { | ||
1644 | + fea[b]=new float[FEATURESIZE]; | ||
1645 | + memset(fea[b],0,sizeof(float)*FEATURESIZE); | ||
1646 | + } | ||
1647 | + | ||
1648 | + //Process | ||
1649 | + res_status=vf_rear_feature_batch(tools->vf_rear_handle, rear_img_data, vf_rear_batch_size, fea); | ||
1650 | + if (res_status != SUCCESS) | ||
1651 | + { | ||
1652 | + LOG_ERROR("sy_va_va_batch_vd(error): vf rear process failed. (ret = {})", res_status); | ||
1653 | + return res_status; | ||
1654 | + } | ||
1655 | + } | ||
1656 | + | ||
1657 | + //output | ||
1658 | + int rear_idx=0; | ||
1659 | + for(int b=0;b<batch_size;b++) | ||
1660 | + { | ||
1661 | + for(int c=0;c<result[b].count;c++) | ||
1662 | + { | ||
1663 | + if(result[b].info[c].type == 1)//�dz�β | ||
1664 | + { | ||
1665 | + memcpy(result[b].info[c].vehicle_fea_res.feature,fea[rear_idx],sizeof(float)*FEATURESIZE); | ||
1666 | + memset(result[b].info[c].vehicle_fea_res.feature+FEATURESIZE,0,sizeof(float)*FEATURESIZE);//��β�ĺ���256��0���� | ||
1667 | + | ||
1668 | + rear_idx++; | ||
1669 | + } | ||
1670 | + } | ||
1671 | + } | ||
1672 | + | ||
1673 | + //delete------------- | ||
1674 | + if(vf_rear_batch_size>0)// | ||
1675 | + { | ||
1676 | + //fea | ||
1677 | + if(fea!= NULL) | ||
1678 | + { | ||
1679 | + for (int b = 0; b < vf_rear_batch_size; b++) | ||
1680 | + { | ||
1681 | + if(fea[b]!= NULL){ | ||
1682 | + delete[] fea[b]; | ||
1683 | + } | ||
1684 | + } | ||
1685 | + delete[] fea; | ||
1686 | + } | ||
1687 | + } | ||
1688 | + LOG_DEBUG("end rear 3.3.vf process---------- "); | ||
1689 | + } | ||
1690 | + //end rear3.3.VF��������----------------------------------------- | ||
1691 | + | ||
1692 | + //3.4.��βVP���Ƽ��ʶ��-------------------------------------------- | ||
1693 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
1694 | + { | ||
1695 | + LOG_DEBUG("rear 3.4.vp process----- "); | ||
1696 | + int vp_batch_size = rear_num;// | ||
1697 | + | ||
1698 | + //��ʼ������ṹ�� | ||
1699 | + vplates_result *vp_result = new vplates_result[vp_batch_size]; | ||
1700 | + | ||
1701 | + //Process | ||
1702 | + res_status=vpdr_batch(tools->vp_handle, rear_img_data, vp_batch_size, vp_result); | ||
1703 | + if (res_status != SUCCESS) | ||
1704 | + { | ||
1705 | + LOG_ERROR("sy_va_va_batch_vpdr(error): vpdr process failed. (ret = {})", res_status); | ||
1706 | + return res_status; | ||
1707 | + } | ||
1708 | + | ||
1709 | + //output | ||
1710 | + int rear_idx=0; | ||
1711 | + for(int b=0;b<batch_size;b++) | ||
1712 | + { | ||
1713 | + for(int c=0;c<result[b].count;c++) | ||
1714 | + { | ||
1715 | + auto& info_c = result[b].info[c]; | ||
1716 | + if(info_c.type == 1)//�dz�β | ||
1717 | + { | ||
1718 | + //ͳ�Ʒ�����ߵij��� | ||
1719 | + int max_index = 0; | ||
1720 | + float max_score = 0; | ||
1721 | + for (int m = 0; m < vp_result[rear_idx].count; m++) | ||
1722 | + { | ||
1723 | + if (vp_result[rear_idx].vehicle_plate_infos[m].detect_score > max_score) | ||
1724 | + { | ||
1725 | + max_score = vp_result[rear_idx].vehicle_plate_infos[m].detect_score; | ||
1726 | + max_index = m; | ||
1727 | + } | ||
1728 | + } | ||
1729 | + | ||
1730 | + if (vp_result[rear_idx].count==0 || vp_result[rear_idx].vehicle_plate_infos[max_index].rect.left_ == -1 )//û������ | ||
1731 | + { | ||
1732 | + info_c.vehicle_plate_det_recg_res.special_type = 0;//���������20200225 | ||
1733 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = 0; | ||
1734 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = -1; | ||
1735 | + | ||
1736 | + info_c.vehicle_plate_det_recg_res.type = 0; | ||
1737 | + info_c.vehicle_plate_det_recg_res.num_score = 0; | ||
1738 | + info_c.vehicle_plate_det_recg_res.detect_score = 0; | ||
1739 | + | ||
1740 | + info_c.vehicle_plate_det_recg_res.rect.left_ = 0; | ||
1741 | + info_c.vehicle_plate_det_recg_res.rect.top_ = 0; | ||
1742 | + info_c.vehicle_plate_det_recg_res.rect.width_ = 0; | ||
1743 | + info_c.vehicle_plate_det_recg_res.rect.height_ = 0; | ||
1744 | + | ||
1745 | + for(int p=0;p<PLATENUM;p++) | ||
1746 | + { | ||
1747 | + info_c.vehicle_plate_det_recg_res.recg[p].index = 0; | ||
1748 | + info_c.vehicle_plate_det_recg_res.recg[p].maxprob = 0; | ||
1749 | + //info_c.vehicle_plate_det_recg_res.recg[p].character = NULL; | ||
1750 | + memset(info_c.vehicle_plate_det_recg_res.recg[p].character, '\0', sizeof(info_c.vehicle_plate_det_recg_res.recg[p].character)); | ||
1751 | + } | ||
1752 | + | ||
1753 | + //20201201���ӳ������ij�����Ϣ | ||
1754 | + for(int p=0;p<PLATENUM;p++) | ||
1755 | + { | ||
1756 | + info_c.vehicle_fea_res.feature[FEATURESIZE*2+p] = 0; | ||
1757 | + } | ||
1758 | + } | ||
1759 | + else{ | ||
1760 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = vp_result[rear_idx].vehicle_plate_infos[max_index].state_score; | ||
1761 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = vp_result[rear_idx].vehicle_plate_infos[max_index].state; | ||
1762 | + | ||
1763 | + info_c.vehicle_plate_det_recg_res.type = vp_result[rear_idx].vehicle_plate_infos[max_index].type; | ||
1764 | + info_c.vehicle_plate_det_recg_res.num_score = vp_result[rear_idx].vehicle_plate_infos[max_index].num_score; | ||
1765 | + info_c.vehicle_plate_det_recg_res.detect_score = vp_result[rear_idx].vehicle_plate_infos[max_index].detect_score; | ||
1766 | + if (info_c.vehicle_plate_det_recg_res.detect_score > 0.1 && info_c.vehicle_plate_det_recg_res.stain_vp_result.type == 1) | ||
1767 | + { | ||
1768 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.type = 2; | ||
1769 | + info_c.vehicle_plate_det_recg_res.stain_vp_result.score = info_c.vehicle_plate_det_recg_res.detect_score; | ||
1770 | + } | ||
1771 | + | ||
1772 | + info_c.vehicle_plate_det_recg_res.rect.left_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.left_ * scale_w[rear_idx] + info_c.vehicle_body_detect_res.rect.left_; | ||
1773 | + info_c.vehicle_plate_det_recg_res.rect.top_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.top_ * scale_h[rear_idx] + info_c.vehicle_body_detect_res.rect.top_; | ||
1774 | + info_c.vehicle_plate_det_recg_res.rect.width_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.width_* scale_w[rear_idx]; | ||
1775 | + info_c.vehicle_plate_det_recg_res.rect.height_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.height_* scale_h[rear_idx]; | ||
1776 | + | ||
1777 | + for(int p=0;p<PLATENUM;p++) | ||
1778 | + { | ||
1779 | + info_c.vehicle_plate_det_recg_res.recg[p].index = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].index; | ||
1780 | + | ||
1781 | + info_c.vehicle_plate_det_recg_res.recg[p].maxprob = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].maxprob; | ||
1782 | + //info_c.vehicle_plate_det_recg_res.recg[p].character = vp_result[idx][j].recg[p].character; | ||
1783 | + info_c.vehicle_plate_det_recg_res.recg[p].character[0] = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].character[0]; | ||
1784 | + info_c.vehicle_plate_det_recg_res.recg[p].character[1] = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].character[1]; | ||
1785 | + info_c.vehicle_plate_det_recg_res.recg[p].character[2] = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].character[2]; | ||
1786 | + info_c.vehicle_plate_det_recg_res.recg[p].character[3] = vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].character[3]; | ||
1787 | + } | ||
1788 | + //20201201���ӳ������ij�����Ϣ | ||
1789 | + for(int p=0;p<PLATENUM;p++) | ||
1790 | + { | ||
1791 | + info_c.vehicle_fea_res.feature[FEATURESIZE*2+p] = (float)vp_result[rear_idx].vehicle_plate_infos[max_index].recg[p].index; | ||
1792 | + } | ||
1793 | + | ||
1794 | + //����������20200225 | ||
1795 | + //1.�ڳ�����ij���Ϊ��ʱ���� | ||
1796 | + sy_rect win_rect = info_c.vehicle_win_detect_res.rect; | ||
1797 | + sy_rect vp_rect = info_c.vehicle_plate_det_recg_res.rect; | ||
1798 | + if(vp_rect.left_ < win_rect.left_+win_rect.width_ && vp_rect.left_ + vp_rect.width_ > win_rect.left_ && vp_rect.top_ < win_rect.top_+win_rect.height_ && vp_rect.top_ + vp_rect.height_ > win_rect.top_ ) | ||
1799 | + { | ||
1800 | + info_c.vehicle_plate_det_recg_res.special_type = 1;//��ʱ����//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. | ||
1801 | + } | ||
1802 | + else | ||
1803 | + { | ||
1804 | + info_c.vehicle_plate_det_recg_res.special_type = 0;//���泵�� | ||
1805 | + } | ||
1806 | + } | ||
1807 | + | ||
1808 | + rear_idx++; | ||
1809 | + } | ||
1810 | + } | ||
1811 | + } | ||
1812 | + | ||
1813 | + //release vp_result | ||
1814 | + if (vp_result != NULL) | ||
1815 | + { | ||
1816 | + delete[] vp_result; | ||
1817 | + vp_result = NULL; | ||
1818 | + } | ||
1819 | + LOG_DEBUG("end rear 3.4.vp process----- "); | ||
1820 | + } | ||
1821 | + //end for 3.4.VP���Ƽ��ʶ��----------------------- | ||
1822 | + | ||
1823 | + } | ||
1824 | + | ||
1825 | + if(car_body_num>0) | ||
1826 | + { | ||
1827 | + LOG_DEBUG("body4.1 crop body_img----- "); | ||
1828 | + sy_img body_img_data[car_body_num]; | ||
1829 | + for(int b=0;b<car_body_num;b++) | ||
1830 | + { | ||
1831 | + body_img_data[b].data_ = NULL; | ||
1832 | + } | ||
1833 | + ImageData body_cropImg[car_body_num]; | ||
1834 | + if(tools->param.vehicle_color_config==SY_CONFIG_OPEN | ||
1835 | + || tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN) | ||
1836 | + { | ||
1837 | + int idx=0; | ||
1838 | + for (int b = 0; b < batch_size; b++) | ||
1839 | + { | ||
1840 | + for(int c=0;c<result[b].count;c++) | ||
1841 | + { | ||
1842 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ | ||
1843 | + { | ||
1844 | + sy_rect body_rect=result[b].info[c].vehicle_body_detect_res.rect;//���� | ||
1845 | + | ||
1846 | + uint32_t alignWidth = (body_rect.width_ + 127) / 128 * 128; | ||
1847 | + uint32_t alignHeight = (body_rect.height_ + 15) / 16 * 16; | ||
1848 | + ACL_CALL(dvpp->PatchCropAndPaste(body_cropImg[idx], img_data_dvpp[b], body_rect.left_, body_rect.top_, body_rect.left_+body_rect.width_, body_rect.top_+body_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
1849 | + | ||
1850 | + body_img_data[idx].w_ = alignWidth;//cropImg.width; | ||
1851 | + body_img_data[idx].h_ = alignHeight;//cropImg.height; | ||
1852 | + //body_img_data[idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(body_cropImg[idx].data.get(), body_cropImg[idx].size); //cropImg.data.get(); | ||
1853 | + body_img_data[idx].data_ = body_cropImg[idx].data.get(); //cropImg.data.get(); | ||
1854 | + | ||
1855 | + idx++; | ||
1856 | + | ||
1857 | + } | ||
1858 | + } | ||
1859 | + } | ||
1860 | + } | ||
1861 | + LOG_DEBUG("end body4.1 crop body_img----- "); | ||
1862 | + | ||
1863 | + if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) | ||
1864 | + { | ||
1865 | + LOG_DEBUG("body4.2 vcolor process----- "); | ||
1866 | + | ||
1867 | + int vc_batch_size=car_body_num;// | ||
1868 | + vc_result *vc_result_= new vc_result[vc_batch_size]; | ||
1869 | + | ||
1870 | + //process | ||
1871 | + res_status=vc_batch(tools->vc_handle, body_img_data, vc_batch_size, vc_result_); | ||
1872 | + if (res_status != SUCCESS) | ||
1873 | + { | ||
1874 | + LOG_ERROR("sy_va_va_batch_vd(error): vc process failed. (ret = {})", res_status); | ||
1875 | + return res_status; | ||
1876 | + } | ||
1877 | + | ||
1878 | + //output | ||
1879 | + int car_body_idx=0; | ||
1880 | + for(int b=0;b<batch_size;b++) | ||
1881 | + { | ||
1882 | + for(int c=0;c<result[b].count;c++) | ||
1883 | + { | ||
1884 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ | ||
1885 | + { | ||
1886 | + if(vc_result_[car_body_idx].score >= tools->param.vc_thresld && (vc_result_[car_body_idx].index>=0 && vc_result_[car_body_idx].index<13)) | ||
1887 | + { | ||
1888 | + result[b].info[c].vehicle_color_res.index = vc_result_[car_body_idx].index; | ||
1889 | + result[b].info[c].vehicle_color_res.score = vc_result_[car_body_idx].score; | ||
1890 | + | ||
1891 | + } | ||
1892 | + car_body_idx++; | ||
1893 | + } | ||
1894 | + } | ||
1895 | + } | ||
1896 | + | ||
1897 | + //release | ||
1898 | + if (vc_result_ != NULL) | ||
1899 | + { | ||
1900 | + delete[] vc_result_; | ||
1901 | + vc_result_ = NULL; | ||
1902 | + } | ||
1903 | + LOG_DEBUG("end body4.2.vcolor process----- "); | ||
1904 | + } | ||
1905 | + //end for body4.2 VColor����ɫʶ��--------------------------- | ||
1906 | + | ||
1907 | + | ||
1908 | + //4-3����ʶ��ʶ��---VERSION_WUXI �����汾���� | ||
1909 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN && VERSION_WUXI ) | ||
1910 | + { | ||
1911 | + vr_supplement_wuxi(handle, body_img_data, batch_size, car_body_num, result); | ||
1912 | + } | ||
1913 | + //4-3����ʶ��ʶ��--�������汾���� | ||
1914 | + if(!VERSION_WUXI && tools->param.vehicle_recg_config==SY_CONFIG_OPEN && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN ) | ||
1915 | + { | ||
1916 | + vr_supplement(handle, body_img_data, batch_size, car_body_num, result); | ||
1917 | + } //end for ����ʶ�����복logo�����ϲ���--------------------------- | ||
1918 | + | ||
1919 | + } | ||
1920 | + | ||
1921 | + if (tools->param.vehicle_feature_config == SY_CONFIG_OPEN | ||
1922 | + || tools->param.vehicle_illegal_config == SY_CONFIG_OPEN) | ||
1923 | + { | ||
1924 | + LOG_DEBUG("7.head win vf+vid ----- "); | ||
1925 | + | ||
1926 | + for(int b=0;b<batch_size;b++) | ||
1927 | + { | ||
1928 | + for(int c=0;c<result[b].count;c++) | ||
1929 | + { | ||
1930 | + sy_rect win_rect =result[b].info[c].vehicle_win_detect_res.rect;//�����dz��� | ||
1931 | + if(result[b].info[c].type == 0 && win_rect.width_!=0 && win_rect.height_!=0)//�dz�ͷ+�г��� | ||
1932 | + { | ||
1933 | + sy_img win_img_data[1]; | ||
1934 | + win_img_data[0].data_ = NULL; | ||
1935 | + | ||
1936 | + uint32_t alignWidth = (win_rect.width_ + 127) / 128 * 128; | ||
1937 | + uint32_t alignHeight = (win_rect.height_ + 15) / 16 * 16; | ||
1938 | + ImageData cropImg; | ||
1939 | + ACL_CALL(dvpp->PatchCropAndPaste(cropImg, img_data_dvpp[b], win_rect.left_, win_rect.top_, win_rect.left_+win_rect.width_, win_rect.top_+win_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
1940 | + | ||
1941 | + win_img_data[0].w_ = alignWidth;//cropImg.width; | ||
1942 | + win_img_data[0].h_ = alignHeight;//cropImg.height; | ||
1943 | + //win_img_data[0].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(cropImg.data.get(), cropImg.size); //cropImg.data.get(); | ||
1944 | + win_img_data[0].data_ = cropImg.data.get(); | ||
1945 | + | ||
1946 | + //��ͷ�������� | ||
1947 | + if (tools->param.vehicle_feature_config == SY_CONFIG_OPEN) | ||
1948 | + { | ||
1949 | + | ||
1950 | + float ** win_feature=new float*[1]; | ||
1951 | + win_feature[0]=new float[FEATURESIZE]; | ||
1952 | + | ||
1953 | + res_status = vf_win_feature_batch(tools->vf_win_handle, win_img_data, 1, win_feature); | ||
1954 | + if (res_status != SUCCESS) | ||
1955 | + { | ||
1956 | + LOG_ERROR("sy_va_va_batch_vd(error): vf_win_feature_batch failed. (ret = {})", res_status); | ||
1957 | + return res_status; | ||
1958 | + } | ||
1959 | + | ||
1960 | + //output | ||
1961 | + memcpy(result[b].info[c].vehicle_fea_res.feature+FEATURESIZE,win_feature[0],sizeof(float)*FEATURESIZE); | ||
1962 | + | ||
1963 | + //delete | ||
1964 | + if(win_feature[0]!= NULL) | ||
1965 | + { | ||
1966 | + delete[] win_feature[0]; | ||
1967 | + win_feature[0]=NULL; | ||
1968 | + } | ||
1969 | + if(win_feature!= NULL) | ||
1970 | + { | ||
1971 | + delete[] win_feature; | ||
1972 | + win_feature=NULL; | ||
1973 | + } | ||
1974 | + } | ||
1975 | + | ||
1976 | + //��ͷ������Υ�� | ||
1977 | + if (tools->param.vehicle_illegal_config == SY_CONFIG_OPEN) | ||
1978 | + { | ||
1979 | + | ||
1980 | + vid_result vid_result_[1]; | ||
1981 | + res_status=vid_process(tools->vid_handle, win_img_data, 1, vid_result_); | ||
1982 | + if (res_status != SUCCESS) | ||
1983 | + { | ||
1984 | + LOG_ERROR("sy_va_va_batch_vd(error): vid process failed. (ret = {})", res_status); | ||
1985 | + return res_status; | ||
1986 | + } | ||
1987 | + | ||
1988 | + //output | ||
1989 | + result[b].info[c].vehicle_illegal_det_res.driver.person.status = vid_result_[0].driver.person.status; | ||
1990 | + result[b].info[c].vehicle_illegal_det_res.driver.person.confidence = vid_result_[0].driver.person.confidence; | ||
1991 | + result[b].info[c].vehicle_illegal_det_res.driver.belt.status = vid_result_[0].driver.belt.status; | ||
1992 | + result[b].info[c].vehicle_illegal_det_res.driver.belt.confidence = vid_result_[0].driver.belt.confidence; | ||
1993 | + result[b].info[c].vehicle_illegal_det_res.driver.smoke.status = vid_result_[0].driver.smoke.status; | ||
1994 | + result[b].info[c].vehicle_illegal_det_res.driver.smoke.confidence = vid_result_[0].driver.smoke.confidence; | ||
1995 | + result[b].info[c].vehicle_illegal_det_res.driver.phone.status = vid_result_[0].driver.phone.status; | ||
1996 | + result[b].info[c].vehicle_illegal_det_res.driver.phone.confidence = vid_result_[0].driver.phone.confidence; | ||
1997 | + result[b].info[c].vehicle_illegal_det_res.driver.call.status = vid_result_[0].driver.call.status; | ||
1998 | + result[b].info[c].vehicle_illegal_det_res.driver.call.confidence = vid_result_[0].driver.call.confidence; | ||
1999 | + | ||
2000 | + result[b].info[c].vehicle_illegal_det_res.copilot.person.status = vid_result_[0].copilot.person.status; | ||
2001 | + result[b].info[c].vehicle_illegal_det_res.copilot.person.confidence = vid_result_[0].copilot.person.confidence; | ||
2002 | + result[b].info[c].vehicle_illegal_det_res.copilot.belt.status = vid_result_[0].copilot.belt.status; | ||
2003 | + result[b].info[c].vehicle_illegal_det_res.copilot.belt.confidence = vid_result_[0].copilot.belt.confidence; | ||
2004 | + result[b].info[c].vehicle_illegal_det_res.copilot.smoke.status = vid_result_[0].copilot.smoke.status; | ||
2005 | + result[b].info[c].vehicle_illegal_det_res.copilot.smoke.confidence = vid_result_[0].copilot.smoke.confidence; | ||
2006 | + result[b].info[c].vehicle_illegal_det_res.copilot.phone.status = vid_result_[0].copilot.phone.status; | ||
2007 | + result[b].info[c].vehicle_illegal_det_res.copilot.phone.confidence = vid_result_[0].copilot.phone.confidence; | ||
2008 | + result[b].info[c].vehicle_illegal_det_res.copilot.call.status = vid_result_[0].copilot.call.status; | ||
2009 | + result[b].info[c].vehicle_illegal_det_res.copilot.call.confidence = vid_result_[0].copilot.call.confidence; | ||
2010 | + | ||
2011 | + | ||
2012 | + } | ||
2013 | + | ||
2014 | + } | ||
2015 | + } | ||
2016 | + | ||
2017 | + } | ||
2018 | + | ||
2019 | + LOG_DEBUG("end 7.head win vf+vid ----- "); | ||
2020 | + | ||
2021 | + } | ||
2022 | + //process_vidresult(handle, batch_size, result); | ||
2023 | + process_vidresult_atlas(handle, batch_size, result); | ||
2024 | + | ||
2025 | + if(motor_num>0) | ||
2026 | + { | ||
2027 | + //double t22 = msecond(); | ||
2028 | + | ||
2029 | + LOG_DEBUG("start mta-step2:motor_img_data."); | ||
2030 | + sy_img motor_img_data[motor_num]; | ||
2031 | + for(int b=0;b<motor_num;b++) | ||
2032 | + { | ||
2033 | + motor_img_data[b].data_ = NULL; | ||
2034 | + } | ||
2035 | + ImageData motor_cropImg[motor_num]; | ||
2036 | + float scale_w[motor_num]; | ||
2037 | + float scale_h[motor_num]; | ||
2038 | + | ||
2039 | + if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) | ||
2040 | + { | ||
2041 | + int motor_idx=0; | ||
2042 | + for (int b = 0; b < batch_size; b++) | ||
2043 | + { | ||
2044 | + for(int c=0;c<result[b].count;c++) | ||
2045 | + { | ||
2046 | + if(result[b].info[c].type == 2)//��motor | ||
2047 | + { | ||
2048 | + sy_rect motor_rect=result[b].info[c].vehicle_body_detect_res.rect;//motor���� | ||
2049 | + | ||
2050 | + uint32_t alignWidth = (motor_rect.width_ + 127) / 128 * 128; | ||
2051 | + uint32_t alignHeight = (motor_rect.height_ + 15) / 16 * 16; | ||
2052 | + ACL_CALL(dvpp->PatchCropAndPaste(motor_cropImg[motor_idx], img_data_dvpp[b], motor_rect.left_, motor_rect.top_, motor_rect.left_+motor_rect.width_, motor_rect.top_+motor_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
2053 | + motor_img_data[motor_idx].w_ = alignWidth;//cropImg.width; | ||
2054 | + motor_img_data[motor_idx].h_ = alignHeight;//cropImg.height; | ||
2055 | + //motor_img_data[motor_idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(motor_cropImg[motor_idx].data.get(), motor_cropImg[motor_idx].size); //cropImg.data.get(); | ||
2056 | + motor_img_data[motor_idx].data_ = motor_cropImg[motor_idx].data.get(); | ||
2057 | + | ||
2058 | + scale_w[motor_idx] = (float)motor_rect.width_/alignWidth; | ||
2059 | + scale_h[motor_idx] = (float)motor_rect.height_/alignHeight; | ||
2060 | + | ||
2061 | + motor_idx++; | ||
2062 | + } | ||
2063 | + } | ||
2064 | + } | ||
2065 | + | ||
2066 | + if(motor_idx != motor_num) | ||
2067 | + LOG_ERROR("error:motor_idx != motor_num"); | ||
2068 | + | ||
2069 | + } | ||
2070 | + LOG_DEBUG("end crop motor_img_data----- "); | ||
2071 | + | ||
2072 | + //Ħ�г��Ƿ��ͷ������ | ||
2073 | + if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) | ||
2074 | + { | ||
2075 | + LOG_DEBUG("start motor hcp."); | ||
2076 | + int motor_batch_size = motor_num; | ||
2077 | + hcp_analysis_result * hcp_result = new hcp_analysis_result[motor_batch_size]; | ||
2078 | + int ret = hcp_batch(tools->hcp_handle, motor_img_data, motor_batch_size, hcp_result); | ||
2079 | + | ||
2080 | + //output Ħ�г���ʻ�˴�ͷ�� | ||
2081 | + int motor_idx=0; | ||
2082 | + for (int b = 0; b < batch_size; b++) | ||
2083 | + { | ||
2084 | + for(int c=0;c<result[b].count;c++) | ||
2085 | + { | ||
2086 | + if(result[b].info[c].type == 2)///Ħ�� | ||
2087 | + { | ||
2088 | + int res_index = hcp_result[motor_idx].res_objs[0].res_index;//��ȡĦ�г���ʻ�˵�head������ | ||
2089 | + float res_socre = hcp_result[motor_idx].res_objs[0].res_prob; | ||
2090 | + if(res_index == 4)//head������ͷ�� | ||
2091 | + { | ||
2092 | + result[b].info[c].mta_res.motor_driver_helmeted.status=MOTOR_DRIVER_HELMETED;//��ͷ�� | ||
2093 | + result[b].info[c].mta_res.motor_driver_helmeted.confidence=res_socre; | ||
2094 | + } | ||
2095 | + else | ||
2096 | + { | ||
2097 | + result[b].info[c].mta_res.motor_driver_helmeted.status=MOTOR_DRIVER_NOT_HELMETED;//δ��ͷ�� | ||
2098 | + result[b].info[c].mta_res.motor_driver_helmeted.confidence=res_socre; | ||
2099 | + } | ||
2100 | + | ||
2101 | + motor_idx++; | ||
2102 | + } | ||
2103 | + } | ||
2104 | + } | ||
2105 | + | ||
2106 | + if(hcp_result!= NULL) | ||
2107 | + { | ||
2108 | + delete[] hcp_result; | ||
2109 | + hcp_result=NULL; | ||
2110 | + } | ||
2111 | + } | ||
2112 | + LOG_DEBUG("end motor hcp."); | ||
2113 | + } | ||
2114 | + | ||
2115 | + int tricycle_batch_size = tricycle_num + (car_body_num - head_num -rear_num);//type ==4��type = 3��Ŀ�� | ||
2116 | + if(tricycle_batch_size>0) | ||
2117 | + { | ||
2118 | + LOG_DEBUG("start :tricycle_img_data."); | ||
2119 | + | ||
2120 | + sy_img tricycle_img_data[tricycle_batch_size]; | ||
2121 | + for(int b=0;b<tricycle_batch_size;b++) | ||
2122 | + { | ||
2123 | + tricycle_img_data[b].data_ = NULL; | ||
2124 | + } | ||
2125 | + //std::shared_ptr<uint8_t> data_tricycle[tricycle_batch_size]; | ||
2126 | + ImageData tricycle_cropImg[tricycle_batch_size];//�� tricycle_img_data ��Ӧ | ||
2127 | + | ||
2128 | + float scale_w[tricycle_batch_size]; | ||
2129 | + float scale_h[tricycle_batch_size]; | ||
2130 | + | ||
2131 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
2132 | + { | ||
2133 | + int tricycle_idx=0; | ||
2134 | + for (int b = 0; b < batch_size; b++) | ||
2135 | + { | ||
2136 | + for(int c=0;c<result[b].count;c++) | ||
2137 | + { | ||
2138 | + if(result[b].info[c].type == 3 || result[b].info[c].type == 4)//��tricycle �� ��ͷβ�ij��� | ||
2139 | + { | ||
2140 | + sy_rect tricycle_rect=result[b].info[c].vehicle_body_detect_res.rect; | ||
2141 | + //tricycle_rect=rect_extend(tricycle_rect,img_w,img_h,0.2);//����Ŀ����ȵ�0.2 | ||
2142 | + | ||
2143 | + uint32_t alignWidth = (tricycle_rect.width_ + 127) / 128 * 128; | ||
2144 | + uint32_t alignHeight = (tricycle_rect.height_ + 15) / 16 * 16; | ||
2145 | + ACL_CALL(dvpp->PatchCropAndPaste(tricycle_cropImg[tricycle_idx], img_data_dvpp[b], tricycle_rect.left_, tricycle_rect.top_, tricycle_rect.left_+tricycle_rect.width_, tricycle_rect.top_+tricycle_rect.height_, alignWidth, alignHeight), SY_SUCCESS, SY_FAILED); | ||
2146 | + tricycle_img_data[tricycle_idx].w_ = alignWidth;//cropImg.width; | ||
2147 | + tricycle_img_data[tricycle_idx].h_ = alignHeight;//cropImg.height; | ||
2148 | + tricycle_img_data[tricycle_idx].data_ = tricycle_cropImg[tricycle_idx].data.get(); //tricycle_cropImg[tricycle_idx].data.get(); | ||
2149 | + | ||
2150 | + scale_w[tricycle_idx] = (float)tricycle_rect.width_/alignWidth; | ||
2151 | + scale_h[tricycle_idx] = (float)tricycle_rect.height_/alignHeight; | ||
2152 | + | ||
2153 | + tricycle_idx++; | ||
2154 | + } | ||
2155 | + } | ||
2156 | + } | ||
2157 | + | ||
2158 | + if(tricycle_idx != tricycle_batch_size) | ||
2159 | + LOG_ERROR("error:tricycle_idx != tricycle_batch_size"); | ||
2160 | + | ||
2161 | + } | ||
2162 | + LOG_DEBUG("end crop tricycle_img_data----- "); | ||
2163 | + | ||
2164 | + | ||
2165 | + //5.VP���Ƽ��ʶ��-------------------------------------------- | ||
2166 | + //��MAX_BATCHSIZE���� | ||
2167 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
2168 | + { | ||
2169 | + LOG_DEBUG("tricycle 5.vp process----- "); | ||
2170 | + int vp_batch_size=tricycle_batch_size;// | ||
2171 | + | ||
2172 | + //��ʼ������ṹ�� | ||
2173 | + vplates_result *vp_result= new vplates_result[vp_batch_size]; | ||
2174 | + | ||
2175 | + //Process | ||
2176 | + res_status=vpdr_batch(tools->vp_handle, tricycle_img_data, vp_batch_size, vp_result); | ||
2177 | + if (res_status != SUCCESS) | ||
2178 | + { | ||
2179 | + LOG_ERROR("sy_va_va_batch_vpdr(error): vpdr process failed. (ret = {})", res_status); | ||
2180 | + return res_status; | ||
2181 | + } | ||
2182 | + | ||
2183 | + //output | ||
2184 | + int tricycle_idx=0; | ||
2185 | + for(int b=0;b<batch_size;b++) | ||
2186 | + { | ||
2187 | + for(int c=0;c<result[b].count;c++) | ||
2188 | + { | ||
2189 | + if(result[b].info[c].type == 3 || result[b].info[c].type == 4)//��tricycle �� ���� | ||
2190 | + { | ||
2191 | + //ͳ�Ʒ�����ߵij��� | ||
2192 | + int max_index = 0; | ||
2193 | + float max_score = 0; | ||
2194 | + for (int m = 0; m < vp_result[tricycle_idx].count; m++) | ||
2195 | + { | ||
2196 | + if (vp_result[tricycle_idx].vehicle_plate_infos[m].detect_score > max_score) | ||
2197 | + { | ||
2198 | + max_score = vp_result[tricycle_idx].vehicle_plate_infos[m].detect_score; | ||
2199 | + max_index = m; | ||
2200 | + } | ||
2201 | + } | ||
2202 | + | ||
2203 | + | ||
2204 | + if (vp_result[tricycle_idx].count==0 || max_index == -1 )//û������ | ||
2205 | + { | ||
2206 | + result[b].info[c].vehicle_plate_det_recg_res.special_type = 0;//���������20200225 | ||
2207 | + | ||
2208 | + result[b].info[c].vehicle_plate_det_recg_res.type = 0; | ||
2209 | + result[b].info[c].vehicle_plate_det_recg_res.num_score = 0; | ||
2210 | + result[b].info[c].vehicle_plate_det_recg_res.detect_score = 0; | ||
2211 | + | ||
2212 | + result[b].info[c].vehicle_plate_det_recg_res.rect.left_ = result[b].info[c].vehicle_body_detect_res.rect.left_; | ||
2213 | + result[b].info[c].vehicle_plate_det_recg_res.rect.top_ = result[b].info[c].vehicle_body_detect_res.rect.top_; | ||
2214 | + result[b].info[c].vehicle_plate_det_recg_res.rect.width_ = 0; | ||
2215 | + result[b].info[c].vehicle_plate_det_recg_res.rect.height_ = 0; | ||
2216 | + | ||
2217 | + for(int p=0;p<PLATENUM;p++) | ||
2218 | + { | ||
2219 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].index = 0; | ||
2220 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].maxprob = 0; | ||
2221 | + //result[b].info[c].vehicle_plate_det_recg_res.recg[p].character = NULL; | ||
2222 | + memset(result[b].info[c].vehicle_plate_det_recg_res.recg[p].character, '\0', sizeof(result[b].info[c].vehicle_plate_det_recg_res.recg[p].character)); | ||
2223 | + } | ||
2224 | + | ||
2225 | + } | ||
2226 | + else{ | ||
2227 | + result[b].info[c].vehicle_plate_det_recg_res.type = vp_result[tricycle_idx].vehicle_plate_infos[max_index].type; | ||
2228 | + result[b].info[c].vehicle_plate_det_recg_res.num_score = vp_result[tricycle_idx].vehicle_plate_infos[max_index].num_score; | ||
2229 | + result[b].info[c].vehicle_plate_det_recg_res.detect_score = vp_result[tricycle_idx].vehicle_plate_infos[max_index].detect_score; | ||
2230 | + | ||
2231 | + result[b].info[c].vehicle_plate_det_recg_res.rect.left_ = vp_result[tricycle_idx].vehicle_plate_infos[max_index].rect.left_ * scale_w[tricycle_idx] + result[b].info[c].vehicle_body_detect_res.rect.left_;//ӳ�䳵�� | ||
2232 | + result[b].info[c].vehicle_plate_det_recg_res.rect.top_ = vp_result[tricycle_idx].vehicle_plate_infos[max_index].rect.top_ * scale_h[tricycle_idx] + result[b].info[c].vehicle_body_detect_res.rect.top_;//ӳ�䳵�� | ||
2233 | + result[b].info[c].vehicle_plate_det_recg_res.rect.width_ = vp_result[tricycle_idx].vehicle_plate_infos[max_index].rect.width_ * scale_w[tricycle_idx]; | ||
2234 | + result[b].info[c].vehicle_plate_det_recg_res.rect.height_ = vp_result[tricycle_idx].vehicle_plate_infos[max_index].rect.height_ * scale_h[tricycle_idx]; | ||
2235 | + | ||
2236 | + for(int p=0;p<PLATENUM;p++) | ||
2237 | + { | ||
2238 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].index = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].index; | ||
2239 | + | ||
2240 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].maxprob = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].maxprob; | ||
2241 | + //result[b].info[c].vehicle_plate_det_recg_res.recg[p].character = vp_result[idx][j].recg[p].character; | ||
2242 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].character[0] = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].character[0]; | ||
2243 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].character[1] = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].character[1]; | ||
2244 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].character[2] = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].character[2]; | ||
2245 | + result[b].info[c].vehicle_plate_det_recg_res.recg[p].character[3] = vp_result[tricycle_idx].vehicle_plate_infos[max_index].recg[p].character[3]; | ||
2246 | + } | ||
2247 | + } | ||
2248 | + | ||
2249 | + tricycle_idx++; | ||
2250 | + } | ||
2251 | + } | ||
2252 | + } | ||
2253 | + | ||
2254 | + | ||
2255 | + //release vp_result | ||
2256 | + if (vp_result != NULL) | ||
2257 | + { | ||
2258 | + delete[] vp_result; | ||
2259 | + vp_result = NULL; | ||
2260 | + } | ||
2261 | + LOG_DEBUG("end tricycle 5.vp process----- "); | ||
2262 | + } | ||
2263 | + //end for 5.VP���Ƽ��ʶ��----------------------- | ||
2264 | + | ||
2265 | + } | ||
2266 | + //end tricycle ���� | ||
2267 | + | ||
2268 | + | ||
2269 | + | ||
2270 | + //delete | ||
2271 | + delete dvpp; | ||
2272 | + dvpp = nullptr; | ||
2273 | + (void) aclrtDestroyStream(stream); | ||
2274 | + | ||
2275 | + LOG_DEBUG("10. finish process, return success----- "); | ||
2276 | + | ||
2277 | + return SUCCESS; | ||
2278 | +} | ||
2279 | + | ||
2280 | + | ||
2281 | + | ||
2282 | +float va_compute_similarity( float *Afea, float *Bfea, int featuresize) | ||
2283 | +{ | ||
2284 | + float ss = 0.0f; | ||
2285 | + | ||
2286 | + float xy=0; | ||
2287 | + float xx=0; | ||
2288 | + float yy=0; | ||
2289 | + for(int i=0;i<featuresize;i++) | ||
2290 | + { | ||
2291 | + xy += Afea[i] * Bfea[i]; | ||
2292 | + xx += Afea[i] * Afea[i]; | ||
2293 | + yy += Bfea[i] * Bfea[i]; | ||
2294 | + } | ||
2295 | + | ||
2296 | + float xxyy = sqrt(xx) * sqrt(yy) ; | ||
2297 | + if(xxyy != 0) | ||
2298 | + ss = xy / xxyy; | ||
2299 | + | ||
2300 | + if(ss < 0) | ||
2301 | + ss = 0; | ||
2302 | + | ||
2303 | + return ss; | ||
2304 | +} | ||
2305 | + | ||
2306 | + | ||
2307 | +//featureΪ FEATURESIZE=512ά������ + 8ά�������� | ||
2308 | +//���ƣ�FEATURESIZE+0 ~ FEATURESIZE+7 | ||
2309 | +float va_compute_similarity_byvafeature(void * handle , float *Afea, float *Bfea, int featuresize) | ||
2310 | +{ | ||
2311 | + va_handle *tools=(va_handle *)handle; | ||
2312 | + | ||
2313 | + float similarity = 0; | ||
2314 | + | ||
2315 | + //������ | ||
2316 | + float vf_similarity = 0 ; | ||
2317 | + float vf_head_similarity = 0 ; | ||
2318 | + float vf_win_similarity = 0 ; | ||
2319 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN)//VF | ||
2320 | + { | ||
2321 | + vf_head_similarity = vf_head_compute_similarity( Afea, Bfea, FEATURESIZE); | ||
2322 | + vf_win_similarity = vf_win_compute_similarity( Afea+FEATURESIZE, Bfea+FEATURESIZE, FEATURESIZE); | ||
2323 | + vf_similarity = 0.5*vf_head_similarity +0.5*vf_win_similarity ; | ||
2324 | + | ||
2325 | + } | ||
2326 | + similarity = vf_similarity; | ||
2327 | + | ||
2328 | + if(1) | ||
2329 | + { | ||
2330 | + float score_vp = 0; | ||
2331 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
2332 | + { | ||
2333 | + int count =0; | ||
2334 | + for (int m = 0; m < PLATENUM; m++)//6�������ַ���ͬ���㳵����ͬ��������1���� | ||
2335 | + { | ||
2336 | + if(Afea[FEATURESIZE*2+m] == Bfea[FEATURESIZE*2+m] && Afea[FEATURESIZE*2+m] !=0) | ||
2337 | + count++; | ||
2338 | + } | ||
2339 | + | ||
2340 | + if(count >=7 ) | ||
2341 | + { | ||
2342 | + score_vp = 1; | ||
2343 | + } | ||
2344 | + else if(count ==6 ) | ||
2345 | + { | ||
2346 | + score_vp = 0.9; | ||
2347 | + } | ||
2348 | + else if(count ==5 ) | ||
2349 | + { | ||
2350 | + score_vp = 0.7; | ||
2351 | + } | ||
2352 | + else | ||
2353 | + { | ||
2354 | + score_vp = 0.1; | ||
2355 | + } | ||
2356 | + | ||
2357 | + float scale_feat = 0.500; | ||
2358 | + float scale_vp = 0.500; | ||
2359 | + if(score_vp >0.9) | ||
2360 | + { | ||
2361 | + scale_feat = 0.200; | ||
2362 | + scale_vp = 0.800; | ||
2363 | + } | ||
2364 | + else if(score_vp >0.8) | ||
2365 | + { | ||
2366 | + scale_feat = 0.500; | ||
2367 | + scale_vp = 0.500; | ||
2368 | + } | ||
2369 | + | ||
2370 | + float similarity1 = vf_similarity*scale_feat + score_vp*scale_vp; | ||
2371 | + | ||
2372 | + if(similarity1 >=0.75) | ||
2373 | + { | ||
2374 | + similarity = similarity1; | ||
2375 | + return similarity; | ||
2376 | + } | ||
2377 | + } | ||
2378 | + } | ||
2379 | + | ||
2380 | + return similarity; | ||
2381 | +} | ||
2382 | + | ||
2383 | + | ||
2384 | + | ||
2385 | +void va_release(void ** handle) | ||
2386 | +{ | ||
2387 | + va_handle *tools=(va_handle *)*handle; | ||
2388 | + | ||
2389 | + //1.������� | ||
2390 | + if(tools->param.vehicle_detect_config==SY_CONFIG_OPEN) | ||
2391 | + { | ||
2392 | + vpt_release(&(tools->vpt_handle)); | ||
2393 | + } | ||
2394 | + | ||
2395 | + | ||
2396 | + //6.VPD�����Լ�� | ||
2397 | + if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) | ||
2398 | + { | ||
2399 | + vpd_release(&(tools->vpd_handle)); | ||
2400 | + } | ||
2401 | + | ||
2402 | + | ||
2403 | + //vc | ||
2404 | + if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) | ||
2405 | + { | ||
2406 | + vc_release(&(tools->vc_handle)); | ||
2407 | + } | ||
2408 | + | ||
2409 | + | ||
2410 | + //4.VR����ʶ�� | ||
2411 | + if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) | ||
2412 | + { | ||
2413 | + vr_release(&(tools->vr_handle)); | ||
2414 | + | ||
2415 | + vrr_release(&(tools->vrr_handle));//����� | ||
2416 | + | ||
2417 | + if(VERSION_WUXI) | ||
2418 | + { | ||
2419 | + vr_vehicle_type_15cls_release(&(tools->vr_vr15cls_handle));//����15���� | ||
2420 | + if(VR_WUXI_LOGO) | ||
2421 | + { | ||
2422 | + vlogodr_release(&(tools->vr_logo_dr_handle));//��logo���ʶ�� | ||
2423 | + } | ||
2424 | + } | ||
2425 | + | ||
2426 | + if(!VERSION_WUXI && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN)//����ʶ��ʶ�� | ||
2427 | + { | ||
2428 | + vlogodr_release(&(tools->vr_logo_dr_handle));//��logo���ʶ�� | ||
2429 | + vr_vehicle_type_15cls_release(&(tools->vr_vr15cls_handle));//����15���� | ||
2430 | + vr_vehicle_type_3885cls_release(&(tools->vr_vr3885cls_handle));//���������� | ||
2431 | + } | ||
2432 | + } | ||
2433 | + | ||
2434 | + | ||
2435 | + //5.VP���Ƽ��ʶ�� | ||
2436 | + if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) | ||
2437 | + { | ||
2438 | + vpdr_release(&(tools->vp_handle)); | ||
2439 | + } | ||
2440 | + | ||
2441 | + | ||
2442 | + | ||
2443 | + //7.VID���� | ||
2444 | + if(tools->param.vehicle_illegal_config==SY_CONFIG_OPEN)//VID | ||
2445 | + { | ||
2446 | + vid_release(&(tools->vid_handle)); | ||
2447 | + } | ||
2448 | + | ||
2449 | + //8.VF�������� | ||
2450 | + if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN)//VF | ||
2451 | + { | ||
2452 | + vf_head_release(&(tools->vf_head_handle)); | ||
2453 | + vf_win_release(&(tools->vf_win_handle)); | ||
2454 | + vf_rear_release(&(tools->vf_rear_handle));//������� | ||
2455 | + } | ||
2456 | + | ||
2457 | + //11.mta��� | ||
2458 | + if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN)//MTA | ||
2459 | + { | ||
2460 | + hcp_release(&(tools->hcp_handle)); | ||
2461 | + } | ||
2462 | + | ||
2463 | + if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN)//MTA | ||
2464 | + { | ||
2465 | + hs_det_release(&(tools->hs_handle)); | ||
2466 | + } | ||
2467 | + | ||
2468 | + | ||
2469 | + //delet dvpp | ||
2470 | + aclrtDestroyContext(tools->ctx); | ||
2471 | + aclrtResetDevice(tools->param.gpuid); | ||
2472 | + //aclFinalize(); | ||
2473 | + | ||
2474 | + if (tools) | ||
2475 | + { | ||
2476 | + delete tools; | ||
2477 | + tools = NULL; | ||
2478 | + } | ||
2479 | +} | ||
2480 | + | ||
2481 | + | ||
2482 | +void va_acl_release() | ||
2483 | +{ | ||
2484 | + aclFinalize(); | ||
2485 | +} | ||
2486 | + | ||
2487 | + | ||
2488 | + | ||
2489 | +//1.��绰 | ||
2490 | +//������� | ||
2491 | +//-��Ӧ�����ˣ� | ||
2492 | +//-��Ӧ�Υ��ʶ��Ϊ��绰�������Լ��ֻ���λ�ÿ��ϡ����������Ŷ�>0.85 or | ||
2493 | +//��Ӧ����Լ��ֻ���λ�ÿ��ϡ����������Ŷ�>0.9�� | ||
2494 | + | ||
2495 | +//2.���ֻ� | ||
2496 | +//������� | ||
2497 | +//-��Ӧ�����ˣ� | ||
2498 | +//-��Ӧ�Υ��ʶ��Ϊ���ֻ�(0308ģ�ͽ�����绰�ж�)�������Լ��ֻ���λ�ÿ��¡����������Ŷ�>0.75(�ɵ���Ϊ0���ʹ�����긨��) or | ||
2499 | +// ��Ӧ����Լ��ֻ���λ�ÿ��¡����������Ŷ�>0.9�� | ||
2500 | + | ||
2501 | +//3.δϵ��ȫ�� | ||
2502 | +//������� | ||
2503 | +//-��Ӧ�����ˣ� | ||
2504 | +//-��Ӧ�Υ���ж�Ϊδϵ��ȫ����������δ����ȫ��(��������ȫ��ȡ��)�� | ||
2505 | +// ����ȫ�����ж��������Լ��а�ȫ��(���Ŷ�>0.2����)����ͨ�������ж����ڶ�Ӧ��(����/����)�� | ||
2506 | + | ||
2507 | +//4.���� | ||
2508 | +//������� | ||
2509 | +//-��Ӧ�����ˣ� | ||
2510 | +//-��Ӧ�Υ��ʶ��ΪΥ���ҳ����Լ����� or | ||
2511 | +// ��Ӧ����Լ����̡����������Ŷ�>0.8�� | ||
2512 | + | ||
2513 | +//5.���� | ||
2514 | +//-����/���ݵ��ж���driver/copilot����ʶ���ˡ������Զ�Ӧ���ĵ�����λ�ڳ�����/��ࣻ | ||
2515 | +//-��Ӧ�����˵��ж�����Ӧ�Υ��ʶ���ˡ������Լ����Ҽ�����Ŷ�>0.8�� | ||
2516 | +//-��Ӧ����ֻ�/����/��ȫ�����ж������ֻ�/����/��ȫ�����ڣ���ͨ�������ж����ڶ�Ӧ��(����/����)�� | ||
2517 | + | ||
2518 | +int process_vidresult_atlas(void * handle, int batch_size, va_result *result) | ||
2519 | +{ | ||
2520 | + for (int b = 0; b < batch_size; b++) | ||
2521 | + { | ||
2522 | + for(int c=0;c<result[b].count;c++) | ||
2523 | + { | ||
2524 | + vid_result cur_result = result[b].info[c].vehicle_illegal_det_res;//���� | ||
2525 | + | ||
2526 | + bool driverperson = false; //��ʶ�����Ƿ����� | ||
2527 | + bool copilotperson = false; //��ʶ�����Ƿ����� | ||
2528 | + bool driverbelt = false; //��ʶ�������Ƿ�������а�ȫ�� | ||
2529 | + bool copilotbelt = false; //��ʶ�������Ƿ�������а�ȫ�� | ||
2530 | + int pyc_driver = 0;//���ݵ�y���� | ||
2531 | + int pyc_copilot = 0;//���ݵ�y���� | ||
2532 | + | ||
2533 | + //������ | ||
2534 | + for(int p=0;p<result[b].info[c].vehicle_pendant_det_res.count;p++) | ||
2535 | + { | ||
2536 | + //�ж��Ƿ����� | ||
2537 | + //��Υ��ʶ���ˡ������Լ��������Ŷ�>0.8 | ||
2538 | + if( result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==0 && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence >0.8) | ||
2539 | + { | ||
2540 | + //���ݣ���Υ��ʶ���ˡ������������� | ||
2541 | + if(cur_result.driver.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1) | ||
2542 | + { | ||
2543 | + driverperson = true; | ||
2544 | + pyc_driver = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2545 | + } | ||
2546 | + //���ݣ���Υ��ʶ���ˡ��������Ǹ��� | ||
2547 | + if(cur_result.copilot.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2) | ||
2548 | + { | ||
2549 | + copilotperson = true; | ||
2550 | + pyc_copilot = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2551 | + } | ||
2552 | + } | ||
2553 | + } | ||
2554 | + | ||
2555 | + //������ | ||
2556 | + for(int p=0;p<result[b].info[c].vehicle_pendant_det_res.count;p++) | ||
2557 | + { | ||
2558 | + float phoneyc = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2559 | + float score = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence; | ||
2560 | + | ||
2561 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1)//�������� | ||
2562 | + { | ||
2563 | + /*//�����Լ��ֻ� | ||
2564 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) | ||
2565 | + { | ||
2566 | + //call | ||
2567 | + //��Υ���ж�Ϊ��绰,���������Ŷ�>0.85�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 | ||
2568 | + if((cur_result.driver.call.status==ILLEGAL && phoneyc <= pyc_driver + 10 && score>0.85) || (phoneyc <= pyc_driver + 10 && score > 0.9)) | ||
2569 | + { | ||
2570 | + //str_drivercall ="CALL"; | ||
2571 | + cur_result.driver.call.status = ILLEGAL;//CALL | ||
2572 | + } | ||
2573 | + else | ||
2574 | + { | ||
2575 | + cur_result.driver.call.status = lEGAL;//�Ϸ� | ||
2576 | + } | ||
2577 | + | ||
2578 | + //usephone | ||
2579 | + //��Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 | ||
2580 | + if((cur_result.driver.phone.status==ILLEGAL && phoneyc > pyc_driver + 10 && score>0.75) || (phoneyc > pyc_driver + 10 && score > 0.9)) | ||
2581 | + //if((cur_result.driver.call.status == ILLEGAL && phoneyc > pyc_driver + 10 && score>0.0) || (phoneyc > pyc_driver + 10 && score > 0.9)) | ||
2582 | + { | ||
2583 | + //str_driverphone ="USEPHONE"; | ||
2584 | + cur_result.driver.phone.status = ILLEGAL; | ||
2585 | + } | ||
2586 | + else | ||
2587 | + { | ||
2588 | + cur_result.driver.phone.status = lEGAL;//�Ϸ� | ||
2589 | + } | ||
2590 | + }*/ | ||
2591 | + | ||
2592 | + //belt | ||
2593 | + //�����Լ���ȫ���������ݲ� | ||
2594 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) | ||
2595 | + driverbelt = true; | ||
2596 | + | ||
2597 | + /*//smoke | ||
2598 | + //�����Լ����� ��Υ���ж�Υ����������ŶȽϸ� | ||
2599 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.driver.smoke.status==ILLEGAL || score>0.8)) | ||
2600 | + //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.driver.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) | ||
2601 | + { | ||
2602 | + //str_driversmoke ="SMOKE"; | ||
2603 | + cur_result.driver.smoke.status = ILLEGAL; | ||
2604 | + } | ||
2605 | + else | ||
2606 | + { | ||
2607 | + cur_result.driver.smoke.status = lEGAL;//�Ϸ� | ||
2608 | + }*/ | ||
2609 | + } | ||
2610 | + | ||
2611 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2)//�������� | ||
2612 | + { | ||
2613 | + //�����Լ��ֻ� | ||
2614 | + /*if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) | ||
2615 | + { | ||
2616 | + //�ж��ֻ��Ƿ��ڸ��ݲ� | ||
2617 | + //call | ||
2618 | + //ͬ���ݣ���Υ���ж�Ϊ��绰,���������Ŷ�>0.85;�������ֻ�λ�ÿ��ϡ���Υ���ж�Ϊ���������������ŶȽϸ� | ||
2619 | + if((cur_result.copilot.call.status==ILLEGAL && phoneyc <= pyc_copilot + 10 && score>0.85) || (phoneyc <= pyc_copilot + 10 && score > 0.9)) | ||
2620 | + { | ||
2621 | + //str_copilotcall ="CALL"; | ||
2622 | + cur_result.copilot.call.status = ILLEGAL; | ||
2623 | + } | ||
2624 | + else | ||
2625 | + { | ||
2626 | + cur_result.copilot.call.status = lEGAL;//�Ϸ� | ||
2627 | + } | ||
2628 | + | ||
2629 | + //usephone | ||
2630 | + //ͬ���ݣ���Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75;�������ֻ�λ�ÿ��¡���Υ���ж�Ϊ���������������ŶȽϸ� | ||
2631 | + if((cur_result.copilot.phone.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.75) || (phoneyc > pyc_copilot + 10 && score > 0.9)) | ||
2632 | + //if((cur_result.copilot.call.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.0) || (phoneyc > pyc_copilot + 10 && score > 0.9)) | ||
2633 | + { | ||
2634 | + //str_copilotphone ="USEPHONE"; | ||
2635 | + cur_result.copilot.phone.status = ILLEGAL; | ||
2636 | + } | ||
2637 | + else | ||
2638 | + { | ||
2639 | + cur_result.copilot.phone.status = lEGAL;//�Ϸ� | ||
2640 | + } | ||
2641 | + | ||
2642 | + | ||
2643 | + }*/ | ||
2644 | + | ||
2645 | + //belt | ||
2646 | + //�����Լ���ȫ�����ڸ��ݲ� | ||
2647 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) | ||
2648 | + copilotbelt = true; | ||
2649 | + | ||
2650 | + /*//smoke | ||
2651 | + //�����Լ����� ��Υ���ж�Υ����������ŶȽϸ� | ||
2652 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.copilot.smoke.status==ILLEGAL || score>0.8)) | ||
2653 | + //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.copilot.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) | ||
2654 | + { | ||
2655 | + //str_copilotsmoke ="SMOKE"; | ||
2656 | + cur_result.copilot.smoke.status = ILLEGAL; | ||
2657 | + } | ||
2658 | + else | ||
2659 | + { | ||
2660 | + cur_result.copilot.smoke.status = lEGAL;//�Ϸ� | ||
2661 | + }*/ | ||
2662 | + } | ||
2663 | + } | ||
2664 | + | ||
2665 | + | ||
2666 | + //����û��------------------- | ||
2667 | + if(!driverperson) | ||
2668 | + { | ||
2669 | + //str_driverperson ="NOBODY"; | ||
2670 | + cur_result.driver.person.status = NOBODY; | ||
2671 | + } | ||
2672 | + else | ||
2673 | + { | ||
2674 | + cur_result.driver.person.status = SOMEBODY; | ||
2675 | + } | ||
2676 | + | ||
2677 | + | ||
2678 | + if(!copilotperson) | ||
2679 | + { | ||
2680 | + //str_copilotperson ="NOBODY"; | ||
2681 | + cur_result.copilot.person.status = NOBODY; | ||
2682 | + } | ||
2683 | + else | ||
2684 | + { | ||
2685 | + cur_result.copilot.person.status = SOMEBODY; | ||
2686 | + } | ||
2687 | + | ||
2688 | + //��ȫ��--------------------------- | ||
2689 | + //�������ˡ�������δ����ȫ������Υ���ж�Ϊδϵ��ȫ�� | ||
2690 | + if(!driverbelt && driverperson && cur_result.driver.belt.status==ILLEGAL) | ||
2691 | + { | ||
2692 | + //str_driverbelt ="NOSAFETYBELT"; | ||
2693 | + cur_result.driver.belt.status = ILLEGAL; | ||
2694 | + } | ||
2695 | + else | ||
2696 | + { | ||
2697 | + cur_result.driver.belt.status = lEGAL; | ||
2698 | + } | ||
2699 | + | ||
2700 | + | ||
2701 | + //�������ˡ�������δ����ȫ������Υ���ж�Ϊδϵ��ȫ�� | ||
2702 | + if(!copilotbelt && copilotperson && cur_result.copilot.belt.status==ILLEGAL) | ||
2703 | + { | ||
2704 | + cur_result.copilot.belt.status = ILLEGAL; | ||
2705 | + } | ||
2706 | + else | ||
2707 | + { | ||
2708 | + cur_result.copilot.belt.status = lEGAL; | ||
2709 | + } | ||
2710 | + | ||
2711 | + } | ||
2712 | + | ||
2713 | + | ||
2714 | + } | ||
2715 | + | ||
2716 | + return SUCCESS; | ||
2717 | +} | ||
2718 | + | ||
2719 | +int process_vidresult(void * handle, int batch_size, va_result *result) | ||
2720 | +{ | ||
2721 | + for (int b = 0; b < batch_size; b++) | ||
2722 | + { | ||
2723 | + for(int c=0;c<result[b].count;c++) | ||
2724 | + { | ||
2725 | + vid_result cur_result = result[b].info[c].vehicle_illegal_det_res;//���� | ||
2726 | + | ||
2727 | + bool driverperson = false; //��ʶ�����Ƿ����� | ||
2728 | + bool copilotperson = false; //��ʶ�����Ƿ����� | ||
2729 | + bool driverbelt = false; //��ʶ�������Ƿ�������а�ȫ�� | ||
2730 | + bool copilotbelt = false; //��ʶ�������Ƿ�������а�ȫ�� | ||
2731 | + int pyc_driver = 0;//���ݵ�y���� | ||
2732 | + int pyc_copilot = 0;//���ݵ�y���� | ||
2733 | + | ||
2734 | + //������ | ||
2735 | + for(int p=0;p<result[b].info[c].vehicle_pendant_det_res.count;p++) | ||
2736 | + { | ||
2737 | + //�ж��Ƿ����� | ||
2738 | + //��Υ��ʶ���ˡ������Լ��������Ŷ�>0.8 | ||
2739 | + if( result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==0 && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence >0.8) | ||
2740 | + { | ||
2741 | + //���ݣ���Υ��ʶ���ˡ������������� | ||
2742 | + if(cur_result.driver.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1) | ||
2743 | + { | ||
2744 | + driverperson = true; | ||
2745 | + pyc_driver = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2746 | + } | ||
2747 | + //���ݣ���Υ��ʶ���ˡ��������Ǹ��� | ||
2748 | + if(cur_result.copilot.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2) | ||
2749 | + { | ||
2750 | + copilotperson = true; | ||
2751 | + pyc_copilot = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2752 | + } | ||
2753 | + } | ||
2754 | + } | ||
2755 | + | ||
2756 | + //������ | ||
2757 | + for(int p=0;p<result[b].info[c].vehicle_pendant_det_res.count;p++) | ||
2758 | + { | ||
2759 | + float phoneyc = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_ + result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_*0.5; | ||
2760 | + float score = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence; | ||
2761 | + | ||
2762 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1)//�������� | ||
2763 | + { | ||
2764 | + //�����Լ��ֻ� | ||
2765 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) | ||
2766 | + { | ||
2767 | + //call | ||
2768 | + //��Υ���ж�Ϊ��绰,���������Ŷ�>0.85�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 | ||
2769 | + if((cur_result.driver.call.status==ILLEGAL && phoneyc <= pyc_driver + 10 && score>0.85) || (phoneyc <= pyc_driver + 10 && score > 0.9)) | ||
2770 | + { | ||
2771 | + //str_drivercall ="CALL"; | ||
2772 | + cur_result.driver.call.status = ILLEGAL;//CALL | ||
2773 | + } | ||
2774 | + else | ||
2775 | + { | ||
2776 | + cur_result.driver.call.status = lEGAL;//�Ϸ� | ||
2777 | + } | ||
2778 | + | ||
2779 | + //usephone | ||
2780 | + //��Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 | ||
2781 | + if((cur_result.driver.phone.status==ILLEGAL && phoneyc > pyc_driver + 10 && score>0.75) || (phoneyc > pyc_driver + 10 && score > 0.9)) | ||
2782 | + //if((cur_result.driver.call.status == ILLEGAL && phoneyc > pyc_driver + 10 && score>0.0) || (phoneyc > pyc_driver + 10 && score > 0.9)) | ||
2783 | + { | ||
2784 | + //str_driverphone ="USEPHONE"; | ||
2785 | + cur_result.driver.phone.status = ILLEGAL; | ||
2786 | + } | ||
2787 | + else | ||
2788 | + { | ||
2789 | + cur_result.driver.phone.status = lEGAL;//�Ϸ� | ||
2790 | + } | ||
2791 | + } | ||
2792 | + | ||
2793 | + //belt | ||
2794 | + //�����Լ���ȫ���������ݲ� | ||
2795 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) | ||
2796 | + driverbelt = true; | ||
2797 | + | ||
2798 | + //smoke | ||
2799 | + //�����Լ����� ��Υ���ж�Υ����������ŶȽϸ� | ||
2800 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.driver.smoke.status==ILLEGAL || score>0.8)) | ||
2801 | + //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.driver.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) | ||
2802 | + { | ||
2803 | + //str_driversmoke ="SMOKE"; | ||
2804 | + cur_result.driver.smoke.status = ILLEGAL; | ||
2805 | + } | ||
2806 | + else | ||
2807 | + { | ||
2808 | + cur_result.driver.smoke.status = lEGAL;//�Ϸ� | ||
2809 | + } | ||
2810 | + } | ||
2811 | + | ||
2812 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2)//�������� | ||
2813 | + { | ||
2814 | + //�����Լ��ֻ� | ||
2815 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) | ||
2816 | + { | ||
2817 | + //�ж��ֻ��Ƿ��ڸ��ݲ� | ||
2818 | + //call | ||
2819 | + //ͬ���ݣ���Υ���ж�Ϊ��绰,���������Ŷ�>0.85;�������ֻ�λ�ÿ��ϡ���Υ���ж�Ϊ���������������ŶȽϸ� | ||
2820 | + if((cur_result.copilot.call.status==ILLEGAL && phoneyc <= pyc_copilot + 10 && score>0.85) || (phoneyc <= pyc_copilot + 10 && score > 0.9)) | ||
2821 | + { | ||
2822 | + //str_copilotcall ="CALL"; | ||
2823 | + cur_result.copilot.call.status = ILLEGAL; | ||
2824 | + } | ||
2825 | + else | ||
2826 | + { | ||
2827 | + cur_result.copilot.call.status = lEGAL;//�Ϸ� | ||
2828 | + } | ||
2829 | + | ||
2830 | + //usephone | ||
2831 | + //ͬ���ݣ���Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75;�������ֻ�λ�ÿ��¡���Υ���ж�Ϊ���������������ŶȽϸ� | ||
2832 | + if((cur_result.copilot.phone.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.75) || (phoneyc > pyc_copilot + 10 && score > 0.9)) | ||
2833 | + //if((cur_result.copilot.call.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.0) || (phoneyc > pyc_copilot + 10 && score > 0.9)) | ||
2834 | + { | ||
2835 | + //str_copilotphone ="USEPHONE"; | ||
2836 | + cur_result.copilot.phone.status = ILLEGAL; | ||
2837 | + } | ||
2838 | + else | ||
2839 | + { | ||
2840 | + cur_result.copilot.phone.status = lEGAL;//�Ϸ� | ||
2841 | + } | ||
2842 | + | ||
2843 | + | ||
2844 | + } | ||
2845 | + | ||
2846 | + //belt | ||
2847 | + //�����Լ���ȫ�����ڸ��ݲ� | ||
2848 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) | ||
2849 | + copilotbelt = true; | ||
2850 | + | ||
2851 | + //smoke | ||
2852 | + //�����Լ����� ��Υ���ж�Υ����������ŶȽϸ� | ||
2853 | + if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.copilot.smoke.status==ILLEGAL || score>0.8)) | ||
2854 | + //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.copilot.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) | ||
2855 | + { | ||
2856 | + //str_copilotsmoke ="SMOKE"; | ||
2857 | + cur_result.copilot.smoke.status = ILLEGAL; | ||
2858 | + } | ||
2859 | + else | ||
2860 | + { | ||
2861 | + cur_result.copilot.smoke.status = lEGAL;//�Ϸ� | ||
2862 | + } | ||
2863 | + } | ||
2864 | + } | ||
2865 | + | ||
2866 | + | ||
2867 | + //����û��------------------- | ||
2868 | + if(!driverperson) | ||
2869 | + { | ||
2870 | + //str_driverperson ="NOBODY"; | ||
2871 | + cur_result.driver.person.status = NOBODY; | ||
2872 | + } | ||
2873 | + else | ||
2874 | + { | ||
2875 | + cur_result.driver.person.status = SOMEBODY; | ||
2876 | + } | ||
2877 | + | ||
2878 | + | ||
2879 | + if(!copilotperson) | ||
2880 | + { | ||
2881 | + //str_copilotperson ="NOBODY"; | ||
2882 | + cur_result.copilot.person.status = NOBODY; | ||
2883 | + } | ||
2884 | + else | ||
2885 | + { | ||
2886 | + cur_result.copilot.person.status = SOMEBODY; | ||
2887 | + } | ||
2888 | + | ||
2889 | + //��ȫ��--------------------------- | ||
2890 | + //�������ˡ�������δ����ȫ������Υ���ж�Ϊδϵ��ȫ�� | ||
2891 | + if(!driverbelt && driverperson && cur_result.driver.belt.status==ILLEGAL) | ||
2892 | + { | ||
2893 | + //str_driverbelt ="NOSAFETYBELT"; | ||
2894 | + cur_result.driver.belt.status = ILLEGAL; | ||
2895 | + } | ||
2896 | + else | ||
2897 | + { | ||
2898 | + cur_result.driver.belt.status = lEGAL; | ||
2899 | + } | ||
2900 | + | ||
2901 | + | ||
2902 | + //�������ˡ�������δ����ȫ������Υ���ж�Ϊδϵ��ȫ�� | ||
2903 | + if(!copilotbelt && copilotperson && cur_result.copilot.belt.status==ILLEGAL) | ||
2904 | + { | ||
2905 | + cur_result.copilot.belt.status = ILLEGAL; | ||
2906 | + } | ||
2907 | + else | ||
2908 | + { | ||
2909 | + cur_result.copilot.belt.status = lEGAL; | ||
2910 | + } | ||
2911 | + | ||
2912 | + } | ||
2913 | + | ||
2914 | + | ||
2915 | + } | ||
2916 | + | ||
2917 | + return SUCCESS; | ||
2918 | +} | ||
2919 | + | ||
2920 | +//�ж����������ݻ��Ǹ��ݣ�0-��ʼֵ(���������ݸ���)��1-���ݣ�2-���� | ||
2921 | +int rect_driver_copilot(sy_rect vpd_rect, sy_rect body_rect) | ||
2922 | +{ | ||
2923 | + int driver_copilot_info = 0; | ||
2924 | + | ||
2925 | + int vpd_middle_x = vpd_rect.left_+vpd_rect.width_/2; | ||
2926 | + int body_middle_x = body_rect.left_+body_rect.width_/2; | ||
2927 | + | ||
2928 | + if(vpd_middle_x < body_middle_x) | ||
2929 | + driver_copilot_info = 2; | ||
2930 | + else if(vpd_middle_x > body_middle_x) | ||
2931 | + driver_copilot_info = 1; | ||
2932 | + | ||
2933 | + return driver_copilot_info; | ||
2934 | +} | ||
2935 | + | ||
2936 | + | ||
2937 | + | ||
2938 | + | ||
2939 | + | ||
2940 | +float IOU(sy_rect rect1, sy_rect rect2) | ||
2941 | +{ | ||
2942 | + float xx1,yy1,xx2,yy2,w,h,wh,o; | ||
2943 | + xx1 = max(rect1.left_, rect2.left_); | ||
2944 | + yy1 = max(rect1.top_, rect2.top_); | ||
2945 | + xx2 = min(rect1.left_+ rect1.width_ , rect2.left_+ rect2.width_ ); | ||
2946 | + yy2 = min(rect1.top_+ rect1.height_ , rect2.top_+ rect2.height_ ); | ||
2947 | + | ||
2948 | + w = max (float(0),(xx2-xx1)); | ||
2949 | + h = max (float(0),(yy2-yy1)); | ||
2950 | + wh =w*h; | ||
2951 | + | ||
2952 | + o = wh / (rect1.width_ *rect1.height_ + rect2.width_ *rect2.height_ -wh ); | ||
2953 | + return o; | ||
2954 | +} | ||
2955 | + | ||
2956 | +//�ж�rect1�Ƿ���rect2���棬1���ڣ�0 �Dz��� | ||
2957 | +int in_rect(sy_rect rect1, sy_rect rect2) | ||
2958 | +{ | ||
2959 | + if(rect1.left_ - rect2.left_ >=-10 | ||
2960 | + && rect1.top_ - rect2.top_ >=-10 | ||
2961 | + && rect2.left_ + rect2.width_ - rect1.left_ - rect1.width_ >=-10 | ||
2962 | + && rect2.top_ + rect2.height_ - rect1.top_ - rect1.height_ >=0) | ||
2963 | + return 1; | ||
2964 | + else | ||
2965 | + return 0; | ||
2966 | + | ||
2967 | +} | ||
2968 | + | ||
2969 | +//�����Խ������,�ⲿ�����ڴ� | ||
2970 | +void process_vpdresult(sy_rect body_rect, vpd_result * src, vpd_result * dest) | ||
2971 | +{ | ||
2972 | + //���˵����������Ŀ�꣬���Ψһ�ij�ͷ��β�����Ψһ�ij���,���Ψһ�ij�logo | ||
2973 | + float max_head_rear_score=0; | ||
2974 | + int head_rear_idx = -1; | ||
2975 | + float max_win_score=0; | ||
2976 | + int win_idx = -1; | ||
2977 | + float max_logo_score=0; | ||
2978 | + int logo_idx = -1; | ||
2979 | + | ||
2980 | + int idx=0; | ||
2981 | + int count = src[0].count; | ||
2982 | + for(int c=0;c<count;c++) | ||
2983 | + { | ||
2984 | + float iou = IOU(src[0].vpd_res[c].rect, body_rect); | ||
2985 | + | ||
2986 | + int index = src[0].vpd_res[c].index; | ||
2987 | + float score = src[0].vpd_res[c].confidence; | ||
2988 | + if(index ==0 || index == 1)//��ͷ��β | ||
2989 | + { | ||
2990 | + //float iou = IOU(src[0].vpd_res[c].rect, body_rect); | ||
2991 | + if(iou > 0.3 && score > max_head_rear_score) | ||
2992 | + { | ||
2993 | + if(head_rear_idx==-1)//�½� | ||
2994 | + { | ||
2995 | + dest[0].vpd_res[idx] = src[0].vpd_res[c]; | ||
2996 | + head_rear_idx = idx; | ||
2997 | + max_head_rear_score = score; | ||
2998 | + | ||
2999 | + idx++; | ||
3000 | + } | ||
3001 | + else//���� | ||
3002 | + { | ||
3003 | + dest[0].vpd_res[head_rear_idx] = src[0].vpd_res[c]; | ||
3004 | + max_head_rear_score = score; | ||
3005 | + } | ||
3006 | + } | ||
3007 | + } | ||
3008 | + else if(index ==2 )//���� | ||
3009 | + { | ||
3010 | + int label = in_rect( src[0].vpd_res[c].rect, body_rect); | ||
3011 | + if(iou > 0 && label && score > max_win_score) | ||
3012 | + { | ||
3013 | + if(win_idx==-1)//�½� | ||
3014 | + { | ||
3015 | + dest[0].vpd_res[idx] = src[0].vpd_res[c]; | ||
3016 | + win_idx = idx; | ||
3017 | + max_win_score = score; | ||
3018 | + | ||
3019 | + idx++; | ||
3020 | + } | ||
3021 | + else//���� | ||
3022 | + { | ||
3023 | + dest[0].vpd_res[win_idx] = src[0].vpd_res[c]; | ||
3024 | + max_win_score = score; | ||
3025 | + } | ||
3026 | + } | ||
3027 | + } | ||
3028 | + else if(index ==24 )//��logo | ||
3029 | + { | ||
3030 | + int label = in_rect( src[0].vpd_res[c].rect, body_rect); | ||
3031 | + if(iou > 0 && label && score > max_logo_score) | ||
3032 | + { | ||
3033 | + if(logo_idx==-1)//�½� | ||
3034 | + { | ||
3035 | + dest[0].vpd_res[idx] = src[0].vpd_res[c]; | ||
3036 | + logo_idx = idx; | ||
3037 | + max_logo_score = score; | ||
3038 | + | ||
3039 | + idx++; | ||
3040 | + } | ||
3041 | + else//���� | ||
3042 | + { | ||
3043 | + dest[0].vpd_res[logo_idx] = src[0].vpd_res[c]; | ||
3044 | + max_logo_score = score; | ||
3045 | + } | ||
3046 | + } | ||
3047 | + } | ||
3048 | + else//��������ȫ������ | ||
3049 | + { | ||
3050 | + if(iou > 0) | ||
3051 | + { | ||
3052 | + dest[0].vpd_res[idx] = src[0].vpd_res[c]; | ||
3053 | + idx++; | ||
3054 | + } | ||
3055 | + } | ||
3056 | + | ||
3057 | + | ||
3058 | + | ||
3059 | + | ||
3060 | + } | ||
3061 | + dest[0].count =idx; | ||
3062 | + | ||
3063 | +} | ||
3064 | + | ||
3065 | + | ||
3066 | + | ||
3067 | +sy_rect rect_extend(sy_rect obj_rect,int img_w,int img_h,float scale) | ||
3068 | +{ | ||
3069 | + sy_rect obj_rect_extend; | ||
3070 | + int right = obj_rect.left_ + obj_rect.width_; | ||
3071 | + int bottom = obj_rect.top_ + obj_rect.height_; | ||
3072 | + | ||
3073 | + int offset = obj_rect.width_ * scale; | ||
3074 | + | ||
3075 | + obj_rect_extend.left_ = obj_rect.left_ - offset; | ||
3076 | + if(obj_rect_extend.left_ < 0) | ||
3077 | + obj_rect_extend.left_ = 0; | ||
3078 | + | ||
3079 | + obj_rect_extend.top_ = obj_rect.top_ - offset; | ||
3080 | + if(obj_rect_extend.top_ < 0) | ||
3081 | + obj_rect_extend.top_ = 0; | ||
3082 | + | ||
3083 | + right += offset; | ||
3084 | + if(right > img_w) | ||
3085 | + right = img_w; | ||
3086 | + | ||
3087 | + bottom += offset; | ||
3088 | + if(bottom > img_h) | ||
3089 | + bottom = img_h; | ||
3090 | + | ||
3091 | + obj_rect_extend.width_ = right - obj_rect_extend.left_; | ||
3092 | + obj_rect_extend.height_ = bottom - obj_rect_extend.top_; | ||
3093 | + | ||
3094 | + return obj_rect_extend; | ||
3095 | +} | ||
3096 | + | ||
3097 | + | ||
3098 | + | ||
3099 | +//======================= vpt ����nms����============================// | ||
3100 | + | ||
3101 | +bool CompareBBox(const vpt_obj_result & a, const vpt_obj_result & b) | ||
3102 | +{ | ||
3103 | + return a.obj_score > b.obj_score; | ||
3104 | +} | ||
3105 | + | ||
3106 | +bool CompareBBoxBest(const vpt_info_midd_temp & a, const vpt_info_midd_temp & b) | ||
3107 | +{ | ||
3108 | + return a.dis < b.dis; | ||
3109 | +} | ||
3110 | + | ||
3111 | +std::vector<vpt_obj_result> NonMaximumSuppression(std::vector<vpt_obj_result>& bboxes, const float& thresh, const char& methodType) | ||
3112 | +{//WH:�Ǽ���ֵ����NMS���ϲ����ڡ�thresh�ǽ�����IOU����ֵ��methodType�Ǽ��㽻���ȵ����ַ�ʽ��P-Net��R-Net��u��O-Net�Ƿ�ʽm | ||
3113 | + std::vector<vpt_obj_result> bboxes_nms; | ||
3114 | + std::sort(bboxes.begin(), bboxes.end(), CompareBBox); | ||
3115 | + int32_t select_idx = 0; | ||
3116 | + int32_t num_bbox = static_cast<int32_t>(bboxes.size()); | ||
3117 | + std::vector<int32_t> mask_merged(num_bbox, 0); | ||
3118 | + bool all_merged = false; | ||
3119 | + while (!all_merged) | ||
3120 | + { | ||
3121 | + while (select_idx < num_bbox && mask_merged[select_idx] == 1) | ||
3122 | + select_idx++; | ||
3123 | + if (select_idx == num_bbox) | ||
3124 | + { | ||
3125 | + all_merged = true; | ||
3126 | + continue; | ||
3127 | + } | ||
3128 | + bboxes_nms.push_back(bboxes[select_idx]); | ||
3129 | + mask_merged[select_idx] = 1; | ||
3130 | + sy_rect select_bbox = bboxes[select_idx].obj_rect; | ||
3131 | + float area1 = static_cast<float>(select_bbox.width_ * select_bbox.height_); | ||
3132 | + float x1 = static_cast<float>(select_bbox.left_); | ||
3133 | + float y1 = static_cast<float>(select_bbox.top_); | ||
3134 | + float x2 = static_cast<float>(select_bbox.left_ + select_bbox.width_ ); | ||
3135 | + float y2 = static_cast<float>(select_bbox.top_ + select_bbox.height_); | ||
3136 | + select_idx++; | ||
3137 | + for (int32_t i = select_idx; i < num_bbox; i++) | ||
3138 | + { | ||
3139 | + if (mask_merged[i] == 1) | ||
3140 | + continue; | ||
3141 | + sy_rect& bbox_i = bboxes[i].obj_rect; | ||
3142 | + float x = std::max<float>(x1, static_cast<float>(bbox_i.left_)); | ||
3143 | + float y = std::max<float>(y1, static_cast<float>(bbox_i.top_)); | ||
3144 | + float w = std::min<float>(x2, static_cast<float>(bbox_i.left_ + bbox_i.width_)) - x; | ||
3145 | + float h = std::min<float>(y2, static_cast<float>(bbox_i.top_ + bbox_i.height_ )) - y; | ||
3146 | + if (w <= 0 || h <= 0) | ||
3147 | + continue; | ||
3148 | + float area2 = static_cast<float>(bbox_i.width_ * bbox_i.height_); | ||
3149 | + float area_intersect = w * h; | ||
3150 | + switch (methodType) { | ||
3151 | + case 'u': | ||
3152 | + if (static_cast<float>(area_intersect) / (area1 + area2 - area_intersect) > thresh) | ||
3153 | + mask_merged[i] = 1; | ||
3154 | + break; | ||
3155 | + case 'm': | ||
3156 | + if (static_cast<float>(area_intersect) / std::min(area1 , area2) > thresh) | ||
3157 | + mask_merged[i] = 1; | ||
3158 | + break; | ||
3159 | + default: | ||
3160 | + break; | ||
3161 | + } | ||
3162 | + } | ||
3163 | + } | ||
3164 | + mask_merged.clear(); | ||
3165 | + return bboxes_nms; | ||
3166 | +} | ||
3167 | + | ||
3168 | + | ||
3169 | +int get_dis(sy_rect rect,int best_center_x,int best_center_y,int img_w,int img_h) | ||
3170 | +{ | ||
3171 | + int dis_a =0; | ||
3172 | + | ||
3173 | + int a_center_x = rect.left_ + rect.width_/2; | ||
3174 | + int a_center_y = rect.top_ + rect.height_/2; | ||
3175 | + | ||
3176 | + dis_a = (a_center_x - best_center_x)*(a_center_x - best_center_x)*0.5 +(a_center_y - best_center_y) *(a_center_y - best_center_y); //x����ľ���*Ȩֵ0.5 | ||
3177 | + if(a_center_y < best_center_y)//��������ĵ����ͷ��*1.2��Ȩֵ | ||
3178 | + dis_a *= 1.2; | ||
3179 | + | ||
3180 | + //����,*1.2��Ȩֵ | ||
3181 | + if(rect.left_<5 || img_w -(rect.left_+rect.width_)<10 || img_h -(rect.top_+rect.height_)<5) | ||
3182 | + dis_a *= 1.2; | ||
3183 | + | ||
3184 | + return dis_a ; | ||
3185 | +} | ||
3186 | + | ||
3187 | +//�˳���result���� | ||
3188 | +//1.����persion��bike�������ij��������nms | ||
3189 | +//2.�����汾��ֻ���topn | ||
3190 | +int process_vptresult(sy_img *imgdata, int batch_size, vpt_result * vpt_result_) | ||
3191 | +{ | ||
3192 | + int res =-1; | ||
3193 | + | ||
3194 | + //1.����person��bike�������ij�����nms | ||
3195 | + for (int b = 0; b < batch_size; b++) | ||
3196 | + { | ||
3197 | + std::vector<vpt_obj_result> vpt_info_pb;//personhe bike | ||
3198 | + vpt_info_pb.clear(); | ||
3199 | + | ||
3200 | + std::vector<vpt_obj_result> vpt_info_temp;//������� | ||
3201 | + vpt_info_temp.clear(); | ||
3202 | + | ||
3203 | + int count = vpt_result_[b].obj_count_; | ||
3204 | + for (int c = 0; c < count; c++) | ||
3205 | + { | ||
3206 | + int class_idx = vpt_result_[b].obj_results_[c].obj_index; | ||
3207 | + if(class_idx == 0 || class_idx ==1 )//person bike����nms | ||
3208 | + { | ||
3209 | + vpt_info_pb.push_back(vpt_result_[b].obj_results_[c]); | ||
3210 | + } | ||
3211 | + else | ||
3212 | + { | ||
3213 | + vpt_info_temp.push_back(vpt_result_[b].obj_results_[c]); | ||
3214 | + } | ||
3215 | + } | ||
3216 | + | ||
3217 | + // vpt_info_temp �������nms���� | ||
3218 | + //�Ǽ���ֵ���ƺϲ���ѡ�� | ||
3219 | + std::vector<vpt_obj_result> bboxes_nms = NonMaximumSuppression(vpt_info_temp, 0.7, 'u'); | ||
3220 | + | ||
3221 | + //output | ||
3222 | + int res_count = 0; | ||
3223 | + for (int i = 0; i < vpt_info_pb.size(); i++)//personhe bike | ||
3224 | + { | ||
3225 | + vpt_result_[b].obj_results_[res_count]= vpt_info_pb[i]; | ||
3226 | + res_count++; | ||
3227 | + } | ||
3228 | + for (int i = 0; i < bboxes_nms.size(); i++)//������� | ||
3229 | + { | ||
3230 | + vpt_result_[b].obj_results_[res_count]= bboxes_nms[i]; | ||
3231 | + res_count++; | ||
3232 | + } | ||
3233 | + | ||
3234 | + bboxes_nms.clear(); | ||
3235 | + | ||
3236 | + vpt_result_[b].obj_count_= res_count; | ||
3237 | + } | ||
3238 | + | ||
3239 | + | ||
3240 | + //2.�����汾��ֻ��topn���������Է��������Ե�Ŀ��������topnʱ����vpt�Ľ�����Ӵ��µ�˳������//WH20220308 | ||
3241 | + if(VERSION_WUXI) | ||
3242 | + { | ||
3243 | + for (int b = 0; b < batch_size; b++) | ||
3244 | + { | ||
3245 | + int count = vpt_result_[b].obj_count_; | ||
3246 | + if(count > VPT_TOPN) | ||
3247 | + { | ||
3248 | + int img_w = imgdata[b].w_; | ||
3249 | + int img_h = imgdata[b].h_; | ||
3250 | + int best_center_x = img_w/2;//��ͼ�����Ŀ������ĵ� | ||
3251 | + int best_center_y = img_h*3/4; | ||
3252 | + | ||
3253 | + std::vector<vpt_info_midd_temp> bboxes_topn; | ||
3254 | + | ||
3255 | + for(int c =0;c<count; c++) | ||
3256 | + { | ||
3257 | + vpt_info_midd_temp vpt_info_midd_temp_; | ||
3258 | + | ||
3259 | + vpt_info_midd_temp_.obj_index = vpt_result_[b].obj_results_[c].obj_index; | ||
3260 | + vpt_info_midd_temp_.obj_score = vpt_result_[b].obj_results_[c].obj_score; | ||
3261 | + vpt_info_midd_temp_.obj_rect = vpt_result_[b].obj_results_[c].obj_rect; | ||
3262 | + vpt_info_midd_temp_.dis = get_dis(vpt_info_midd_temp_.obj_rect,best_center_x,best_center_y ,img_w, img_h); | ||
3263 | + bboxes_topn.push_back(vpt_info_midd_temp_); | ||
3264 | + } | ||
3265 | + | ||
3266 | + std::sort(bboxes_topn.begin(), bboxes_topn.end(), CompareBBoxBest); | ||
3267 | + | ||
3268 | + //��� | ||
3269 | + int res_count=0; | ||
3270 | + for (int i = 0; i < bboxes_topn.size(); i++) | ||
3271 | + { | ||
3272 | + vpt_result_[b].obj_results_[res_count].obj_index= bboxes_topn[i].obj_index; | ||
3273 | + vpt_result_[b].obj_results_[res_count].obj_score= bboxes_topn[i].obj_score; | ||
3274 | + vpt_result_[b].obj_results_[res_count].obj_rect= bboxes_topn[i].obj_rect; | ||
3275 | + res_count++; | ||
3276 | + } | ||
3277 | + | ||
3278 | + bboxes_topn.clear(); | ||
3279 | + } | ||
3280 | + } | ||
3281 | + } | ||
3282 | + | ||
3283 | + return res; | ||
3284 | +} | ||
3285 | + | ||
3286 | + | ||
3287 | + | ||
3288 | + | ||
3289 | + | ||
3290 | + | ||
3291 | + | ||
3292 | + | ||
3293 | +//����ʶ���복logo��Ʒ��ӳ�䣨����Ʒ�Ʋ���Ӧ����Ҫӳ�䣩 | ||
3294 | +int logo_strcmp(char * logo,char * brand) | ||
3295 | +{ | ||
3296 | + int res =-1; | ||
3297 | + res = strcmp(logo,brand); | ||
3298 | + | ||
3299 | + if(res !=0)//ûƥ���ϣ����Ƿ�Ҫ��ӳ�� | ||
3300 | + { | ||
3301 | + for(int i=0;i<vr_brand_array_len;i++)//��������Գ�Ʒ��У���� | ||
3302 | + { | ||
3303 | + if(strcmp(logo,vlogo_brand_array[i])==0 && strcmp(brand,vr_brand_array[i])==0)//�ҵ�ƥ��� | ||
3304 | + { | ||
3305 | + res=0; | ||
3306 | + break; | ||
3307 | + } | ||
3308 | + } | ||
3309 | + } | ||
3310 | + return res; | ||
3311 | +} | ||
3312 | + | ||
3313 | +//��logo��Ʒ��ӳ�䵽��������ij�Ʒ�ƣ����logo�ڶ�Ӧ������Ӧ��������Ʒ�ƣ����logo���ڶ�Ӧ�������logo�������� | ||
3314 | +int logo_check_wuxi(char * logo) | ||
3315 | +{ | ||
3316 | + int index =-1; | ||
3317 | + for(int i=0;i<vlogo_brand_array_wuxi_len;i++) | ||
3318 | + { | ||
3319 | + if(strcmp(logo,vlogo_brand_array_wuxi[i])==0) | ||
3320 | + { | ||
3321 | + index = i; | ||
3322 | + break; | ||
3323 | + } | ||
3324 | + } | ||
3325 | + | ||
3326 | + return index; | ||
3327 | +} | ||
3328 | + | ||
3329 | + | ||
3330 | + | ||
3331 | +//�����汾�ij���ʶ��ʶ�� | ||
3332 | +int vr_supplement_wuxi(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result) | ||
3333 | +{ | ||
3334 | + va_handle *tools=(va_handle *)handle; | ||
3335 | + int res_status =-1; | ||
3336 | + | ||
3337 | + LOG_DEBUG("body4-3.vr 15cls WUXI----- "); | ||
3338 | + | ||
3339 | + int vr_logo_15cls_batch_size = car_body_num;// | ||
3340 | + | ||
3341 | + //�ó�logo������Ʒ�ƣ�logo�����Ӧ��������ij�Ʒ�� | ||
3342 | + if(VR_WUXI_LOGO) | ||
3343 | + { | ||
3344 | + LOG_DEBUG("body4-3.vr logo WUXI----- "); | ||
3345 | + //��ʼ������ṹ��vr_logo_result_ | ||
3346 | + vlogos_result * vr_logo_result_ = new vlogos_result[vr_logo_15cls_batch_size]; | ||
3347 | + memset(vr_logo_result_,0,sizeof(vlogos_result)*vr_logo_15cls_batch_size); | ||
3348 | + vr_logo_result_->count = 0; | ||
3349 | + | ||
3350 | + res_status = vlogodr_batch(tools->vr_logo_dr_handle, body_img_data, vr_logo_15cls_batch_size, vr_logo_result_); | ||
3351 | + if (res_status != SUCCESS) | ||
3352 | + { | ||
3353 | + LOG_ERROR("sy_va_va_batch(error): vlogodr_batch failed. (ret = {})", res_status); | ||
3354 | + return res_status; | ||
3355 | + } | ||
3356 | + | ||
3357 | + | ||
3358 | + //output | ||
3359 | + int car_body_idx=0; | ||
3360 | + for(int b=0;b<batch_size;b++) | ||
3361 | + { | ||
3362 | + for(int c=0;c<result[b].count;c++) | ||
3363 | + { | ||
3364 | + if(result[b].info[c].type == 1 )//��β�ر�������Ϊ�õ����п⣬��Ҫ��ӳ�䵽�����⣬ֻ��Ҫ������Ʒ�� | ||
3365 | + { | ||
3366 | + if(result[b].info[c].vehicle_recg_res.name_score >0) | ||
3367 | + { | ||
3368 | + int check_index=-1; | ||
3369 | + check_index = logo_check_wuxi(result[b].info[c].vehicle_recg_res.vehicle_brand); | ||
3370 | + if(check_index!=-1)//��ӳ�䵽�����ӳ�䵽������Ʒ�� | ||
3371 | + { | ||
3372 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_brand_array_wuxi[check_index],sizeof(char)*260); | ||
3373 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3374 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3375 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3376 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3377 | + //result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3378 | + //result[b].info[c].vehicle_recg_res.index = -1; | ||
3379 | + } | ||
3380 | + else//����ӳ�䵽���ÿ� | ||
3381 | + { | ||
3382 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3383 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3384 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3385 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3386 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3387 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3388 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3389 | + } | ||
3390 | + } | ||
3391 | + } | ||
3392 | + | ||
3393 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ | ||
3394 | + { | ||
3395 | + int logo_count = vr_logo_result_[car_body_idx].count; | ||
3396 | + if(logo_count>0) | ||
3397 | + { | ||
3398 | + int logo_index= vr_logo_result_[car_body_idx].vehicle_logo_infos[0].logo_brand_index; | ||
3399 | + float logo_recg_score = vr_logo_result_[car_body_idx].vehicle_logo_infos[0].recg_score; | ||
3400 | + char *logo_brand = vr_logo_result_[car_body_idx].vehicle_logo_infos[0].logo_brand;//����Ʒ�� | ||
3401 | + | ||
3402 | + if(logo_recg_score>0.8) | ||
3403 | + { | ||
3404 | + int logo_check_index=-1; | ||
3405 | + logo_check_index = logo_check_wuxi(logo_brand); | ||
3406 | + | ||
3407 | + if(logo_check_index!=-1 && strcmp(vr_brand_array_wuxi[logo_check_index],result[b].info[c].vehicle_recg_res.vehicle_brand)!=0) | ||
3408 | + { | ||
3409 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_brand_array_wuxi[logo_check_index],sizeof(char)*260); | ||
3410 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3411 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3412 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3413 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3414 | + result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; | ||
3415 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3416 | + } | ||
3417 | + else if(logo_check_index==-1) | ||
3418 | + { | ||
3419 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3420 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3421 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3422 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3423 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3424 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3425 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3426 | + } | ||
3427 | + } | ||
3428 | + } | ||
3429 | + | ||
3430 | + car_body_idx++; | ||
3431 | + } | ||
3432 | + } | ||
3433 | + } | ||
3434 | + | ||
3435 | + | ||
3436 | + //release vr_logo_result_ | ||
3437 | + if (vr_logo_result_ != NULL) | ||
3438 | + { | ||
3439 | + delete[] vr_logo_result_; | ||
3440 | + vr_logo_result_ = NULL; | ||
3441 | + } | ||
3442 | + }//end if(VR_WUXI_LOGO) | ||
3443 | + | ||
3444 | + | ||
3445 | + //��ʼ������ṹ��vr_15cls_result_ | ||
3446 | + vr_vehicle_type_15cls_result * vr_15cls_result_ = new vr_vehicle_type_15cls_result[vr_logo_15cls_batch_size]; | ||
3447 | + memset(vr_15cls_result_,0,sizeof(vr_vehicle_type_15cls_result)*vr_logo_15cls_batch_size); | ||
3448 | + | ||
3449 | + LOG_DEBUG("vr_vehicle_type_15cls_batch"); | ||
3450 | + res_status=vr_vehicle_type_15cls_batch(tools->vr_vr15cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_15cls_result_); | ||
3451 | + if (res_status != SUCCESS) | ||
3452 | + { | ||
3453 | + LOG_ERROR("sy_va_va_batch(error): vr_vehicle_type_15cls_batch failed. (ret = {})", res_status); | ||
3454 | + return res_status; | ||
3455 | + } | ||
3456 | + | ||
3457 | + //output | ||
3458 | + int car_idx=0; | ||
3459 | + for(int b=0;b<batch_size;b++) | ||
3460 | + { | ||
3461 | + for(int c=0;c<result[b].count;c++) | ||
3462 | + { | ||
3463 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ | ||
3464 | + { | ||
3465 | + if(0) | ||
3466 | + { | ||
3467 | + char *vehicle_brand=result[b].info[c].vehicle_recg_res.vehicle_brand;//����ʶ��Ʒ�� | ||
3468 | + std::string str_vehicle_subbrand = result[b].info[c].vehicle_recg_res.vehicle_subbrand; | ||
3469 | + std::string str_vehicle_issue_year = result[b].info[c].vehicle_recg_res.vehicle_issue_year; | ||
3470 | + std::string str_vehicle_subbrand_issue_year; | ||
3471 | + if(str_vehicle_issue_year !="") | ||
3472 | + str_vehicle_subbrand_issue_year = str_vehicle_subbrand + "-" + str_vehicle_issue_year; | ||
3473 | + else | ||
3474 | + str_vehicle_subbrand_issue_year = str_vehicle_subbrand; | ||
3475 | + char *vehicle_subbrand_issue_year = (char *)str_vehicle_subbrand_issue_year.c_str();//����ʶ����Ʒ����� | ||
3476 | + float name_score=result[b].info[c].vehicle_recg_res.name_score; //����ʶ�����Ŷ� | ||
3477 | + //float name_score=0.7; | ||
3478 | + std::string str_vehicle_brand = vehicle_brand; | ||
3479 | + std::string str_vr_brand_subbrand_issue_year; | ||
3480 | + if(str_vehicle_subbrand_issue_year !="") | ||
3481 | + str_vr_brand_subbrand_issue_year = str_vehicle_brand + "-"+ str_vehicle_subbrand_issue_year; | ||
3482 | + else | ||
3483 | + str_vr_brand_subbrand_issue_year = str_vehicle_brand; | ||
3484 | + | ||
3485 | + } | ||
3486 | + | ||
3487 | + float name_score=result[b].info[c].vehicle_recg_res.name_score; //����ʶ�����Ŷ� | ||
3488 | + | ||
3489 | + //15cls output | ||
3490 | + float vr_15cls_score = vr_15cls_result_[car_idx].score; | ||
3491 | + if( vr_15cls_score > VR_15CLS_THRE)//wh20200917������db����û�г��ͷ������Ϣ | ||
3492 | + { | ||
3493 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); | ||
3494 | + if(result[b].info[c].vehicle_recg_res.name_score>0) | ||
3495 | + result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; | ||
3496 | + else | ||
3497 | + result[b].info[c].vehicle_recg_res.name_score = vr_15cls_score; | ||
3498 | + } | ||
3499 | + | ||
3500 | + car_idx++; | ||
3501 | + | ||
3502 | + } | ||
3503 | + } | ||
3504 | + } | ||
3505 | + | ||
3506 | + | ||
3507 | + //delete | ||
3508 | + if (vr_15cls_result_ != NULL) | ||
3509 | + { | ||
3510 | + delete[] vr_15cls_result_; | ||
3511 | + vr_15cls_result_ = NULL; | ||
3512 | + } | ||
3513 | + LOG_DEBUG("end body4-3.vr 15cls WUXI----- "); | ||
3514 | + | ||
3515 | + return SUCCESS; | ||
3516 | +} | ||
3517 | + | ||
3518 | + | ||
3519 | + | ||
3520 | + | ||
3521 | +//���п�汾�ij���ʶ��ʶ�� | ||
3522 | +int vr_supplement(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result) | ||
3523 | +{ | ||
3524 | + va_handle *tools=(va_handle *)handle; | ||
3525 | + int res_status =-1; | ||
3526 | + | ||
3527 | + LOG_DEBUG("body4-3.vr logo 15cls----- "); | ||
3528 | + | ||
3529 | + int vr_logo_15cls_batch_size = car_body_num;// | ||
3530 | + | ||
3531 | + //��ʼ������ṹ��vr_logo_result_ | ||
3532 | + vlogos_result * vr_logo_result_ = new vlogos_result[vr_logo_15cls_batch_size]; | ||
3533 | + memset(vr_logo_result_,0,sizeof(vlogos_result)*vr_logo_15cls_batch_size); | ||
3534 | + vr_logo_result_->count = 0; | ||
3535 | + //��ʼ������ṹ��vr_15cls_result_ | ||
3536 | + vr_vehicle_type_15cls_result * vr_15cls_result_ = new vr_vehicle_type_15cls_result[vr_logo_15cls_batch_size]; | ||
3537 | + memset(vr_15cls_result_,0,sizeof(vr_vehicle_type_15cls_result)*vr_logo_15cls_batch_size); | ||
3538 | + //��ʼ������ṹ�� vr_3885cls_result_ | ||
3539 | + vr_vehicle_type_3885cls_result * vr_3885cls_result_ = new vr_vehicle_type_3885cls_result[vr_logo_15cls_batch_size]; | ||
3540 | + memset(vr_3885cls_result_,0,sizeof(vr_vehicle_type_3885cls_result)*vr_logo_15cls_batch_size); | ||
3541 | + | ||
3542 | + //process | ||
3543 | + LOG_DEBUG("vlogodr_batch"); | ||
3544 | + res_status = vlogodr_batch(tools->vr_logo_dr_handle, body_img_data, vr_logo_15cls_batch_size, vr_logo_result_); | ||
3545 | + if (res_status != SUCCESS) | ||
3546 | + { | ||
3547 | + LOG_ERROR("sy_va_va_batch_vd(error): vlogodr_batch failed. (ret = {})", res_status); | ||
3548 | + return res_status; | ||
3549 | + } | ||
3550 | + | ||
3551 | + LOG_DEBUG("vr_vehicle_type_15cls_batch"); | ||
3552 | + res_status=vr_vehicle_type_15cls_batch(tools->vr_vr15cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_15cls_result_); | ||
3553 | + if (res_status != SUCCESS) | ||
3554 | + { | ||
3555 | + LOG_ERROR("sy_va_va_batch_vd(error): vr_vehicle_type_15cls_batch failed. (ret = {})", res_status); | ||
3556 | + return res_status; | ||
3557 | + } | ||
3558 | + | ||
3559 | + LOG_DEBUG("vr_vehicle_type_3885cls_batch"); | ||
3560 | + res_status = vr_vehicle_type_3885cls_batch(tools->vr_vr3885cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_3885cls_result_); | ||
3561 | + if (res_status != SUCCESS) | ||
3562 | + { | ||
3563 | + LOG_ERROR("sy_va_va_batch(error): vr_vehicle_type_3885cls_batch failed. (ret = {})", res_status); | ||
3564 | + return res_status; | ||
3565 | + } | ||
3566 | + | ||
3567 | + //output | ||
3568 | + int car_idx=0; | ||
3569 | + for(int b=0;b<batch_size;b++) | ||
3570 | + { | ||
3571 | + for(int c=0;c<result[b].count;c++) | ||
3572 | + { | ||
3573 | + if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ | ||
3574 | + { | ||
3575 | + char *vehicle_brand=result[b].info[c].vehicle_recg_res.vehicle_brand;//����ʶ��Ʒ�� | ||
3576 | + std::string str_vehicle_subbrand = result[b].info[c].vehicle_recg_res.vehicle_subbrand; | ||
3577 | + std::string str_vehicle_issue_year = result[b].info[c].vehicle_recg_res.vehicle_issue_year; | ||
3578 | + std::string str_vehicle_subbrand_issue_year; | ||
3579 | + if(str_vehicle_issue_year !="") | ||
3580 | + str_vehicle_subbrand_issue_year = str_vehicle_subbrand + "-" + str_vehicle_issue_year; | ||
3581 | + else | ||
3582 | + str_vehicle_subbrand_issue_year = str_vehicle_subbrand; | ||
3583 | + char *vehicle_subbrand_issue_year = (char *)str_vehicle_subbrand_issue_year.c_str();//����ʶ����Ʒ����� | ||
3584 | + float name_score=result[b].info[c].vehicle_recg_res.name_score; //����ʶ�����Ŷ� | ||
3585 | + //float name_score=0.7; //����ʶ�����Ŷ� | ||
3586 | + std::string str_vehicle_brand = vehicle_brand; | ||
3587 | + std::string str_vr_brand_subbrand_issue_year; | ||
3588 | + if(str_vehicle_subbrand_issue_year !="") | ||
3589 | + str_vr_brand_subbrand_issue_year = str_vehicle_brand + "-"+ str_vehicle_subbrand_issue_year; | ||
3590 | + else | ||
3591 | + str_vr_brand_subbrand_issue_year = str_vehicle_brand; | ||
3592 | + | ||
3593 | + LOG_DEBUG("vr:{} {} {}",vehicle_brand,vehicle_subbrand_issue_year,name_score); | ||
3594 | + | ||
3595 | + //������������--------- | ||
3596 | + std::string str_vr_cls_brand_subbrand_issue_year = vr_3885cls_result_[car_idx].vehicle_type; | ||
3597 | + //std::string str_vr_cls_brand_subbrand_issue_year = "����-310(ʱ����)-2017,2016";//test ������������������temp | ||
3598 | + //std::string str_vr_cls_brand_subbrand_issue_year = "����-730-2014";//test ������������������temp | ||
3599 | + //std::string str_vr_cls_brand_subbrand_issue_year = "����-730";//test ������������������temp | ||
3600 | + //std::string str_vr_cls_brand_subbrand_issue_year = "BEIJING-EU7-2019";//test ������������������temp | ||
3601 | + //std::string str_vr_cls_brand_subbrand_issue_year = "BEIJING-EU7-2019";//test ������������������temp | ||
3602 | + std::string str_vr_cls_brand =""; | ||
3603 | + std::string str_vr_cls_subbrand_issue_year =""; | ||
3604 | + std::string str_vr_cls_subbrand =""; | ||
3605 | + std::string str_vr_cls_issue_year =""; | ||
3606 | + std::string str_vr_cls_type =""; | ||
3607 | + //���Ʒ�� | ||
3608 | + int pos=0; | ||
3609 | + pos=str_vr_cls_brand_subbrand_issue_year.find("-"); | ||
3610 | + if( pos!= -1) ///pos=-1˵��û���ҵ�"-" | ||
3611 | + { | ||
3612 | + str_vr_cls_brand = str_vr_cls_brand_subbrand_issue_year.substr(0,pos); | ||
3613 | + str_vr_cls_subbrand_issue_year = str_vr_cls_brand_subbrand_issue_year.substr(pos+1); | ||
3614 | + } | ||
3615 | + else if(str_vr_cls_brand_subbrand_issue_year.size()>0)//û�ҵ�"-",�����ַ��� | ||
3616 | + { | ||
3617 | + str_vr_cls_brand = str_vr_cls_brand_subbrand_issue_year; | ||
3618 | + } | ||
3619 | + char *vr_cls_brand = (char *)str_vr_cls_brand.c_str(); | ||
3620 | + char *vr_cls_subbrand_issue_year = (char *)str_vr_cls_subbrand_issue_year.c_str(); | ||
3621 | + float vr_cls_score = vr_3885cls_result_[car_idx].score; | ||
3622 | + //�����Ʒ�ƺ���� | ||
3623 | + pos=0; | ||
3624 | + pos=str_vr_cls_subbrand_issue_year.find("-"); | ||
3625 | + if( pos!= -1) ///pos=-1˵��û���ҵ�"-" | ||
3626 | + { | ||
3627 | + str_vr_cls_subbrand = str_vr_cls_subbrand_issue_year.substr(0,pos); | ||
3628 | + str_vr_cls_issue_year = str_vr_cls_subbrand_issue_year.substr(pos+1); | ||
3629 | + } | ||
3630 | + else if(str_vr_cls_subbrand_issue_year.size()>0)//û�ҵ�"-",�����ַ��� | ||
3631 | + { | ||
3632 | + str_vr_cls_subbrand = str_vr_cls_subbrand_issue_year; | ||
3633 | + } | ||
3634 | + char *vr_cls_subbrand = (char *)str_vr_cls_subbrand.c_str(); | ||
3635 | + char *vr_cls_issue_year = (char *)str_vr_cls_issue_year.c_str(); | ||
3636 | + //str_vr_cls_type!!!!!!!! | ||
3637 | + std::unordered_map<std::string, std::string>::iterator iters = vehicle_name_type.find(str_vr_cls_brand_subbrand_issue_year); | ||
3638 | + if(iters != vehicle_name_type.end()) | ||
3639 | + { | ||
3640 | + str_vr_cls_type = iters->second; | ||
3641 | + } | ||
3642 | + char *vr_cls_type = (char *)str_vr_cls_type.c_str(); | ||
3643 | + | ||
3644 | + | ||
3645 | + LOG_DEBUG("car_idx:{} ",car_idx); | ||
3646 | + //1.У����Ʒ�� | ||
3647 | + int logo_change=0; | ||
3648 | + //logo output | ||
3649 | + int logo_count = vr_logo_result_[car_idx].count; | ||
3650 | + LOG_DEBUG("logo_count={} ",logo_count); | ||
3651 | + if(logo_count>0)//����� | ||
3652 | + { | ||
3653 | + //����Ʒ�� | ||
3654 | + int logo_index= vr_logo_result_[car_idx].vehicle_logo_infos[0].logo_brand_index; | ||
3655 | + float logo_recg_score = vr_logo_result_[car_idx].vehicle_logo_infos[0].recg_score; | ||
3656 | + char *vehicle_logo_brand = vr_logo_result_[car_idx].vehicle_logo_infos[0].logo_brand; | ||
3657 | + | ||
3658 | + if(logo_recg_score>0 && name_score>0 && vr_cls_score>0) | ||
3659 | + { | ||
3660 | + LOG_DEBUG("logo_recg_score:{} name_score:{} vr_cls_score:{}",logo_recg_score, name_score, vr_cls_score); | ||
3661 | + if(logo_strcmp(vehicle_logo_brand, vehicle_brand)==0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) | ||
3662 | + { | ||
3663 | + if(strcmp(vehicle_subbrand_issue_year, vr_cls_subbrand_issue_year)!=0) | ||
3664 | + { | ||
3665 | + LOG_DEBUG("vr_cls_brand:{} vr_cls_subbrand:{} vr_cls_issue_year:{} vr_cls_type:{} ", vr_cls_brand, vr_cls_subbrand, vr_cls_issue_year, vr_cls_type); | ||
3666 | + if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3667 | + { | ||
3668 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3669 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3670 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3671 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3672 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3673 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3674 | + if(score> 0.99 )score =0.99; | ||
3675 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3676 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3677 | + | ||
3678 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3679 | + } | ||
3680 | + | ||
3681 | + if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) | ||
3682 | + { | ||
3683 | + if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) | ||
3684 | + { | ||
3685 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3686 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3687 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3688 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3689 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3690 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3691 | + if(score> 0.99 )score =0.99; | ||
3692 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3693 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3694 | + | ||
3695 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3696 | + } | ||
3697 | + } | ||
3698 | + | ||
3699 | + if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3700 | + { | ||
3701 | + if( VR_CLS_THRE - vr_cls_score < VR_REAR_THRE - name_score) | ||
3702 | + { | ||
3703 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3704 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3705 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3706 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3707 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3708 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3709 | + if(score> 0.99 )score =0.99; | ||
3710 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3711 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3712 | + | ||
3713 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3714 | + } | ||
3715 | + } | ||
3716 | + } | ||
3717 | + } | ||
3718 | + | ||
3719 | + LOG_DEBUG("vr_cls_brand:{} vr_cls_subbrand:{} vr_cls_issue_year:{} vr_cls_type:{} ", vr_cls_brand, vr_cls_subbrand, vr_cls_issue_year, vr_cls_type); | ||
3720 | + if(logo_strcmp(vehicle_logo_brand, vehicle_brand)!=0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)!=0) | ||
3721 | + { | ||
3722 | + if(strcmp(vehicle_brand, vr_cls_brand)==0) | ||
3723 | + { | ||
3724 | + if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3725 | + { | ||
3726 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3727 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3728 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3729 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3730 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3731 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3732 | + if(score> 0.99 )score =0.99; | ||
3733 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3734 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3735 | + | ||
3736 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3737 | + } | ||
3738 | + | ||
3739 | + if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) | ||
3740 | + { | ||
3741 | + if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) | ||
3742 | + { | ||
3743 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3744 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3745 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3746 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3747 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3748 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3749 | + if(score> 0.99 )score =0.99; | ||
3750 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3751 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3752 | + | ||
3753 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3754 | + } | ||
3755 | + } | ||
3756 | + | ||
3757 | + if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3758 | + { | ||
3759 | + if(logo_recg_score >= VR_LOGO_THRE) | ||
3760 | + { | ||
3761 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); | ||
3762 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3763 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3764 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3765 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3766 | + result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; | ||
3767 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3768 | + logo_change=1; | ||
3769 | + | ||
3770 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3771 | + } | ||
3772 | + else | ||
3773 | + { | ||
3774 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3775 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3776 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3777 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3778 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3779 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3780 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3781 | + | ||
3782 | + //result[b].info[c].vehicle_recg_res.count = 0; | ||
3783 | + } | ||
3784 | + | ||
3785 | + } | ||
3786 | + } | ||
3787 | + else | ||
3788 | + { | ||
3789 | + if(logo_recg_score >= VR_LOGO_THRE) | ||
3790 | + { | ||
3791 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); | ||
3792 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3793 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3794 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3795 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3796 | + result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; | ||
3797 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3798 | + logo_change=1; | ||
3799 | + | ||
3800 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3801 | + } | ||
3802 | + else | ||
3803 | + { | ||
3804 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3805 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3806 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3807 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3808 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3809 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3810 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3811 | + | ||
3812 | + //result[b].info[c].vehicle_recg_res.count =0; | ||
3813 | + } | ||
3814 | + } | ||
3815 | + } | ||
3816 | + | ||
3817 | + if(logo_strcmp(vehicle_logo_brand, vehicle_brand)!=0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) | ||
3818 | + { | ||
3819 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3820 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3821 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3822 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3823 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3824 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3825 | + if(score> 0.99 )score =0.99; | ||
3826 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3827 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3828 | + | ||
3829 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3830 | + } | ||
3831 | + | ||
3832 | + } | ||
3833 | + | ||
3834 | + if(logo_recg_score>0 && name_score==0 && vr_cls_score>0) | ||
3835 | + { | ||
3836 | + LOG_DEBUG("logo_recg_score:{} name_score:{} vr_cls_score:{}",logo_recg_score, name_score, vr_cls_score); | ||
3837 | + if(logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) | ||
3838 | + { | ||
3839 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3840 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3841 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3842 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3843 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3844 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3845 | + if(score> 0.99 )score =0.99; | ||
3846 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3847 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3848 | + | ||
3849 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3850 | + } | ||
3851 | + else | ||
3852 | + { | ||
3853 | + if(logo_recg_score >= VR_LOGO_THRE) | ||
3854 | + { | ||
3855 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); | ||
3856 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3857 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3858 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3859 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3860 | + result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; | ||
3861 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3862 | + logo_change=1; | ||
3863 | + | ||
3864 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3865 | + } | ||
3866 | + else | ||
3867 | + { | ||
3868 | + if(vr_cls_score > VR_CLS_THRE) | ||
3869 | + { | ||
3870 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3871 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3872 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3873 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3874 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3875 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3876 | + if(score> 0.99 )score =0.99; | ||
3877 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3878 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3879 | + | ||
3880 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3881 | + } | ||
3882 | + else | ||
3883 | + { | ||
3884 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3885 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3886 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3887 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3888 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3889 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3890 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3891 | + | ||
3892 | + //result[b].info[c].vehicle_recg_res.count =0; | ||
3893 | + } | ||
3894 | + } | ||
3895 | + } | ||
3896 | + } | ||
3897 | + } | ||
3898 | + else | ||
3899 | + { | ||
3900 | + LOG_DEBUG("name_score:{} vr_cls_score:{}", name_score, vr_cls_score); | ||
3901 | + if(name_score>0 && vr_cls_score>0) | ||
3902 | + { | ||
3903 | + if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3904 | + { | ||
3905 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3906 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3907 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3908 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3909 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3910 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3911 | + if(score> 0.99 )score =0.99; | ||
3912 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3913 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3914 | + | ||
3915 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3916 | + } | ||
3917 | + | ||
3918 | + if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) | ||
3919 | + { | ||
3920 | + if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) | ||
3921 | + { | ||
3922 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3923 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3924 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3925 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3926 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3927 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3928 | + if(score> 0.99 )score =0.99; | ||
3929 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3930 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3931 | + | ||
3932 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3933 | + } | ||
3934 | + } | ||
3935 | + | ||
3936 | + //��������һ�£��ҷ������Ŷ�С��0.3�������ȶ����ƶ�С��0.8���� �����Ʒ��-��Ʒ��-���ʶ���������������ţ�������� | ||
3937 | + if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) | ||
3938 | + { | ||
3939 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3940 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3941 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3942 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3943 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3944 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3945 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3946 | + | ||
3947 | + //result[b].info[c].vehicle_recg_res.count =0; | ||
3948 | + } | ||
3949 | + | ||
3950 | + | ||
3951 | + } | ||
3952 | + | ||
3953 | + if(name_score==0 && vr_cls_score>0) | ||
3954 | + { | ||
3955 | + if(vr_cls_score>VR_CLS_THRE) | ||
3956 | + { | ||
3957 | + LOG_DEBUG("vr_cls_brand:{} ",vr_cls_brand); | ||
3958 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); | ||
3959 | + LOG_DEBUG("vr_cls_subbrand:{}", vr_cls_subbrand); | ||
3960 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); | ||
3961 | + LOG_DEBUG("vr_cls_issue_year:{}", vr_cls_issue_year); | ||
3962 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); | ||
3963 | + LOG_DEBUG("vr_cls_type:{}", vr_cls_type); | ||
3964 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); | ||
3965 | + LOG_DEBUG("freight_ton:{} ", result[b].info[c].vehicle_recg_res.freight_ton); | ||
3966 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3967 | + LOG_DEBUG("vr_cls_score:{}", vr_cls_score); | ||
3968 | + float score = vr_cls_score + VR_CLS_OFFSET; | ||
3969 | + if(score> 0.99 )score =0.99; | ||
3970 | + LOG_DEBUG("score:{}", score); | ||
3971 | + result[b].info[c].vehicle_recg_res.name_score = score; | ||
3972 | + LOG_DEBUG("name_score:{}", result[b].info[c].vehicle_recg_res.name_score); | ||
3973 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3974 | + LOG_DEBUG("index:{}", result[b].info[c].vehicle_recg_res.index); | ||
3975 | + | ||
3976 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
3977 | + LOG_DEBUG("if end."); | ||
3978 | + } | ||
3979 | + else | ||
3980 | + { | ||
3981 | + memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); | ||
3982 | + memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); | ||
3983 | + memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); | ||
3984 | + memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); | ||
3985 | + memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); | ||
3986 | + result[b].info[c].vehicle_recg_res.name_score = 0; | ||
3987 | + result[b].info[c].vehicle_recg_res.index = -1; | ||
3988 | + | ||
3989 | + //result[b].info[c].vehicle_recg_res.count =0; | ||
3990 | + } | ||
3991 | + | ||
3992 | + } | ||
3993 | + | ||
3994 | + }//end û�м����� | ||
3995 | + | ||
3996 | + LOG_DEBUG("vehicle_type:{}", result[b].info[c].vehicle_recg_res.vehicle_type); | ||
3997 | + char* vehicle_type=result[b].info[c].vehicle_recg_res.vehicle_type; | ||
3998 | + name_score=result[b].info[c].vehicle_recg_res.name_score; //����ʶ�����Ŷ� | ||
3999 | + char* vehicle_type_15cls = vr_15cls_result_[car_idx].vehicle_type; | ||
4000 | + float vr_15cls_score = vr_15cls_result_[car_idx].score; | ||
4001 | + LOG_DEBUG("name_score:{} vehicle_type_15cls:{} vr_15cls_score:{}", name_score, vehicle_type_15cls, vr_15cls_score); | ||
4002 | + if(name_score>0)//�г������Ľ�� | ||
4003 | + { | ||
4004 | + LOG_DEBUG("name_score:{} vr_15cls_score:{} logo_change:{}", name_score, vr_15cls_score, logo_change); | ||
4005 | + if(logo_change == 0) | ||
4006 | + { | ||
4007 | + if(strcmp(vehicle_type, vehicle_type_15cls)!=0) | ||
4008 | + { | ||
4009 | + if(name_score < 0.55 && vr_15cls_score>0.8) | ||
4010 | + { | ||
4011 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); | ||
4012 | + result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; | ||
4013 | + } | ||
4014 | + } | ||
4015 | + } | ||
4016 | + else if(logo_change == 1) | ||
4017 | + { | ||
4018 | + if(vr_15cls_score>=0.2) | ||
4019 | + { | ||
4020 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); | ||
4021 | + result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; | ||
4022 | + } | ||
4023 | + } | ||
4024 | + } | ||
4025 | + else if(name_score==0) | ||
4026 | + { | ||
4027 | + LOG_DEBUG("name_score:{} vr_15cls_score:{}", name_score, vr_15cls_score); | ||
4028 | + if(vr_15cls_score>=0.8) | ||
4029 | + { | ||
4030 | + memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); | ||
4031 | + result[b].info[c].vehicle_recg_res.name_score = vr_15cls_score; | ||
4032 | + | ||
4033 | + //result[b].info[c].vehicle_recg_res.count =1; | ||
4034 | + } | ||
4035 | + } | ||
4036 | + | ||
4037 | + car_idx++; | ||
4038 | + } | ||
4039 | + } | ||
4040 | + } | ||
4041 | + | ||
4042 | + //release vr_logo_result_ | ||
4043 | + if (vr_logo_result_ != NULL) | ||
4044 | + { | ||
4045 | + delete[] vr_logo_result_; | ||
4046 | + vr_logo_result_ = NULL; | ||
4047 | + } | ||
4048 | + if (vr_15cls_result_ != NULL) | ||
4049 | + { | ||
4050 | + delete[] vr_15cls_result_; | ||
4051 | + vr_15cls_result_ = NULL; | ||
4052 | + } | ||
4053 | + if (vr_3885cls_result_ != NULL) | ||
4054 | + { | ||
4055 | + delete[] vr_3885cls_result_; | ||
4056 | + vr_3885cls_result_ = NULL; | ||
4057 | + } | ||
4058 | + LOG_DEBUG("end body4-3.vr logo 15cls----- "); | ||
4059 | + | ||
4060 | + return SUCCESS; | ||
4061 | + | ||
4062 | +} | ||
4063 | + | ||
4064 | +//end for ����ʶ�����복logo�����ϲ���--------------------------- | ||
4065 | + | ||
4066 | + | ||
4067 | + | ||
4068 | + | ||
4069 | + | ||
4070 | + | ||
4071 | + | ||
4072 | +//===================== �������� =====================// | ||
4073 | + | ||
4074 | +int checkTime() | ||
4075 | +{ | ||
4076 | + struct tm* info; | ||
4077 | + int nYear, nMonth, nDay; | ||
4078 | + time_t raw; | ||
4079 | + time(&raw); | ||
4080 | + info = localtime(&raw); | ||
4081 | + nYear = info->tm_year + 1900; | ||
4082 | + nMonth = info->tm_mon + 1; | ||
4083 | + nDay = info->tm_mday; | ||
4084 | + if (nYear == 2019 && nMonth < 7) | ||
4085 | + return 1; | ||
4086 | + LOG_ERROR("Software license is out of time! Please contact software developers."); | ||
4087 | + //exit(0); | ||
4088 | + return -1; | ||
4089 | +} | ||
4090 | + | ||
4091 | + | ||
4092 | + |
src/ai_engine_module/VehicleAnalysisDevice.h0
0 → 100644
1 | +#ifndef __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ | ||
2 | +#define __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ | ||
3 | + | ||
4 | +#include "vehicle_analysis.h" | ||
5 | + | ||
6 | +int va_init(void ** handle, va_param param); | ||
7 | + | ||
8 | +int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result *result); | ||
9 | + | ||
10 | +void va_release(void ** handle); | ||
11 | + | ||
12 | + | ||
13 | +#endif // __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ | ||
0 | \ No newline at end of file | 14 | \ No newline at end of file |
src/ai_engine_module/include.h
@@ -11,11 +11,12 @@ | @@ -11,11 +11,12 @@ | ||
11 | #include "opencv2/opencv.hpp" | 11 | #include "opencv2/opencv.hpp" |
12 | #include "opencv2/imgcodecs/legacy/constants_c.h" | 12 | #include "opencv2/imgcodecs/legacy/constants_c.h" |
13 | #include "opencv2/imgproc/types_c.h" | 13 | #include "opencv2/imgproc/types_c.h" |
14 | -#include "time.h" | 14 | + |
15 | #include "sys/time.h" | 15 | #include "sys/time.h" |
16 | 16 | ||
17 | #include "utils.h" | 17 | #include "utils.h" |
18 | #include "dvpp_process.h" | 18 | #include "dvpp_process.h" |
19 | +#include "stream_data.h" | ||
19 | 20 | ||
20 | #include "../utils/logger.hpp" | 21 | #include "../utils/logger.hpp" |
21 | 22 | ||
@@ -24,6 +25,12 @@ | @@ -24,6 +25,12 @@ | ||
24 | #include <vector> | 25 | #include <vector> |
25 | #include <string> | 26 | #include <string> |
26 | 27 | ||
28 | +#include<math.h> | ||
29 | +#include<string.h> | ||
30 | +#include<stdio.h> | ||
31 | +#include <time.h> | ||
32 | + | ||
33 | + | ||
27 | using namespace std; | 34 | using namespace std; |
28 | using namespace cv; | 35 | using namespace cv; |
29 | 36 |