#include "vehicle_analysis.h" #include "vehicle_result.h" #include "vpt.h" #include "vpd.h" #include "vid.h" #include "vf_head.h"//������-��ͷ #include "vf_win.h"//������-���� #include "vf_rear.h"//������-��β #include "vehicle_color.h" #include "vehicle_recognition.h" //��ͷ����ʶ�� #include "vehicle_rear_recognition.h" // ��β����ʶ�� #include "vehicle_plate_dr.h" //#include "vs_det_cls.h" //#include "muck_truck_cover.h" #include "vr_type.h" //#include "stain_vplate.h" //����ʶ�𲹳�ʶ�� #include "vr_vehicle_type_15cls.h" //���Ͳ���ʶ��--����15���� #include "vehicle_logo_dr.h" //���Ͳ���ʶ��--��logoʶ�� #include "vr_vehicle_type_3885cls.h" //���Ͳ���ʶ��--���������� //MTAĦ�г����ֳ����� #include "human_car_parsing.h"//���ﳵ���������ͷ�����ԣ� #include "head_shoulder_det.h"//ͷ�磨����������ˣ� #include "VehicleAnalysisDevice.h" #include "include.h" #define SUCCESS 0 #define VD_MAXDETECTCOUNT 100 #define VPD_MAXNUM 300 #define FEATURESIZE 256 //�������� #define VR_HEAD_THRE 0.7 //��ͷ����ʶ����ֵ #define VR_REAR_THRE 0.8 //��β����ʶ����ֵ #define VR_CLS_THRE 0.25 //������������ֵ #define VR_CLS_OFFSET 0.3 //�������������Ŷ����ϸ���ֵ #define VR_LOGO_THRE 0.9 //��logo����ֵ #define VR_15CLS_THRE 0.8 //����15�������ֵ #define VERSION_WUXI 0 //�л����а汾�������汾�������汾��ֻ��topn���������������Ͳ���ʶ�𣬵�Ҫ���ӳ���15������������ȱʧ�ij����͡� #define VR_WUXI_LOGO 1 //�����汾���Ƿ�����logo������ #define VPT_TOPN 10 //�˳���ȡtopn���з��� #define MAX_BATCHSIZE 10 using namespace std; typedef struct va_handle { void* vpt_handle; void* vc_handle; void* vr_handle;//����ʶ�� void* vrr_handle;//��β����ʶ�� void* vr_logo_dr_handle;//����ʶ�𲹳�ʶ��(��ͷ��βlogoʶ��) void* vr_vr15cls_handle;//����ʶ�𲹳�ʶ��(����15����) void* vr_vr3885cls_handle;//����ʶ�𲹳�ʶ��(����������) void* vp_handle; void* vpd_handle; void* vid_handle; void* vf_head_handle; void* vf_win_handle; void* vf_rear_handle;//��β������ //void* vs_handle;//����Ʒ�೵ʶ�� //void* muck_truck_cover_handle; //�������Ǹ� //void* viq_handle; void* hcp_handle;//mta�е����ﳵ(Ħ�г���ʻԱͷ������) void* hs_handle;//���˷��� //void* stain_vp_handle;//�����ڵ�ʶ�� //void* vf_face_handle;//�������������� va_param param; //�Ѳ�������handle���� aclrtContext ctx; }va_handle; int rect_driver_copilot(sy_rect vpd_rect, sy_rect body_rect); int process_vptresult( sy_img *imgdata, int batch_size, vpt_result * vpt_result_); void process_vpdresult(sy_rect body_rect, vpd_result * src, vpd_result * dest); sy_rect rect_extend(sy_rect obj_rect,int image_w,int image_h,float scale);//Ŀ���������� //int lorry_manned(va_handle *tools,sy_img * lorry_img, sy_rect win_rect, lorry_manned_result *result); //int process_vidresult(void * handle, int batch_size, va_result *result);//��Υ���복������ϲ��� int manned_analysis(va_handle *tools,sy_img * img, int type, sy_rect win_rect, manned_result *result); int process_vidresult_atlas(void * handle, int batch_size, va_result *result);//��Υ���복������ϲ���,atlas���Ƶģ���Υ�����ֻ�ò�ϵ��ȫ���IJ��ԣ� //void CvBGR2NV21(cv::Mat& bgr, unsigned char* yuv); int logo_strcmp(char * logo,char * brand); int logo_check_wuxi(char * logo); int vr_supplement_wuxi(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result);//�����汾�ij��Ͳ���ʶ�� int vr_supplement(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result);//���а汾�ij��Ͳ���ʶ�� const char * va_get_version() { return "sy_va_version:1.2.0.20231129.atlas310p.arm.withOfflineAuthorization"; } int va_init(void ** handle, va_param param) { va_handle *tools=new va_handle(); *handle=(void *)tools; int ret = SUCCESS; tools->param = param; string str1=tools->param.models_Path; LOG_DEBUG("start init Context "); int devId = tools->param.gpuid; LOG_INFO("devId:{}", devId); ACL_CALL(aclrtSetDevice(devId), ACL_ERROR_NONE, SY_FAILED); //aclrtContext ctx; //ACL_CALL(aclrtCreateContext(&ctx, devId), ACL_ERROR_NONE, SY_FAILED); ACL_CALL(aclrtCreateContext(&tools->ctx, devId), ACL_ERROR_NONE, SY_FAILED); LOG_DEBUG("end init Context "); //1.�������init if(tools->param.vehicle_detect_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_detect_config"); //string str2=str1 + "vtp0609.om"; string str2=str1 + "vpt0715_310p.om"; LOG_DEBUG("1.vpt init "); //vpt�˳����ʼ�� vpt_param vpt_param_; //vpt_param_.modelNames = "/home/HwHiAiUser/WH/vehicle_analysis202105/vehicle_analysis/all_models/vtp.om"; vpt_param_.modelNames = (char *)str2.c_str(); LOG_DEBUG("vpt modelNames:%s ",vpt_param_.modelNames); vpt_param_.threshold = tools->param.vehicle_det_thresld; vpt_param_.devId = tools->param.gpuid; vpt_param_.isTrk = false; int init_state=vpt_init(&(tools->vpt_handle), vpt_param_); if (init_state != SUCCESS) { //HIAI_ENGINE_LOG(HIAI_IDE_ERROR, "vpt_init failed"); LOG_ERROR("sy_va_va_init(error):vpt_init failed "); return init_state; } } //2.VPD 23�೵���Լ��ʶ�� if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_pendant_det_config"); string str2=str1 + "vpd0629_310p.om"; LOG_DEBUG("2.1 vpd init "); vehicle_pendant_det_param vpdet_param; vpdet_param.dmodelNames = (char *)str2.c_str(); vpdet_param.devId = tools->param.gpuid; vpdet_param.dthresld = tools->param.vehicle_attribute_det_thresld; vpdet_param.dlogo_thresld = 0.5; int init_state=vpd_init(&(tools->vpd_handle), vpdet_param); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vpd init end.(ret = {})", init_state); return init_state; } } //3.����ɫinit if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_color_config"); string str2=str1 + "carcolor310p.om"; LOG_DEBUG("3.vc init "); //vpt�˳����ʼ�� vc_param vc_param_; //vpt_param_.modelNames = "/home/HwHiAiUser/WH/vehicle_analysis202105/vehicle_analysis/all_models/vtp.om"; vc_param_.modelNames = (char *)str2.c_str(); vc_param_.thresld = tools->param.vc_thresld; vc_param_.devId = tools->param.gpuid; int ret=vc_init(&(tools->vc_handle), vc_param_); if (ret != SUCCESS) { //HIAI_ENGINE_LOG(HIAI_IDE_ERROR, "vc_init failed"); LOG_ERROR("sy_va_va_init(error):vc_init failed "); return ret; } } //4.VR����ʶ�� if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_recg_config"); string str2=str1 + "vr_head0725_310p.om"; LOG_DEBUG("4.1.vr init "); vr_param vr_param_; vr_param_.modelNames = (char *)str2.c_str(); vr_param_.devId = tools->param.gpuid; vr_param_.db_path=tools->param.dbPath; int ret=vr_init(&(tools->vr_handle), vr_param_); if (ret != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vr init end.(ret = {})", ret); return ret; } string str3=str1 + "vr_rear1230x_310p.om"; LOG_DEBUG("4.2.vrr init "); vrr_param vrr_param_; vrr_param_.modelNames = (char *)str3.c_str(); vrr_param_.devId = tools->param.gpuid; vrr_param_.db_path=tools->param.dbPath; ret=vrr_init(&(tools->vrr_handle), vrr_param_); if (ret != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vrr init end.(ret = {})", ret); return ret; } if(VERSION_WUXI ) { if(VR_WUXI_LOGO) { LOG_DEBUG("4.3 start vlogodr_init "); string str2 = str1 + "vlogo_det310p.om"; vlogod_param vlogod_param_; vlogod_param_.dmodelNames = (char *)str2.c_str(); vlogod_param_.dthresld = tools->param.vehicle_logo_det_thresld; vlogod_param_.devId = tools->param.gpuid; string str3 = str1 + "vlogo_reg310p.om"; vlogor_param vlogor_param_; vlogor_param_.rmodelNames = (char *)str3.c_str(); vlogor_param_.rthresld = 0;//0.8 int init_state = vlogodr_init(&(tools->vr_logo_dr_handle),vlogod_param_, vlogor_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vlogodr_init end.(ret = {})", init_state); return init_state; } } LOG_DEBUG("4.4 start vr_vehicle_type_15cls_init "); string str6 = str1 + "vtype15_2106_310p.om"; vr_vehicle_type_15cls_param vehicle_type_15cls_params; vehicle_type_15cls_params.devId = tools->param.gpuid; vehicle_type_15cls_params.thresld = 0;//0.8 vehicle_type_15cls_params.modelNames = (char *)str6.c_str(); int init_state = vr_vehicle_type_15cls_init(&(tools->vr_vr15cls_handle), vehicle_type_15cls_params); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_15cls_init end.(ret = {})", init_state); return init_state; } } if(!VERSION_WUXI && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN)//����ʶ�𲹳�ʶ��logo���ʶ��+����15���ࣩ { LOG_DEBUG("vehicle_recg_supplement_config"); LOG_DEBUG("4.3 start vlogodr_init "); string str2 = str1 + "vlogo_det310p.om"; vlogod_param vlogod_param_; vlogod_param_.dmodelNames = (char *)str2.c_str(); vlogod_param_.dthresld = tools->param.vehicle_logo_det_thresld; vlogod_param_.devId = tools->param.gpuid; string str3 = str1 + "vlogo_reg310p.om"; vlogor_param vlogor_param_; vlogor_param_.rmodelNames = (char *)str3.c_str(); vlogor_param_.rthresld = 0;//0.8 int init_state = vlogodr_init(&(tools->vr_logo_dr_handle),vlogod_param_, vlogor_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vlogodr_init end.(ret = {})", init_state); return init_state; } LOG_DEBUG("4.4 start vr_vehicle_type_15cls_init"); string str6 = str1 + "vtype15_2106_310p.om"; vr_vehicle_type_15cls_param vehicle_type_15cls_params; vehicle_type_15cls_params.devId = tools->param.gpuid; vehicle_type_15cls_params.thresld = 0;//0.8 vehicle_type_15cls_params.modelNames = (char *)str6.c_str(); init_state = vr_vehicle_type_15cls_init(&(tools->vr_vr15cls_handle), vehicle_type_15cls_params); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_15cls_init end.(ret = {})", init_state); return init_state; } LOG_DEBUG("4.5 start vr_vehicle_type_3885cls_init "); string str7 = str1 + "vtype3885x_310p.om"; vr_vehicle_type_3885cls_param vr_vehicle_type_3885cls_params; vr_vehicle_type_3885cls_params.devId = tools->param.gpuid; vr_vehicle_type_3885cls_params.modelNames = (char *)str7.c_str(); init_state = vr_vehicle_type_3885cls_init(&(tools->vr_vr3885cls_handle), vr_vehicle_type_3885cls_params); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vr_vehicle_type_3885cls_init end.(ret = {})", init_state); return init_state; } } } //5.VP���Ƽ��ʶ�� if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_plate_det_recg_config"); string str2 = str1 + "yolo_plate_det310p.om"; LOG_DEBUG("5.vp init "); vpd_param vpd_param_; vpd_param_.modelNames = (char *)str2.c_str(); vpd_param_.devId = tools->param.gpuid; vpd_param_.thresld=tools->param.vehicle_plate_det_thresld; string str3 = str1 + "plate3cls_310p.om"; string str4 = str1 + "plate_reg230316_310p.om"; vpr_param vpr_param_; vpr_param_.cls_modelNames = (char *)str3.c_str(); vpr_param_.reg_modelNames = (char *)str4.c_str(); int init_state=vpdr_init(&(tools->vp_handle), vpd_param_, vpr_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vpdr init end.(ret = {})", init_state); return init_state; } } //6.VID��Υ�� if(tools->param.vehicle_illegal_config==SY_CONFIG_OPEN) { string str2 = str1 + "vid2x_310p.om"; LOG_DEBUG("6.vid init "); vid_param vid_param_; vid_param_.modelNames = (char *)str2.c_str(); vid_param_.nobody_thre = 0.8; vid_param_.phone_thre = 0.55;//0.7; vid_param_.call_thre = 0.6;//0.84; vid_param_.nosafebelt_thre = 0.9; vid_param_.smoke_thre = 0.85;//0.91; vid_param_.devId = tools->param.gpuid; int init_state=vid_init(&(tools->vid_handle), vid_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vid init end.(ret = {})", init_state); return init_state; } } //7.VF��������ȡ if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_feature_config"); string str2 = str1 + "vf_headx310p.om"; LOG_DEBUG("7.1 vf head init "); vf_head_param vf_head_param_; vf_head_param_.modelNames = (char *)str2.c_str(); vf_head_param_.thresld = 0.65; vf_head_param_.devId = tools->param.gpuid; int init_state=vf_head_init(&(tools->vf_head_handle), vf_head_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vf head init end.(ret = {})", init_state); return init_state; } string str3 = str1 + "vf_winx_310p.om"; LOG_DEBUG("7.2 vf win init "); vf_win_param vf_win_param_; vf_win_param_.modelNames = (char *)str3.c_str(); vf_win_param_.thresld = 0.8; vf_win_param_.devId = tools->param.gpuid; init_state=vf_win_init(&(tools->vf_win_handle), vf_win_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vf win init end.(ret = {})", init_state); return init_state; } string str4 = str1 + "vf_rear1025_310p.om"; //��β������ LOG_DEBUG("7.3 vf rear init "); vf_rear_param param; param.modelNames = (char *)str4.c_str(); param.devId= tools->param.gpuid; param.thresld = 0.6; init_state=vf_rear_init(&(tools->vf_rear_handle), param); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): vf_rear init end.(ret = {})", init_state); return init_state; } } //motor���� if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_motor_tricycle_analysis_config"); string str2 = str1 + "hcp0629x_310p.om"; LOG_DEBUG("8.1 hcp init "); hcp_param hcp_param_; hcp_param_.modelNames = (char *)str2.c_str(); hcp_param_.devId = tools->param.gpuid; int init_state=hcp_init(&(tools->hcp_handle), hcp_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): hcp_init end.(ret = {})", init_state); return init_state; } } //���˷��� if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN) { LOG_DEBUG("vehicle_manned_config"); string str2 = str1 + "hs_sim0610x_310p.om"; LOG_DEBUG("8.1 hs init "); hs_det_param hs_param_; hs_param_.modelNames = (char *)str2.c_str(); hs_param_.thresld = 0.3;//��ʱ�ⲿ���ɵ� hs_param_.devId = tools->param.gpuid; int init_state=hs_det_init(&(tools->hs_handle), hs_param_); if (init_state != SUCCESS) { LOG_ERROR("sy_va_va_init(error): hs_det_init end.(ret = {})", init_state); return init_state; } } return SUCCESS; } double msecond() { struct timeval tv; gettimeofday(&tv, 0); return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0); } int prepare_data(sy_img * img_data_array, int batch_size, sy_img batch_img[], ImageData img_data_dvpp[]) { for(int b=0;b1000 || h > 1000)//ͼ�����1000��ָ�� batch_img_bfpad { batch_img[b].w_ = img_data_array[b].w_; batch_img[b].h_ = img_data_array[b].h_; batch_img[b].data_ = img_data_array[b].data_; Utils::CopysyImageDataToDvpp(img_data_dvpp[b], img_data_array[b]); } else { w = (w + 127)/128 *128; h = (h+ 15) / 16 * 16; //devתcpu sy_img img_data_array_host; img_data_array_host.data_ = NULL; img_data_array_host.w_ = w; img_data_array_host.h_ = h; uint32_t size = w * h * 1.5; img_data_array_host.data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(img_data_array[b].data_, size); int w2 = w *1.5;//width pad 1.5�� //if(w2%2!=0)w2+=1;//ż�� w2 = (w2 + 127)/128 *128; int h2 = h; uint32_t size2 = w2 * h2 *1.5; sy_img img_data_array_pad; img_data_array_pad.w_ = w2; img_data_array_pad.h_ = h2; img_data_array_pad.data_=new unsigned char[size2]; memset(img_data_array_pad.data_,0,sizeof(unsigned char)*size2); for(int jj=0;jj< h ;jj++) { memcpy(&img_data_array_pad.data_[jj*w2], &img_data_array_host.data_[jj*w], w * sizeof(unsigned char)); //Y } int hw = h*w; int h2w2 = h2*w2; for(int jj=0;jj< h/2 ;jj++) { memcpy(&img_data_array_pad.data_[h2w2+jj*w2], &img_data_array_host.data_[hw+jj*w], w * sizeof(unsigned char)); //UV } //cpu��gpu Utils::CopysyImageDataToDvpp(img_data_dvpp[b], img_data_array_pad); //set_data batch_img[b].w_ = w2; batch_img[b].h_ = h2; batch_img[b].data_ = img_data_dvpp[b].data.get(); //delete if(img_data_array_host.data_ != NULL) { delete[] img_data_array_host.data_; img_data_array_host.data_ = NULL; } if(img_data_array_pad.data_ != NULL) { delete[] img_data_array_pad.data_; img_data_array_pad.data_ = NULL; } } } return 0; } //----------����ϵ��----// //wh20210713����img_data_array��device����,batch_size�̶�Ϊ10 int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result *result) { if (handle == NULL) { LOG_ERROR("sy_va_va_batch(error): handle == null."); return -1; } if ((*img_data_array).data_ == NULL || (*img_data_array).w_ == 0 || (*img_data_array).h_ == 0) { LOG_ERROR("sy_va_va_batch(error): imgdata == null or w == 0 or h == 0."); return -1; } if (batch_size == 0) { LOG_ERROR("sy_va_va_batch(error): batch size == 0."); return -1; } va_handle *tools=(va_handle *)handle; //�������뿪�� if(tools->param.vehicle_detect_config==SY_CONFIG_CLOSE) { LOG_ERROR("sy_va_va_batch(error): vehicle_detect_config error."); return -1; } //wh:init��process����һ���̵߳û�����Ҫ�趨Context����Ӧ������ //ACL_CALL(aclrtSetDevice(0), ACL_ERROR_NONE, SY_FAILED); ACL_CALL(aclrtSetCurrentContext(tools->ctx), ACL_ERROR_NONE, SY_FAILED); LOG_DEBUG("prepare data"); //wh20220301 //step2----����batch_img��ͼ�����1000��ָ�� img_data_array ��ͼ��С��1000����pad��ָ�� sy_img batch_img[batch_size]; // ImageData img_data_dvpp[batch_size];//������ͼ�񿽱���dvpp,���ں���Ŀ�ͼ prepare_data(img_data_array, batch_size, batch_img, img_data_dvpp); //��ʼ��dvpp aclrtStream stream = nullptr; ACL_CALL(aclrtCreateStream(&stream), ACL_ERROR_NONE, SY_FAILED); DvppProcess* dvpp = new DvppProcess(); dvpp->InitResource(stream); //��ͷ��β�����ı�ǩ int car_body_num=0;//body�г������� int body_num=0;//body������ int win_num=0; int head_num=0; int rear_num=0; int motor_num = 0; int tricycle_num = 0; int res_status; vpt_result *vpt_result_; LOG_DEBUG("vpt_batch"); res_status = vpt_batch(tools->vpt_handle, batch_img, batch_size, &vpt_result_);//device���� if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vpt_batch failed. (ret = {})", res_status); return res_status; } LOG_DEBUG("vpt_batch end"); LOG_DEBUG("process_vptresult"); process_vptresult(batch_img, batch_size, vpt_result_); //output int body_idx=0; for (int b = 0; b < batch_size; b++) { int idx =0; for(int c=0;c tools->param.vehicle_det_thresld) { result[b].info[idx].vpt_type = index; if(VERSION_WUXI && c>=VPT_TOPN )//�����汾ֻ����topn { result[b].info[idx].type=5;//����(������) result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; result[b].info[idx].vehicle_body_detect_res.score = score; idx++; } else { int manned_label =0;//�Ƿ������˷��� if((index == 0) )//人车物0是行人 { result[b].info[idx].type=6;//行人 result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; result[b].info[idx].vehicle_body_detect_res.score = score; idx++; } //Ħ�г������ֳ�����СĿ��ߴ��һ����ˣ����̱߶����� 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 { result[b].info[idx].type= index;//2-motor 3-tricycle result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; result[b].info[idx].vehicle_body_detect_res.score = score; //idx++; manned_label =1; if(index== 2 )motor_num++; if(index== 3 )tricycle_num++; } //if((index>= 4 && index<= 8 ) )//�˳���4-8 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 { result[b].info[idx].type=4;//���� result[b].info[idx].vehicle_body_detect_res.rect = vpt_result_[b].obj_results_[c].obj_rect; result[b].info[idx].vehicle_body_detect_res.score = score; manned_label =1; //idx++; body_idx++; } //���˷��� if(manned_label ==1) { if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN) { LOG_DEBUG("1.manned ----------- "); sy_img lorry_img_data[1]; lorry_img_data[0].data_ = NULL; //�����dz������� sy_rect lorry_rect =result[b].info[idx].vehicle_body_detect_res.rect; uint32_t alignWidth = (lorry_rect.width_ + 127) / 128 * 128; uint32_t alignHeight = (lorry_rect.height_ + 15) / 16 * 16; ImageData cropImg; 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); lorry_img_data[0].w_ = alignWidth;//cropImg.width; lorry_img_data[0].h_ = alignHeight;//cropImg.height; //lorry_img_data[0].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(cropImg.data.get(), cropImg.size); //cropImg.data.get(); lorry_img_data[0].data_ = cropImg.data.get(); float scale_w = (float)lorry_rect.width_ / alignWidth;//��alignWidth��alignHeightӳ�䵽ԭsize float scale_h = (float)lorry_rect.height_ / alignHeight; //ͷ��SDK-------- LOG_DEBUG("hs_det_process_batch ----------- "); hs_det_result hst_result[1]; int res_status = hs_det_process_batch(tools->hs_handle, lorry_img_data, 1, hst_result); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): lorry_manned process failed. (ret = {})", res_status); return res_status; } LOG_DEBUG("end hs_det_process_batch ----------- "); int hs_num=hst_result[0].objcount;//ͷ���� if(hs_num>10) hs_num=10;//������ʱֻ���10��ͷ�� result[b].info[idx].manned_res.hs_count = hs_num; for(int i=0;i0) { if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) { //��ȡ��������ͼ�� vpd_img_data ����������˳����ԣ�----- LOG_DEBUG("1-2 vpd crop body_img----- "); int body_iter=car_body_num/MAX_BATCHSIZE; int body_remainder=car_body_num%MAX_BATCHSIZE; if(body_remainder!=0) body_iter+=1; sy_img **vpd_img_data = NULL; vpd_img_data = new sy_img*[body_iter]; for(int iter=0;iterPatchCropAndPaste(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); int iter=idx/MAX_BATCHSIZE; int index=idx%MAX_BATCHSIZE; vpd_img_data[iter][index].w_ = alignWidth;//cropImg.width; vpd_img_data[iter][index].h_ = alignHeight;//cropImg.height; 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(); scale_w[idx] = (float)vpd_rect[idx].width_ / alignWidth;//��alignWidth��alignHeightӳ�䵽ԭsize scale_h[idx] = (float)vpd_rect[idx].height_ / alignHeight; idx++; } } } LOG_DEBUG("end 1-2 vpd crop vpd_img_data----- "); //23�����Լ��(Ĭ��һ������ֻ�ܼ�⵽һ����ͷ���߳�β��һ������) LOG_DEBUG("1-2 vpd_process----- "); vpd_result vpd_result_temp[car_body_num]; vpd_result vpd_result_[car_body_num]; for(int b=0;bvpd_handle, vpd_img_data[iter], temp_batch, &vpd_result_temp[p_idx]); } else { temp_batch=MAX_BATCHSIZE; res_status=vpd_process(tools->vpd_handle, vpd_img_data[iter], temp_batch, &vpd_result_temp[p_idx]); } p_idx += temp_batch; } //����������ӳ�䵽��ͼ�� for(int b=0;b tools->param.vehicle_attribute_det_thresld) { if(index == 0 && head_rear==0)//��ͷ { result[b].info[c].vehicle_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; result[b].info[c].vehicle_detect_res.score = score; result[b].info[c].type = 0; head_num++; head_rear=1; } else if(index == 1 && head_rear==0)//��β { result[b].info[c].vehicle_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; result[b].info[c].vehicle_detect_res.score = score; result[b].info[c].type = 1; rear_num++; head_rear=1; } else if(index == 2 && win==0)//���� { result[b].info[c].vehicle_win_detect_res.rect = vpd_result_[body_idx].vpd_res[i].rect; result[b].info[c].vehicle_win_detect_res.score = score; win_num++; win=1; } //else if(index >=8 && index <=19)//������index=8~19��12�� else if(index >=3 && index <=14)//������index=3~14��12�� { result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].rect = vpd_result_[body_idx].vpd_res[i].rect; result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].confidence = vpd_result_[body_idx].vpd_res[i].confidence; //result[b].info[idx].vehicle_pendant_det_res.vpd_res[vpd12_idx].index = index-8; result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].index = index-3; //���ݸ�����Ϣ //if(index == 8 || index == 9 || index == 10 || index == 11|| index == 16|| index == 19)//8-˾�� ��9-������10-��ȫ����11-�����塢16-��绰��19-���� ��Ҫ�ж����ݸ��� if(index == 3 || index == 4 || index == 5 || index == 6|| index == 11|| index == 14)//3-˾�� ��4-������5-��ȫ����6-�����塢11-��绰��14-���� ��Ҫ�ж����ݸ��� { 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); result[b].info[c].vehicle_pendant_det_res.vpd_res[vpd12_idx].driver_copilot_info = driver_copilot_info; } vpd12_idx++;//12�೵���Եĸ��� } } }//end ������output result[b].info[c].vehicle_pendant_det_res.count = vpd12_idx; //12�೵���Եĸ��� body_idx++; } } } //delete if (vpd_img_data != NULL) { for(int iter=0;iter0) { //2.1 ��ȡ��ͷ����ͼ��batch�� head_img_data ���������ʶ�𡢳��Ƽ��ʶ�� LOG_DEBUG("head2.1 crop head_img----- "); sy_img head_img_data[head_num]; for(int b=0;bparam.vehicle_recg_config==SY_CONFIG_OPEN ||tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN ||tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { int head_idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;cPatchCropAndPaste(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); head_img_data[head_idx].w_ = alignWidth;//cropImg.width; head_img_data[head_idx].h_ = alignHeight;//cropImg.height; head_img_data_host[head_idx].w_ = alignWidth;//cropImg.width; head_img_data_host[head_idx].h_ = alignHeight;//cropImg.height; 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(); head_img_data[head_idx].data_ = car_cropImg[head_idx].data.get(); //car_cropImg[head_idx].data.get(); scale_w[head_idx] = (float)head_rect.width_/alignWidth; scale_h[head_idx] = (float)head_rect.height_/alignHeight; head_idx++; } } } if(head_idx != head_num) LOG_ERROR("error:head_idx != head_num"); } LOG_DEBUG("end head2.1 crop head_img----- "); //end for ��ȡ��ͷ--------- //2.2.VR����ʶ��---------------------------------------- //��MAX_BATCHSIZE���� if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("head2.2.vr process----- "); int vr_batch_size=head_num;// vr_result * vr_result_ = new vr_result[vr_batch_size]; int res_status = vr_batch(tools->vr_handle, head_img_data, vr_batch_size, vr_result_); if (SUCCESS != res_status) { LOG_ERROR("sy_va_va_batch_vd(error): vr_batch failed. (ret = {})", res_status); return res_status; } //output int head_idx=0; for(int b=0;b0) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_result_[head_idx].vehicle_brand, sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_result_[head_idx].vehicle_subbrand, sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_result_[head_idx].vehicle_issue_year, sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_result_[head_idx].vehicle_type, sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.freight_ton, vr_result_[head_idx].freight_ton, sizeof(char)*260); result[b].info[c].vehicle_recg_res.name_score = vr_result_[head_idx].name_score; result[b].info[c].vehicle_recg_res.index = vr_result_[head_idx].index; } head_idx++; } } } //release vr_result_ if (vr_result_ != NULL) { delete[] vr_result_; } LOG_DEBUG("head2.2.vr_batch end."); } //2.3.VP���Ƽ��ʶ������1and2stn_vp-------------------------------------------- //2.3.1.VF��ͷ�������������dz�ͷ����Ҫ�ѳ���������0 //��MAX_BATCHSIZE���� if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("head2.3.vp process & vf_head process----- "); int vp_batch_size = head_num;// if(vp_batch_size>0) { //��ʼ����ͷ���� float ** fea=new float*[vp_batch_size]; for (int b = 0; b < vp_batch_size; b++) { fea[b]=new float[FEATURESIZE]; memset(fea[b],0,sizeof(float)*FEATURESIZE); } //��ʼ�����ƽ���ṹ�� vplates_result *vp_result = new vplates_result[vp_batch_size]; //5.���Ƽ��ʶ�� res_status=vpdr_batch(tools->vp_handle, head_img_data, vp_batch_size, vp_result); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vpdr process failed. (ret = {})", res_status); return res_status; } //8-1��ͷ������������λ����0 if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { LOG_DEBUG("head2.3.1 vf head process---------- "); //����λ����0 for(int idx=0;idx max_score && vp_result[idx].vehicle_plate_infos[m].num_score!=0) { max_score = vp_result[idx].vehicle_plate_infos[m].detect_score; max_index = m; } } if (vp_result[idx].count>0 && max_index != -1 )//��⵽���� { int left = vp_result[idx].vehicle_plate_infos[max_index].rect.left_; int top = vp_result[idx].vehicle_plate_infos[max_index].rect.top_; int width = vp_result[idx].vehicle_plate_infos[max_index].rect.width_; int height = vp_result[idx].vehicle_plate_infos[max_index].rect.height_; int w=head_img_data_host[idx].w_; int h=head_img_data_host[idx].h_; for(int jj=top;jjvf_head_handle, head_img_data, vp_batch_size, fea); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vf head process failed. (ret = {})", res_status); return res_status; } } //output int head_idx=0;//�������� for(int b=0;b max_score && vp_result[head_idx].vehicle_plate_infos[m].num_score!=0) { max_score = vp_result[head_idx].vehicle_plate_infos[m].detect_score; max_index = m; } } if (vp_result[head_idx].count==0 || max_index == -1 )//û��⵽���� { for(int p=0;p 0 && space_char_num < PLATENUM) { info_c.vehicle_plate_det_recg_res.stain_vp_result.type = 2; info_c.vehicle_plate_det_recg_res.stain_vp_result.score = info_c.vehicle_plate_det_recg_res.detect_score; } } //20201201wh���������ӳ�����Ϣ for(int p=0;p win_rect.left_ && vp_rect.top_ < win_rect.top_+win_rect.height_ && vp_rect.top_ + vp_rect.height_ > win_rect.top_ ) { info_c.vehicle_plate_det_recg_res.special_type = 1;//��ʱ����//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. } //2.��ɫ˫�㳵�ƣ������ڳ�ͷ����һ��Ϊ���ٳ������� else if(info_c.vehicle_plate_det_recg_res.type == 4) { info_c.vehicle_plate_det_recg_res.special_type = 2;//���ٳ���//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. } else { info_c.vehicle_plate_det_recg_res.special_type = 0;//���泵�� } } //��ͷ������� if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { memcpy(info_c.vehicle_fea_res.feature,fea[head_idx],sizeof(float)*FEATURESIZE); } head_idx++; } } }//end output //release vp_result if (vp_result != NULL) { delete[] vp_result; vp_result = NULL; } //release fea if(fea!= NULL) { for (int b = 0; b < vp_batch_size; b++) { if(fea[b]!= NULL){ delete[] fea[b]; fea[b]= NULL; } } delete[] fea; fea = NULL; } LOG_DEBUG("end head2.3 vp process & vf_head process----- "); } }//end head 2.3 VP���Ƽ��ʶ��----------------------- //delete------ for(int b=0;b0)//��⵽��β { //��ȡ��β����ͼ��batch�� rear_img_data ���������ʶ�𡢳��Ƽ��ʶ�𡢳����� LOG_DEBUG("rear 3.1 crop rear_img----- "); sy_img rear_img_data[rear_num]; for(int b=0;bparam.vehicle_recg_config==SY_CONFIG_OPEN ||tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN ||tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { int rear_idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;cPatchCropAndPaste(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); rear_img_data[rear_idx].w_ = alignWidth;//cropImg.width; rear_img_data[rear_idx].h_ = alignHeight;//cropImg.height; //rear_img_data[rear_idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(rear_cropImg[rear_idx].data.get(), rear_cropImg[rear_idx].size); //cropImg.data.get(); rear_img_data[rear_idx].data_ = rear_cropImg[rear_idx].data.get(); scale_w[rear_idx] = (float)rear_rect.width_/alignWidth; scale_h[rear_idx] = (float)rear_rect.height_/alignHeight; rear_idx++; } } } if(rear_idx != rear_num) LOG_ERROR("error:rear_idx != head_num"); } LOG_DEBUG("end rear3.1 crop head_img----- "); //end for ��ȡ��β--------- //3.1.VR����ʶ��------------------------------��β����ʶ�������dz���---- //��MAX_BATCHSIZE���� if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("rear 3.2.vrr process----- "); int vrr_batch_size = rear_num;// //��ʼ������ṹ�� vr_result *vrr_result_= new vr_result[vrr_batch_size]; for(int i=0;ivrr_handle, rear_img_data, vrr_batch_size, vrr_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vrr process failed. (ret = {})", res_status); return res_status; } //output int rear_idx=0;//�������� for(int b=0;b0) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vrr_result_[rear_idx].vehicle_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vrr_result_[rear_idx].vehicle_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vrr_result_[rear_idx].vehicle_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vrr_result_[rear_idx].vehicle_type,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.freight_ton, vrr_result_[rear_idx].freight_ton,sizeof(char)*260); result[b].info[c].vehicle_recg_res.name_score = vrr_result_[rear_idx].name_score; result[b].info[c].vehicle_recg_res.index = vrr_result_[rear_idx].index; //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE + 9] = (float)vrr_result_[iter][index].index; //20201201wh���������ӳ���ɫ���� //result[b].info[c].vehicle_fea_res.feature[FEATURESIZE + 10] = (float)vrr_result_[iter][index].name_score; //20201201wh���������ӳ���ɫ���� } rear_idx++; } } } //release vrr_result_ if (vrr_result_ != NULL) { delete[] vrr_result_; } LOG_DEBUG("end rear 3.2.vrr process----- "); } //end for 4.VR����ʶ��---------------------------------------- //3.3.VF��������-----------------------------��β���������dz���------------- //��MAX_BATCHSIZE���� if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN) { LOG_DEBUG("rear 3.3 vf process---------- "); int vf_rear_batch_size=rear_num;//��ͷ����//�ɰ汾�dz���Ϊ���� float ** fea=NULL; if(vf_rear_batch_size>0)//�г� { //fea fea=new float*[vf_rear_batch_size]; for (int b = 0; b < vf_rear_batch_size; b++) { fea[b]=new float[FEATURESIZE]; memset(fea[b],0,sizeof(float)*FEATURESIZE); } //Process res_status=vf_rear_feature_batch(tools->vf_rear_handle, rear_img_data, vf_rear_batch_size, fea); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vf rear process failed. (ret = {})", res_status); return res_status; } } //output int rear_idx=0; for(int b=0;b0)// { //fea if(fea!= NULL) { for (int b = 0; b < vf_rear_batch_size; b++) { if(fea[b]!= NULL){ delete[] fea[b]; } } delete[] fea; } } LOG_DEBUG("end rear 3.3.vf process---------- "); } //end rear3.3.VF��������----------------------------------------- //3.4.��βVP���Ƽ��ʶ��-------------------------------------------- if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("rear 3.4.vp process----- "); int vp_batch_size = rear_num;// //��ʼ������ṹ�� vplates_result *vp_result = new vplates_result[vp_batch_size]; //Process res_status=vpdr_batch(tools->vp_handle, rear_img_data, vp_batch_size, vp_result); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vpdr(error): vpdr process failed. (ret = {})", res_status); return res_status; } //output int rear_idx=0; for(int b=0;b max_score) { max_score = vp_result[rear_idx].vehicle_plate_infos[m].detect_score; max_index = m; } } if (vp_result[rear_idx].count==0 || vp_result[rear_idx].vehicle_plate_infos[max_index].rect.left_ == -1 )//û��⵽���� { for(int p=0;p 0 && space_char_num < PLATENUM) { info_c.vehicle_plate_det_recg_res.stain_vp_result.type = 2; info_c.vehicle_plate_det_recg_res.stain_vp_result.score = info_c.vehicle_plate_det_recg_res.detect_score; } } for(int p=0;p win_rect.left_ && vp_rect.top_ < win_rect.top_+win_rect.height_ && vp_rect.top_ + vp_rect.height_ > win_rect.top_ ) { info_c.vehicle_plate_det_recg_res.special_type = 1;//��ʱ����//���泵�ơ���ʱ���ơ����ٳ��ơ�0-common,1-temporary_license_plate,2-low_speed_license_plate. } else { info_c.vehicle_plate_det_recg_res.special_type = 0;//���泵�� } } rear_idx++; } } } //release vp_result if (vp_result != NULL) { delete[] vp_result; vp_result = NULL; } LOG_DEBUG("end rear 3.4.vp process----- "); } //end for 3.4.VP���Ƽ��ʶ��----------------------- } if(car_body_num>0) { LOG_DEBUG("body4.1 crop body_img----- "); sy_img body_img_data[car_body_num]; for(int b=0;bparam.vehicle_color_config==SY_CONFIG_OPEN || tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN) { int idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;cPatchCropAndPaste(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); body_img_data[idx].w_ = alignWidth;//cropImg.width; body_img_data[idx].h_ = alignHeight;//cropImg.height; //body_img_data[idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(body_cropImg[idx].data.get(), body_cropImg[idx].size); //cropImg.data.get(); body_img_data[idx].data_ = body_cropImg[idx].data.get(); //cropImg.data.get(); idx++; } } } } LOG_DEBUG("end body4.1 crop body_img----- "); if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) { LOG_DEBUG("body4.2 vcolor process----- "); int vc_batch_size=car_body_num;// vc_result *vc_result_= new vc_result[vc_batch_size]; //process res_status=vc_batch(tools->vc_handle, body_img_data, vc_batch_size, vc_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vc process failed. (ret = {})", res_status); return res_status; } //output int car_body_idx=0; for(int b=0;b= tools->param.vc_thresld && (vc_result_[car_body_idx].index>=0 && vc_result_[car_body_idx].index<13)) { result[b].info[c].vehicle_color_res.index = vc_result_[car_body_idx].index; result[b].info[c].vehicle_color_res.score = vc_result_[car_body_idx].score; } car_body_idx++; } } } //release if (vc_result_ != NULL) { delete[] vc_result_; vc_result_ = NULL; } LOG_DEBUG("end body4.2.vcolor process----- "); } //end for body4.2 VColor����ɫʶ��--------------------------- //4-3����ʶ�𲹳�ʶ��---VERSION_WUXI �����汾���� if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN && VERSION_WUXI ) { vr_supplement_wuxi(handle, body_img_data, batch_size, car_body_num, result); } //4-3����ʶ�𲹳�ʶ��--�������汾���� if(!VERSION_WUXI && tools->param.vehicle_recg_config==SY_CONFIG_OPEN && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN ) { vr_supplement(handle, body_img_data, batch_size, car_body_num, result); } //end for ����ʶ�����복logo�����ϲ���--------------------------- } if (tools->param.vehicle_feature_config == SY_CONFIG_OPEN || tools->param.vehicle_illegal_config == SY_CONFIG_OPEN) { LOG_DEBUG("7.head win vf+vid ----- "); for(int b=0;bPatchCropAndPaste(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); win_img_data[0].w_ = alignWidth;//cropImg.width; win_img_data[0].h_ = alignHeight;//cropImg.height; //win_img_data[0].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(cropImg.data.get(), cropImg.size); //cropImg.data.get(); win_img_data[0].data_ = cropImg.data.get(); //��ͷ�������� if (tools->param.vehicle_feature_config == SY_CONFIG_OPEN) { float ** win_feature=new float*[1]; win_feature[0]=new float[FEATURESIZE]; res_status = vf_win_feature_batch(tools->vf_win_handle, win_img_data, 1, win_feature); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vf_win_feature_batch failed. (ret = {})", res_status); return res_status; } //output memcpy(result[b].info[c].vehicle_fea_res.feature+FEATURESIZE,win_feature[0],sizeof(float)*FEATURESIZE); //delete if(win_feature[0]!= NULL) { delete[] win_feature[0]; win_feature[0]=NULL; } if(win_feature!= NULL) { delete[] win_feature; win_feature=NULL; } } //��ͷ������Υ�� if (tools->param.vehicle_illegal_config == SY_CONFIG_OPEN) { vid_result vid_result_[1]; res_status=vid_process(tools->vid_handle, win_img_data, 1, vid_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vid process failed. (ret = {})", res_status); return res_status; } //output result[b].info[c].vehicle_illegal_det_res.driver.person.status = vid_result_[0].driver.person.status; result[b].info[c].vehicle_illegal_det_res.driver.person.confidence = vid_result_[0].driver.person.confidence; result[b].info[c].vehicle_illegal_det_res.driver.belt.status = vid_result_[0].driver.belt.status; result[b].info[c].vehicle_illegal_det_res.driver.belt.confidence = vid_result_[0].driver.belt.confidence; result[b].info[c].vehicle_illegal_det_res.driver.smoke.status = vid_result_[0].driver.smoke.status; result[b].info[c].vehicle_illegal_det_res.driver.smoke.confidence = vid_result_[0].driver.smoke.confidence; result[b].info[c].vehicle_illegal_det_res.driver.phone.status = vid_result_[0].driver.phone.status; result[b].info[c].vehicle_illegal_det_res.driver.phone.confidence = vid_result_[0].driver.phone.confidence; result[b].info[c].vehicle_illegal_det_res.driver.call.status = vid_result_[0].driver.call.status; result[b].info[c].vehicle_illegal_det_res.driver.call.confidence = vid_result_[0].driver.call.confidence; result[b].info[c].vehicle_illegal_det_res.copilot.person.status = vid_result_[0].copilot.person.status; result[b].info[c].vehicle_illegal_det_res.copilot.person.confidence = vid_result_[0].copilot.person.confidence; result[b].info[c].vehicle_illegal_det_res.copilot.belt.status = vid_result_[0].copilot.belt.status; result[b].info[c].vehicle_illegal_det_res.copilot.belt.confidence = vid_result_[0].copilot.belt.confidence; result[b].info[c].vehicle_illegal_det_res.copilot.smoke.status = vid_result_[0].copilot.smoke.status; result[b].info[c].vehicle_illegal_det_res.copilot.smoke.confidence = vid_result_[0].copilot.smoke.confidence; result[b].info[c].vehicle_illegal_det_res.copilot.phone.status = vid_result_[0].copilot.phone.status; result[b].info[c].vehicle_illegal_det_res.copilot.phone.confidence = vid_result_[0].copilot.phone.confidence; result[b].info[c].vehicle_illegal_det_res.copilot.call.status = vid_result_[0].copilot.call.status; result[b].info[c].vehicle_illegal_det_res.copilot.call.confidence = vid_result_[0].copilot.call.confidence; } } } } LOG_DEBUG("end 7.head win vf+vid ----- "); } LOG_DEBUG("process_vidresult_atlas"); process_vidresult_atlas(handle, batch_size, result); LOG_DEBUG("motor_num:{}", motor_num); if(motor_num>0) { //double t22 = msecond(); LOG_DEBUG("start mta-step2:motor_img_data."); sy_img motor_img_data[motor_num]; for(int b=0;bparam.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) { int motor_idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;cPatchCropAndPaste(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); motor_img_data[motor_idx].w_ = alignWidth;//cropImg.width; motor_img_data[motor_idx].h_ = alignHeight;//cropImg.height; //motor_img_data[motor_idx].data_ = (uint8_t*)Utils::CopyDataDeviceToLocal(motor_cropImg[motor_idx].data.get(), motor_cropImg[motor_idx].size); //cropImg.data.get(); motor_img_data[motor_idx].data_ = motor_cropImg[motor_idx].data.get(); scale_w[motor_idx] = (float)motor_rect.width_/alignWidth; scale_h[motor_idx] = (float)motor_rect.height_/alignHeight; motor_idx++; } } } if(motor_idx != motor_num) LOG_ERROR("error:motor_idx != motor_num"); } LOG_DEBUG("end crop motor_img_data----- "); //Ħ�г��Ƿ��ͷ������ if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN) { LOG_DEBUG("start motor hcp."); int motor_batch_size = motor_num; hcp_analysis_result * hcp_result = new hcp_analysis_result[motor_batch_size]; int ret = hcp_batch(tools->hcp_handle, motor_img_data, motor_batch_size, hcp_result); //output Ħ�г���ʻ�˴�ͷ�� int motor_idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;c0) { LOG_DEBUG("start :tricycle_img_data."); sy_img tricycle_img_data[tricycle_batch_size]; for(int b=0;b data_tricycle[tricycle_batch_size]; ImageData tricycle_cropImg[tricycle_batch_size];//�� tricycle_img_data ��Ӧ float scale_w[tricycle_batch_size]; float scale_h[tricycle_batch_size]; if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { int tricycle_idx=0; for (int b = 0; b < batch_size; b++) { for(int c=0;cPatchCropAndPaste(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); tricycle_img_data[tricycle_idx].w_ = alignWidth;//cropImg.width; tricycle_img_data[tricycle_idx].h_ = alignHeight;//cropImg.height; tricycle_img_data[tricycle_idx].data_ = tricycle_cropImg[tricycle_idx].data.get(); //tricycle_cropImg[tricycle_idx].data.get(); scale_w[tricycle_idx] = (float)tricycle_rect.width_/alignWidth; scale_h[tricycle_idx] = (float)tricycle_rect.height_/alignHeight; tricycle_idx++; } } } if(tricycle_idx != tricycle_batch_size) LOG_ERROR("error:tricycle_idx != tricycle_batch_size"); } LOG_DEBUG("end crop tricycle_img_data----- "); //5.VP���Ƽ��ʶ��-------------------------------------------- //��MAX_BATCHSIZE���� if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { LOG_DEBUG("tricycle 5.vp process----- "); int vp_batch_size=tricycle_batch_size;// //��ʼ������ṹ�� vplates_result *vp_result= new vplates_result[vp_batch_size]; //Process res_status=vpdr_batch(tools->vp_handle, tricycle_img_data, vp_batch_size, vp_result); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vpdr(error): vpdr process failed. (ret = {})", res_status); return res_status; } //output int tricycle_idx=0; for(int b=0;b max_score) { max_score = vp_result[tricycle_idx].vehicle_plate_infos[m].detect_score; max_index = m; } } if (vp_result[tricycle_idx].count==0 || max_index == -1 )//û��⵽���� { info_c.vehicle_plate_det_recg_res.rect.left_ = info_c.vehicle_body_detect_res.rect.left_; info_c.vehicle_plate_det_recg_res.rect.top_ = info_c.vehicle_body_detect_res.rect.top_; for(int p=0;p 0 && space_char_num < PLATENUM) { info_c.vehicle_plate_det_recg_res.stain_vp_result.type = 2; info_c.vehicle_plate_det_recg_res.stain_vp_result.score = info_c.vehicle_plate_det_recg_res.detect_score; } } } tricycle_idx++; } } } //release vp_result if (vp_result != NULL) { delete[] vp_result; vp_result = NULL; } LOG_DEBUG("end tricycle 5.vp process----- "); } //end for 5.VP���Ƽ��ʶ��----------------------- // if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) // { // LOG_DEBUG("start tricycle hcp."); // hcp_analysis_result * hcp_result = new hcp_analysis_result[tricycle_batch_size]; // int ret = hcp_batch(tools->hcp_handle, tricycle_img_data, tricycle_batch_size, hcp_result); // //output Ħ�г���ʻ�˴�ͷ�� // int tricycle_idx=0; // for (int b = 0; b < batch_size; b++) // { // for(int c=0;cparam.vehicle_feature_config==SY_CONFIG_OPEN)//VF { vf_head_similarity = vf_head_compute_similarity( Afea, Bfea, FEATURESIZE); vf_win_similarity = vf_win_compute_similarity( Afea+FEATURESIZE, Bfea+FEATURESIZE, FEATURESIZE); vf_similarity = 0.5*vf_head_similarity +0.5*vf_win_similarity ; } similarity = vf_similarity; if(1) { float score_vp = 0; if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { int count =0; for (int m = 0; m < PLATENUM; m++)//6�������ַ���ͬ���㳵����ͬ��������1���� { if(Afea[FEATURESIZE*2+m] == Bfea[FEATURESIZE*2+m] && Afea[FEATURESIZE*2+m] !=0) count++; } if(count >=7 ) { score_vp = 1; } else if(count ==6 ) { score_vp = 0.9; } else if(count ==5 ) { score_vp = 0.7; } else { score_vp = 0.1; } float scale_feat = 0.500; float scale_vp = 0.500; if(score_vp >0.9) { scale_feat = 0.200; scale_vp = 0.800; } else if(score_vp >0.8) { scale_feat = 0.500; scale_vp = 0.500; } float similarity1 = vf_similarity*scale_feat + score_vp*scale_vp; if(similarity1 >=0.75) { similarity = similarity1; return similarity; } } } return similarity; } void va_release(void ** handle) { va_handle *tools=(va_handle *)*handle; //1.������� if(tools->param.vehicle_detect_config==SY_CONFIG_OPEN) { vpt_release(&(tools->vpt_handle)); } //6.VPD�����Լ�� if(tools->param.vehicle_pendant_det_config==SY_CONFIG_OPEN) { vpd_release(&(tools->vpd_handle)); } //vc if(tools->param.vehicle_color_config==SY_CONFIG_OPEN) { vc_release(&(tools->vc_handle)); } //4.VR����ʶ�� if(tools->param.vehicle_recg_config==SY_CONFIG_OPEN) { vr_release(&(tools->vr_handle)); vrr_release(&(tools->vrr_handle));//��β���� if(VERSION_WUXI) { vr_vehicle_type_15cls_release(&(tools->vr_vr15cls_handle));//����15���� if(VR_WUXI_LOGO) { vlogodr_release(&(tools->vr_logo_dr_handle));//��logo���ʶ�� } } if(!VERSION_WUXI && tools->param.vehicle_recg_supplement_config==SY_CONFIG_OPEN)//����ʶ�𲹳�ʶ�� { vlogodr_release(&(tools->vr_logo_dr_handle));//��logo���ʶ�� vr_vehicle_type_15cls_release(&(tools->vr_vr15cls_handle));//����15���� vr_vehicle_type_3885cls_release(&(tools->vr_vr3885cls_handle));//���������� } } //5.VP���Ƽ��ʶ�� if(tools->param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN) { vpdr_release(&(tools->vp_handle)); } //7.VID��Υ�� if(tools->param.vehicle_illegal_config==SY_CONFIG_OPEN)//VID { vid_release(&(tools->vid_handle)); } //8.VF�������� if(tools->param.vehicle_feature_config==SY_CONFIG_OPEN)//VF { vf_head_release(&(tools->vf_head_handle)); vf_win_release(&(tools->vf_win_handle)); vf_rear_release(&(tools->vf_rear_handle));//��β������ } //11.mta��� if(tools->param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN)//MTA { hcp_release(&(tools->hcp_handle)); } if(tools->param.vehicle_manned_config==SY_CONFIG_OPEN)//MTA { hs_det_release(&(tools->hs_handle)); } //delet dvpp aclrtDestroyContext(tools->ctx); aclrtResetDevice(tools->param.gpuid); //aclFinalize(); if (tools) { delete tools; tools = NULL; } } int process_vidresult_atlas(void * handle, int batch_size, va_result *result) { for (int b = 0; b < batch_size; b++) { for(int c=0;c0.8 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) { //���ݣ���Υ��ʶ���ˡ������������� if(cur_result.driver.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1) { driverperson = true; 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; } //���ݣ���Υ��ʶ���ˡ��������Ǹ��� if(cur_result.copilot.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2) { copilotperson = true; 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; } } } //������ for(int p=0;p0.85�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 if((cur_result.driver.call.status==ILLEGAL && phoneyc <= pyc_driver + 10 && score>0.85) || (phoneyc <= pyc_driver + 10 && score > 0.9)) { //str_drivercall ="CALL"; cur_result.driver.call.status = ILLEGAL;//CALL } else { cur_result.driver.call.status = lEGAL;//�Ϸ� } //usephone //��Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 if((cur_result.driver.phone.status==ILLEGAL && phoneyc > pyc_driver + 10 && score>0.75) || (phoneyc > pyc_driver + 10 && score > 0.9)) //if((cur_result.driver.call.status == ILLEGAL && phoneyc > pyc_driver + 10 && score>0.0) || (phoneyc > pyc_driver + 10 && score > 0.9)) { //str_driverphone ="USEPHONE"; cur_result.driver.phone.status = ILLEGAL; } else { cur_result.driver.phone.status = lEGAL;//�Ϸ� } }*/ //belt //�����Լ�⵽��ȫ���������ݲ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) driverbelt = true; /*//smoke //�����Լ�⵽���� ��Υ���ж�Υ����������ŶȽϸ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.driver.smoke.status==ILLEGAL || score>0.8)) //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.driver.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) { //str_driversmoke ="SMOKE"; cur_result.driver.smoke.status = ILLEGAL; } else { cur_result.driver.smoke.status = lEGAL;//�Ϸ� }*/ } if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2)//�������� { //�����Լ�⵽�ֻ� /*if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) { //�ж��ֻ��Ƿ��ڸ��ݲ� //call //ͬ���ݣ���Υ���ж�Ϊ��绰,���������Ŷ�>0.85;�������ֻ�λ�ÿ��ϡ���Υ���ж�Ϊ���������������ŶȽϸ� if((cur_result.copilot.call.status==ILLEGAL && phoneyc <= pyc_copilot + 10 && score>0.85) || (phoneyc <= pyc_copilot + 10 && score > 0.9)) { //str_copilotcall ="CALL"; cur_result.copilot.call.status = ILLEGAL; } else { cur_result.copilot.call.status = lEGAL;//�Ϸ� } //usephone //ͬ���ݣ���Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75;�������ֻ�λ�ÿ��¡���Υ���ж�Ϊ���������������ŶȽϸ� if((cur_result.copilot.phone.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.75) || (phoneyc > pyc_copilot + 10 && score > 0.9)) //if((cur_result.copilot.call.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.0) || (phoneyc > pyc_copilot + 10 && score > 0.9)) { //str_copilotphone ="USEPHONE"; cur_result.copilot.phone.status = ILLEGAL; } else { cur_result.copilot.phone.status = lEGAL;//�Ϸ� } }*/ //belt //�����Լ�⵽��ȫ�����ڸ��ݲ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) copilotbelt = true; /*//smoke //�����Լ�⵽���� ��Υ���ж�Υ����������ŶȽϸ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.copilot.smoke.status==ILLEGAL || score>0.8)) //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.copilot.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) { //str_copilotsmoke ="SMOKE"; cur_result.copilot.smoke.status = ILLEGAL; } else { cur_result.copilot.smoke.status = lEGAL;//�Ϸ� }*/ } } //����û��------------------- if(!driverperson) { //str_driverperson ="NOBODY"; cur_result.driver.person.status = NOBODY; } else { cur_result.driver.person.status = SOMEBODY; } if(!copilotperson) { //str_copilotperson ="NOBODY"; cur_result.copilot.person.status = NOBODY; } else { cur_result.copilot.person.status = SOMEBODY; } //��ȫ��--------------------------- //�������ˡ�������δ��⵽��ȫ������Υ���ж�Ϊδϵ��ȫ�� if(!driverbelt && driverperson && cur_result.driver.belt.status==ILLEGAL) { //str_driverbelt ="NOSAFETYBELT"; cur_result.driver.belt.status = ILLEGAL; } else { cur_result.driver.belt.status = lEGAL; } //�������ˡ�������δ��⵽��ȫ������Υ���ж�Ϊδϵ��ȫ�� if(!copilotbelt && copilotperson && cur_result.copilot.belt.status==ILLEGAL) { cur_result.copilot.belt.status = ILLEGAL; } else { cur_result.copilot.belt.status = lEGAL; } } } return SUCCESS; } int process_vidresult(void * handle, int batch_size, va_result *result) { for (int b = 0; b < batch_size; b++) { for(int c=0;c0.8 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) { //���ݣ���Υ��ʶ���ˡ������������� if(cur_result.driver.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==1) { driverperson = true; 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; } //���ݣ���Υ��ʶ���ˡ��������Ǹ��� if(cur_result.copilot.person.status==SOMEBODY && result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2) { copilotperson = true; 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; } } } //������ for(int p=0;p0.85�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 if((cur_result.driver.call.status==ILLEGAL && phoneyc <= pyc_driver + 10 && score>0.85) || (phoneyc <= pyc_driver + 10 && score > 0.9)) { //str_drivercall ="CALL"; cur_result.driver.call.status = ILLEGAL;//CALL } else { cur_result.driver.call.status = lEGAL;//�Ϸ� } //usephone //��Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75�� �������ֻ�λ�ÿ���,��Υ���ж�Ϊ���������������Ŷ�>0.9 if((cur_result.driver.phone.status==ILLEGAL && phoneyc > pyc_driver + 10 && score>0.75) || (phoneyc > pyc_driver + 10 && score > 0.9)) //if((cur_result.driver.call.status == ILLEGAL && phoneyc > pyc_driver + 10 && score>0.0) || (phoneyc > pyc_driver + 10 && score > 0.9)) { //str_driverphone ="USEPHONE"; cur_result.driver.phone.status = ILLEGAL; } else { cur_result.driver.phone.status = lEGAL;//�Ϸ� } } //belt //�����Լ�⵽��ȫ���������ݲ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) driverbelt = true; //smoke //�����Լ�⵽���� ��Υ���ж�Υ����������ŶȽϸ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.driver.smoke.status==ILLEGAL || score>0.8)) //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.driver.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) { //str_driversmoke ="SMOKE"; cur_result.driver.smoke.status = ILLEGAL; } else { cur_result.driver.smoke.status = lEGAL;//�Ϸ� } } if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info==2)//�������� { //�����Լ�⵽�ֻ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==8) { //�ж��ֻ��Ƿ��ڸ��ݲ� //call //ͬ���ݣ���Υ���ж�Ϊ��绰,���������Ŷ�>0.85;�������ֻ�λ�ÿ��ϡ���Υ���ж�Ϊ���������������ŶȽϸ� if((cur_result.copilot.call.status==ILLEGAL && phoneyc <= pyc_copilot + 10 && score>0.85) || (phoneyc <= pyc_copilot + 10 && score > 0.9)) { //str_copilotcall ="CALL"; cur_result.copilot.call.status = ILLEGAL; } else { cur_result.copilot.call.status = lEGAL;//�Ϸ� } //usephone //ͬ���ݣ���Υ���ж�Ϊ���ֻ�(0308������绰�ж�),���������Ŷ�>0.75;�������ֻ�λ�ÿ��¡���Υ���ж�Ϊ���������������ŶȽϸ� if((cur_result.copilot.phone.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.75) || (phoneyc > pyc_copilot + 10 && score > 0.9)) //if((cur_result.copilot.call.status==ILLEGAL && phoneyc > pyc_copilot + 10 && score>0.0) || (phoneyc > pyc_copilot + 10 && score > 0.9)) { //str_copilotphone ="USEPHONE"; cur_result.copilot.phone.status = ILLEGAL; } else { cur_result.copilot.phone.status = lEGAL;//�Ϸ� } } //belt //�����Լ�⵽��ȫ�����ڸ��ݲ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==2) copilotbelt = true; //smoke //�����Լ�⵽���� ��Υ���ж�Υ����������ŶȽϸ� if(result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index ==11 && (cur_result.copilot.smoke.status==ILLEGAL || score>0.8)) //if(vpdresult[b].vpd_res[k].index ==11 && cur_result.copilot.smoke.status==ILLEGAL && vpdresult[b].vpd_res[k].confidence>0.8) { //str_copilotsmoke ="SMOKE"; cur_result.copilot.smoke.status = ILLEGAL; } else { cur_result.copilot.smoke.status = lEGAL;//�Ϸ� } } } //����û��------------------- if(!driverperson) { //str_driverperson ="NOBODY"; cur_result.driver.person.status = NOBODY; } else { cur_result.driver.person.status = SOMEBODY; } if(!copilotperson) { //str_copilotperson ="NOBODY"; cur_result.copilot.person.status = NOBODY; } else { cur_result.copilot.person.status = SOMEBODY; } //��ȫ��--------------------------- //�������ˡ�������δ��⵽��ȫ������Υ���ж�Ϊδϵ��ȫ�� if(!driverbelt && driverperson && cur_result.driver.belt.status==ILLEGAL) { //str_driverbelt ="NOSAFETYBELT"; cur_result.driver.belt.status = ILLEGAL; } else { cur_result.driver.belt.status = lEGAL; } //�������ˡ�������δ��⵽��ȫ������Υ���ж�Ϊδϵ��ȫ�� if(!copilotbelt && copilotperson && cur_result.copilot.belt.status==ILLEGAL) { cur_result.copilot.belt.status = ILLEGAL; } else { cur_result.copilot.belt.status = lEGAL; } } } return SUCCESS; } //�ж����������ݻ��Ǹ��ݣ�0-��ʼֵ(���������ݸ���)��1-���ݣ�2-���� int rect_driver_copilot(sy_rect vpd_rect, sy_rect body_rect) { int driver_copilot_info = 0; int vpd_middle_x = vpd_rect.left_+vpd_rect.width_/2; int body_middle_x = body_rect.left_+body_rect.width_/2; if(vpd_middle_x < body_middle_x) driver_copilot_info = 2; else if(vpd_middle_x > body_middle_x) driver_copilot_info = 1; return driver_copilot_info; } float IOU(sy_rect rect1, sy_rect rect2) { float xx1,yy1,xx2,yy2,w,h,wh,o; xx1 = max(rect1.left_, rect2.left_); yy1 = max(rect1.top_, rect2.top_); xx2 = min(rect1.left_+ rect1.width_ , rect2.left_+ rect2.width_ ); yy2 = min(rect1.top_+ rect1.height_ , rect2.top_+ rect2.height_ ); w = max (float(0),(xx2-xx1)); h = max (float(0),(yy2-yy1)); wh =w*h; o = wh / (rect1.width_ *rect1.height_ + rect2.width_ *rect2.height_ -wh ); return o; } //�ж�rect1�Ƿ���rect2���棬1���ڣ�0 �Dz��� int in_rect(sy_rect rect1, sy_rect rect2) { if(rect1.left_ - rect2.left_ >=-10 && rect1.top_ - rect2.top_ >=-10 && rect2.left_ + rect2.width_ - rect1.left_ - rect1.width_ >=-10 && rect2.top_ + rect2.height_ - rect1.top_ - rect1.height_ >=0) return 1; else return 0; } //�����Խ������,�ⲿ�����ڴ� void process_vpdresult(sy_rect body_rect, vpd_result * src, vpd_result * dest) { //���˵����������Ŀ�꣬���Ψһ�ij�ͷ��β�����Ψһ�ij���,���Ψһ�ij�logo float max_head_rear_score=0; int head_rear_idx = -1; float max_win_score=0; int win_idx = -1; float max_logo_score=0; int logo_idx = -1; int idx=0; int count = src[0].count; for(int c=0;c 0.3 && score > max_head_rear_score) { if(head_rear_idx==-1)//�½� { dest[0].vpd_res[idx] = src[0].vpd_res[c]; head_rear_idx = idx; max_head_rear_score = score; idx++; } else//���� { dest[0].vpd_res[head_rear_idx] = src[0].vpd_res[c]; max_head_rear_score = score; } } } else if(index ==2 )//���� { int label = in_rect( src[0].vpd_res[c].rect, body_rect); if(iou > 0 && label && score > max_win_score) { if(win_idx==-1)//�½� { dest[0].vpd_res[idx] = src[0].vpd_res[c]; win_idx = idx; max_win_score = score; idx++; } else//���� { dest[0].vpd_res[win_idx] = src[0].vpd_res[c]; max_win_score = score; } } } else if(index ==24 )//��logo { int label = in_rect( src[0].vpd_res[c].rect, body_rect); if(iou > 0 && label && score > max_logo_score) { if(logo_idx==-1)//�½� { dest[0].vpd_res[idx] = src[0].vpd_res[c]; logo_idx = idx; max_logo_score = score; idx++; } else//���� { dest[0].vpd_res[logo_idx] = src[0].vpd_res[c]; max_logo_score = score; } } } else//��������ȫ������ { if(iou > 0) { dest[0].vpd_res[idx] = src[0].vpd_res[c]; idx++; } } } dest[0].count =idx; } sy_rect rect_extend(sy_rect obj_rect,int img_w,int img_h,float scale) { sy_rect obj_rect_extend; int right = obj_rect.left_ + obj_rect.width_; int bottom = obj_rect.top_ + obj_rect.height_; int offset = obj_rect.width_ * scale; obj_rect_extend.left_ = obj_rect.left_ - offset; if(obj_rect_extend.left_ < 0) obj_rect_extend.left_ = 0; obj_rect_extend.top_ = obj_rect.top_ - offset; if(obj_rect_extend.top_ < 0) obj_rect_extend.top_ = 0; right += offset; if(right > img_w) right = img_w; bottom += offset; if(bottom > img_h) bottom = img_h; obj_rect_extend.width_ = right - obj_rect_extend.left_; obj_rect_extend.height_ = bottom - obj_rect_extend.top_; return obj_rect_extend; } //======================= vpt ����nms����============================// bool CompareBBox(const vpt_obj_result & a, const vpt_obj_result & b) { return a.obj_score > b.obj_score; } bool CompareBBoxBest(const vpt_info_midd_temp & a, const vpt_info_midd_temp & b) { return a.dis < b.dis; } std::vector NonMaximumSuppression(std::vector& bboxes, const float& thresh, const char& methodType) {//WH:�Ǽ���ֵ����NMS���ϲ����ڡ�thresh�ǽ�����IOU����ֵ��methodType�Ǽ��㽻���ȵ����ַ�ʽ��P-Net��R-Net��u��O-Net�Ƿ�ʽm std::vector bboxes_nms; std::sort(bboxes.begin(), bboxes.end(), CompareBBox); int32_t select_idx = 0; int32_t num_bbox = static_cast(bboxes.size()); std::vector mask_merged(num_bbox, 0); bool all_merged = false; while (!all_merged) { while (select_idx < num_bbox && mask_merged[select_idx] == 1) select_idx++; if (select_idx == num_bbox) { all_merged = true; continue; } bboxes_nms.push_back(bboxes[select_idx]); mask_merged[select_idx] = 1; sy_rect select_bbox = bboxes[select_idx].obj_rect; float area1 = static_cast(select_bbox.width_ * select_bbox.height_); float x1 = static_cast(select_bbox.left_); float y1 = static_cast(select_bbox.top_); float x2 = static_cast(select_bbox.left_ + select_bbox.width_ ); float y2 = static_cast(select_bbox.top_ + select_bbox.height_); select_idx++; for (int32_t i = select_idx; i < num_bbox; i++) { if (mask_merged[i] == 1) continue; sy_rect& bbox_i = bboxes[i].obj_rect; float x = std::max(x1, static_cast(bbox_i.left_)); float y = std::max(y1, static_cast(bbox_i.top_)); float w = std::min(x2, static_cast(bbox_i.left_ + bbox_i.width_)) - x; float h = std::min(y2, static_cast(bbox_i.top_ + bbox_i.height_ )) - y; if (w <= 0 || h <= 0) continue; float area2 = static_cast(bbox_i.width_ * bbox_i.height_); float area_intersect = w * h; switch (methodType) { case 'u': if (static_cast(area_intersect) / (area1 + area2 - area_intersect) > thresh) mask_merged[i] = 1; break; case 'm': if (static_cast(area_intersect) / std::min(area1 , area2) > thresh) mask_merged[i] = 1; break; default: break; } } } mask_merged.clear(); return bboxes_nms; } int get_dis(sy_rect rect,int best_center_x,int best_center_y,int img_w,int img_h) { int dis_a =0; int a_center_x = rect.left_ + rect.width_/2; int a_center_y = rect.top_ + rect.height_/2; 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 if(a_center_y < best_center_y)//��������ĵ����ͷ��*1.2��Ȩֵ dis_a *= 1.2; //����,*1.2��Ȩֵ if(rect.left_<5 || img_w -(rect.left_+rect.width_)<10 || img_h -(rect.top_+rect.height_)<5) dis_a *= 1.2; return dis_a ; } //�˳���result���� //1.����persion��bike�������ij��������nms //2.�����汾��ֻ���topn int process_vptresult(sy_img *imgdata, int batch_size, vpt_result * vpt_result_) { int res =-1; //1.����person��bike�������ij�����nms for (int b = 0; b < batch_size; b++) { std::vector vpt_info_pb;//personhe bike vpt_info_pb.clear(); std::vector vpt_info_temp;//������� vpt_info_temp.clear(); int count = vpt_result_[b].obj_count_; for (int c = 0; c < count; c++) { int class_idx = vpt_result_[b].obj_results_[c].obj_index; if(class_idx == 0 || class_idx ==1 )//person bike����nms { vpt_info_pb.push_back(vpt_result_[b].obj_results_[c]); } else { vpt_info_temp.push_back(vpt_result_[b].obj_results_[c]); } } // vpt_info_temp �������nms���� //�Ǽ���ֵ���ƺϲ���ѡ�� std::vector bboxes_nms = NonMaximumSuppression(vpt_info_temp, 0.7, 'u'); //output int res_count = 0; for (int i = 0; i < vpt_info_pb.size(); i++)//personhe bike { vpt_result_[b].obj_results_[res_count]= vpt_info_pb[i]; res_count++; } for (int i = 0; i < bboxes_nms.size(); i++)//������� { vpt_result_[b].obj_results_[res_count]= bboxes_nms[i]; res_count++; } bboxes_nms.clear(); vpt_result_[b].obj_count_= res_count; } //2.�����汾��ֻ��topn���������Է��������Ե�Ŀ��������topnʱ����vpt�Ľ�����Ӵ��µ�˳������//WH20220308 if(VERSION_WUXI) { for (int b = 0; b < batch_size; b++) { int count = vpt_result_[b].obj_count_; if(count > VPT_TOPN) { int img_w = imgdata[b].w_; int img_h = imgdata[b].h_; int best_center_x = img_w/2;//��ͼ�����Ŀ������ĵ� int best_center_y = img_h*3/4; std::vector bboxes_topn; for(int c =0;ccount = 0; res_status = vlogodr_batch(tools->vr_logo_dr_handle, body_img_data, vr_logo_15cls_batch_size, vr_logo_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch(error): vlogodr_batch failed. (ret = {})", res_status); return res_status; } //output int car_body_idx=0; for(int b=0;b0) { int check_index=-1; check_index = logo_check_wuxi(result[b].info[c].vehicle_recg_res.vehicle_brand); if(check_index!=-1)//��ӳ�䵽�����ӳ�䵽������Ʒ�� { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_brand_array_wuxi[check_index],sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); //result[b].info[c].vehicle_recg_res.name_score = 0; //result[b].info[c].vehicle_recg_res.index = -1; } else//����ӳ�䵽���ÿ� { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; } } } if(result[b].info[c].type == 0 || result[b].info[c].type == 1 || result[b].info[c].type == 4)///��Ħ������ { int logo_count = vr_logo_result_[car_body_idx].count; if(logo_count>0) { int logo_index= vr_logo_result_[car_body_idx].vehicle_logo_infos[0].logo_brand_index; float logo_recg_score = vr_logo_result_[car_body_idx].vehicle_logo_infos[0].recg_score; char *logo_brand = vr_logo_result_[car_body_idx].vehicle_logo_infos[0].logo_brand;//����Ʒ�� if(logo_recg_score>0.8) { int logo_check_index=-1; logo_check_index = logo_check_wuxi(logo_brand); if(logo_check_index!=-1 && strcmp(vr_brand_array_wuxi[logo_check_index],result[b].info[c].vehicle_recg_res.vehicle_brand)!=0) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_brand_array_wuxi[logo_check_index],sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; result[b].info[c].vehicle_recg_res.index = -1; } else if(logo_check_index==-1) { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; } } } car_body_idx++; } } } //release vr_logo_result_ if (vr_logo_result_ != NULL) { delete[] vr_logo_result_; vr_logo_result_ = NULL; } }//end if(VR_WUXI_LOGO) //��ʼ������ṹ��vr_15cls_result_ vr_vehicle_type_15cls_result * vr_15cls_result_ = new vr_vehicle_type_15cls_result[vr_logo_15cls_batch_size]; memset(vr_15cls_result_,0,sizeof(vr_vehicle_type_15cls_result)*vr_logo_15cls_batch_size); LOG_DEBUG("vr_vehicle_type_15cls_batch"); res_status=vr_vehicle_type_15cls_batch(tools->vr_vr15cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_15cls_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch(error): vr_vehicle_type_15cls_batch failed. (ret = {})", res_status); return res_status; } //output int car_idx=0; for(int b=0;b VR_15CLS_THRE)//wh20200917������db����û�г��ͷ������Ϣ { memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); if(result[b].info[c].vehicle_recg_res.name_score>0) result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; else result[b].info[c].vehicle_recg_res.name_score = vr_15cls_score; } car_idx++; } } } //delete if (vr_15cls_result_ != NULL) { delete[] vr_15cls_result_; vr_15cls_result_ = NULL; } LOG_DEBUG("end body4-3.vr 15cls WUXI----- "); return SUCCESS; } //���п�汾�ij���ʶ�𲹳�ʶ�� int vr_supplement(void *handle, sy_img * body_img_data, int batch_size,int car_body_num, va_result *result) { va_handle *tools=(va_handle *)handle; int res_status =-1; LOG_DEBUG("body4-3.vr logo 15cls----- "); int vr_logo_15cls_batch_size = car_body_num;// //��ʼ������ṹ��vr_logo_result_ vlogos_result * vr_logo_result_ = new vlogos_result[vr_logo_15cls_batch_size]; memset(vr_logo_result_,0,sizeof(vlogos_result)*vr_logo_15cls_batch_size); vr_logo_result_->count = 0; //��ʼ������ṹ��vr_15cls_result_ vr_vehicle_type_15cls_result * vr_15cls_result_ = new vr_vehicle_type_15cls_result[vr_logo_15cls_batch_size]; memset(vr_15cls_result_,0,sizeof(vr_vehicle_type_15cls_result)*vr_logo_15cls_batch_size); //��ʼ������ṹ�� vr_3885cls_result_ vr_vehicle_type_3885cls_result * vr_3885cls_result_ = new vr_vehicle_type_3885cls_result[vr_logo_15cls_batch_size]; memset(vr_3885cls_result_,0,sizeof(vr_vehicle_type_3885cls_result)*vr_logo_15cls_batch_size); //process LOG_DEBUG("vlogodr_batch"); res_status = vlogodr_batch(tools->vr_logo_dr_handle, body_img_data, vr_logo_15cls_batch_size, vr_logo_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vlogodr_batch failed. (ret = {})", res_status); return res_status; } LOG_DEBUG("vr_vehicle_type_15cls_batch"); res_status=vr_vehicle_type_15cls_batch(tools->vr_vr15cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_15cls_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch_vd(error): vr_vehicle_type_15cls_batch failed. (ret = {})", res_status); return res_status; } LOG_DEBUG("vr_vehicle_type_3885cls_batch"); res_status = vr_vehicle_type_3885cls_batch(tools->vr_vr3885cls_handle, body_img_data, vr_logo_15cls_batch_size, vr_3885cls_result_); if (res_status != SUCCESS) { LOG_ERROR("sy_va_va_batch(error): vr_vehicle_type_3885cls_batch failed. (ret = {})", res_status); return res_status; } //output int car_idx=0; for(int b=0;b0)//û�ҵ�"-",�����ַ��� { str_vr_cls_brand = str_vr_cls_brand_subbrand_issue_year; } char *vr_cls_brand = (char *)str_vr_cls_brand.c_str(); char *vr_cls_subbrand_issue_year = (char *)str_vr_cls_subbrand_issue_year.c_str(); float vr_cls_score = vr_3885cls_result_[car_idx].score; //�����Ʒ�ƺ���� pos=0; pos=str_vr_cls_subbrand_issue_year.find("-"); if( pos!= -1) ///pos=-1˵��û���ҵ�"-" { str_vr_cls_subbrand = str_vr_cls_subbrand_issue_year.substr(0,pos); str_vr_cls_issue_year = str_vr_cls_subbrand_issue_year.substr(pos+1); } else if(str_vr_cls_subbrand_issue_year.size()>0)//û�ҵ�"-",�����ַ��� { str_vr_cls_subbrand = str_vr_cls_subbrand_issue_year; } char *vr_cls_subbrand = (char *)str_vr_cls_subbrand.c_str(); char *vr_cls_issue_year = (char *)str_vr_cls_issue_year.c_str(); //str_vr_cls_type!!!!!!!! std::unordered_map::iterator iters = vehicle_name_type.find(str_vr_cls_brand_subbrand_issue_year); if(iters != vehicle_name_type.end()) { str_vr_cls_type = iters->second; } char *vr_cls_type = (char *)str_vr_cls_type.c_str(); LOG_DEBUG("car_idx:{} ",car_idx); //1.У����Ʒ�� int logo_change=0; //logo output int logo_count = vr_logo_result_[car_idx].count; LOG_DEBUG("logo_count={} ",logo_count); if(logo_count>0)//�г����� { //����Ʒ�� int logo_index= vr_logo_result_[car_idx].vehicle_logo_infos[0].logo_brand_index; float logo_recg_score = vr_logo_result_[car_idx].vehicle_logo_infos[0].recg_score; char *vehicle_logo_brand = vr_logo_result_[car_idx].vehicle_logo_infos[0].logo_brand; if(logo_recg_score>0 && name_score>0 && vr_cls_score>0) { LOG_DEBUG("logo_recg_score:{} name_score:{} vr_cls_score:{}",logo_recg_score, name_score, vr_cls_score); if(logo_strcmp(vehicle_logo_brand, vehicle_brand)==0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) { if(strcmp(vehicle_subbrand_issue_year, vr_cls_subbrand_issue_year)!=0) { 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); if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) { if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } } if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) { if( VR_CLS_THRE - vr_cls_score < VR_REAR_THRE - name_score) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } } } } 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); if(logo_strcmp(vehicle_logo_brand, vehicle_brand)!=0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)!=0) { if(strcmp(vehicle_brand, vr_cls_brand)==0) { if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) { if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } } if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) { if(logo_recg_score >= VR_LOGO_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; result[b].info[c].vehicle_recg_res.index = -1; logo_change=1; //result[b].info[c].vehicle_recg_res.count =1; } else { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count = 0; } } } else { if(logo_recg_score >= VR_LOGO_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; result[b].info[c].vehicle_recg_res.index = -1; logo_change=1; //result[b].info[c].vehicle_recg_res.count =1; } else { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =0; } } } if(logo_strcmp(vehicle_logo_brand, vehicle_brand)!=0 && logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } } if(logo_recg_score>0 && name_score==0 && vr_cls_score>0) { LOG_DEBUG("logo_recg_score:{} name_score:{} vr_cls_score:{}",logo_recg_score, name_score, vr_cls_score); if(logo_strcmp(vehicle_logo_brand, vr_cls_brand)==0) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } else { if(logo_recg_score >= VR_LOGO_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vehicle_logo_brand, sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = logo_recg_score; result[b].info[c].vehicle_recg_res.index = -1; logo_change=1; //result[b].info[c].vehicle_recg_res.count =1; } else { if(vr_cls_score > VR_CLS_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } else { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =0; } } } } } else { LOG_DEBUG("name_score:{} vr_cls_score:{}", name_score, vr_cls_score); if(name_score>0 && vr_cls_score>0) { if(vr_cls_score > VR_CLS_THRE && name_score < VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } if(vr_cls_score > VR_CLS_THRE && name_score > VR_REAR_THRE) { if(vr_cls_score - VR_CLS_THRE > name_score - VR_REAR_THRE) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; result[b].info[c].vehicle_recg_res.name_score = score; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =1; } } //��������һ�£��ҷ������Ŷ�С��0.3�������ȶ����ƶ�С��0.8���� �����Ʒ��-��Ʒ��-���ʶ���������������ţ�������� if(vr_cls_score < VR_CLS_THRE && name_score < VR_REAR_THRE) { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =0; } } if(name_score==0 && vr_cls_score>0) { if(vr_cls_score>VR_CLS_THRE) { LOG_DEBUG("vr_cls_brand:{} ",vr_cls_brand); memcpy(result[b].info[c].vehicle_recg_res.vehicle_brand, vr_cls_brand,sizeof(char)*260); LOG_DEBUG("vr_cls_subbrand:{}", vr_cls_subbrand); memcpy(result[b].info[c].vehicle_recg_res.vehicle_subbrand, vr_cls_subbrand,sizeof(char)*260); LOG_DEBUG("vr_cls_issue_year:{}", vr_cls_issue_year); memcpy(result[b].info[c].vehicle_recg_res.vehicle_issue_year, vr_cls_issue_year,sizeof(char)*260); LOG_DEBUG("vr_cls_type:{}", vr_cls_type); memcpy(result[b].info[c].vehicle_recg_res.vehicle_type, vr_cls_type,sizeof(char)*260); LOG_DEBUG("freight_ton:{} ", result[b].info[c].vehicle_recg_res.freight_ton); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); LOG_DEBUG("vr_cls_score:{}", vr_cls_score); float score = vr_cls_score + VR_CLS_OFFSET; if(score> 0.99 )score =0.99; LOG_DEBUG("score:{}", score); result[b].info[c].vehicle_recg_res.name_score = score; LOG_DEBUG("name_score:{}", result[b].info[c].vehicle_recg_res.name_score); result[b].info[c].vehicle_recg_res.index = -1; LOG_DEBUG("index:{}", result[b].info[c].vehicle_recg_res.index); //result[b].info[c].vehicle_recg_res.count =1; LOG_DEBUG("if end."); } else { memset(result[b].info[c].vehicle_recg_res.vehicle_brand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_brand)); memset(result[b].info[c].vehicle_recg_res.vehicle_subbrand, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_subbrand)); memset(result[b].info[c].vehicle_recg_res.vehicle_issue_year, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_issue_year)); memset(result[b].info[c].vehicle_recg_res.vehicle_type, '\0', sizeof(result[b].info[c].vehicle_recg_res.vehicle_type)); memset(result[b].info[c].vehicle_recg_res.freight_ton, '\0', sizeof(result[b].info[c].vehicle_recg_res.freight_ton)); result[b].info[c].vehicle_recg_res.name_score = 0; result[b].info[c].vehicle_recg_res.index = -1; //result[b].info[c].vehicle_recg_res.count =0; } } }//end û�м�⵽���� LOG_DEBUG("vehicle_type:{}", result[b].info[c].vehicle_recg_res.vehicle_type); char* vehicle_type=result[b].info[c].vehicle_recg_res.vehicle_type; name_score=result[b].info[c].vehicle_recg_res.name_score; //����ʶ�����Ŷ� char* vehicle_type_15cls = vr_15cls_result_[car_idx].vehicle_type; float vr_15cls_score = vr_15cls_result_[car_idx].score; LOG_DEBUG("name_score:{} vehicle_type_15cls:{} vr_15cls_score:{}", name_score, vehicle_type_15cls, vr_15cls_score); if(name_score>0)//�г������Ľ�� { LOG_DEBUG("name_score:{} vr_15cls_score:{} logo_change:{}", name_score, vr_15cls_score, logo_change); if(logo_change == 0) { if(strcmp(vehicle_type, vehicle_type_15cls)!=0) { if(name_score < 0.55 && vr_15cls_score>0.8) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; } } } else if(logo_change == 1) { if(vr_15cls_score>=0.2) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); result[b].info[c].vehicle_recg_res.name_score = (result[b].info[c].vehicle_recg_res.name_score + vr_15cls_score)/2; } } } else if(name_score==0) { LOG_DEBUG("name_score:{} vr_15cls_score:{}", name_score, vr_15cls_score); if(vr_15cls_score>=0.8) { memcpy(result[b].info[c].vehicle_recg_res.vehicle_type,vr_15cls_result_[car_idx].vehicle_type,sizeof(char)*260); result[b].info[c].vehicle_recg_res.name_score = vr_15cls_score; //result[b].info[c].vehicle_recg_res.count =1; } } car_idx++; } } } //release vr_logo_result_ if (vr_logo_result_ != NULL) { delete[] vr_logo_result_; vr_logo_result_ = NULL; } if (vr_15cls_result_ != NULL) { delete[] vr_15cls_result_; vr_15cls_result_ = NULL; } if (vr_3885cls_result_ != NULL) { delete[] vr_3885cls_result_; vr_3885cls_result_ = NULL; } LOG_DEBUG("end body4-3.vr logo 15cls----- "); return SUCCESS; }