#include "VehicleAnalysis.h" VehicleAnalysis::VehicleAnalysis() { cout << va_get_version() << endl; } VehicleAnalysis::~VehicleAnalysis() { release(); } int VehicleAnalysis::init(int devId, int max_batch_size) { param.vehicle_detect_config= SY_CONFIG_OPEN; //1.开启车检测 SY_CONFIG_CLOSE SY_CONFIG_OPEN param.vehicle_recg_config= SY_CONFIG_OPEN; //4.开启车型识别 param.vehicle_recg_supplement_config= SY_CONFIG_OPEN; //4.开启车型识别补充识别 param.vehicle_plate_det_recg_config= SY_CONFIG_OPEN; //5.开启车牌检测识别 param.vehicle_pendant_det_config= SY_CONFIG_OPEN; //6.开启车属性检测识别 param.vehicle_motor_tricycle_analysis_config= SY_CONFIG_OPEN; //8.摩托车分析 param.vehicle_manned_config= SY_CONFIG_OPEN; //8.开启载人分析 param.vehicle_color_config= SY_CONFIG_CLOSE; //3.开启车颜色识别 param.vehicle_illegal_config= SY_CONFIG_CLOSE; //7.开启车违规 param.vehicle_feature_config= SY_CONFIG_CLOSE; //8.开启车辆特征提取 param.gpuid=devId; //车检测参数 //param.vehicle_det_param.process_min_l = 720;// 720; //param.vehicle_det_param.process_max_l = 1280;//1280; //param.vehicle_det_param.thresld=0.3; //param.min_obj_size=200; //最小目标 param.vehicle_det_thresld=0.4; //车牌检测参数 //param.vehicle_plate_det_param.process_min_l=320; //param.vehicle_plate_det_param.process_max_l=320; //param.vehicle_plate_det_param.thresld=0.4; param.vehicle_plate_det_thresld=0.5; //车属性检测参数 //param.vehicle_attribute_det_param.process_min_l=360; //param.vehicle_attribute_det_param.process_max_l=640; //param.vehicle_attribute_det_param.thresld=0.3; param.vehicle_attribute_det_thresld=0.5; //车logo检测参数 //param.vehicle_logo_det_param.process_min_l=512; //param.vehicle_logo_det_param.process_max_l=512; //param.vehicle_logo_det_param.thresld=0.1; param.vehicle_logo_det_thresld=0.1; //车颜色阈值 param.vc_thresld = 0.5; //车型参数 param.dbPath="./models/vehicle_analysis/db/vr_h0725x210605_r191230.db"; param.models_Path="./models/vehicle_analysis/"; //所有模型的地址 cout << "va_init start " << endl; // 内部有 ctx int ret = va_init(&m_handle, param); if (ret != 0) { return -1; } cout << "va_init success " << endl; return 0; } va_result * VehicleAnalysis::detect(vector vec_img) { int batch_size = vec_img.size(); va_result *result=new va_result[batch_size]; for(int b=0;b vec_result; for (int b = 0; b < batch_size; b++) { for(int c=0;c0) { float vehicle_body_detect_res_score = result_info.vehicle_body_detect_res.score; int x1=result_info.vehicle_body_detect_res.rect.left_; int y1=result_info.vehicle_body_detect_res.rect.top_; int x2=result_info.vehicle_body_detect_res.rect.left_+result_info.vehicle_body_detect_res.rect.width_; int y2=result_info.vehicle_body_detect_res.rect.top_+result_info.vehicle_body_detect_res.rect.height_; std::cout << " vehicle_body_detect_res_score:" <0) // { // float vehicle_detect_res_score = result_info.vehicle_detect_res.score; // int x1=result_info.vehicle_detect_res.rect.left_; // int y1=result_info.vehicle_detect_res.rect.top_; // int x2=result_info.vehicle_detect_res.rect.left_+result_info.vehicle_detect_res.rect.width_; // int y2=result_info.vehicle_detect_res.rect.top_+result_info.vehicle_detect_res.rect.height_; // std::cout << " vehicle_detect_res_score:" <0) // { // float vehicle_win_detect_res_score = result_info.vehicle_win_detect_res.score; // int x1=result_info.vehicle_win_detect_res.rect.left_; // int y1=result_info.vehicle_win_detect_res.rect.top_; // int x2=result_info.vehicle_win_detect_res.rect.left_+result_info.vehicle_win_detect_res.rect.width_; // int y2=result_info.vehicle_win_detect_res.rect.top_+result_info.vehicle_win_detect_res.rect.height_; // std::cout << " vehicle_win_detect_res_score:" < name_score_thre) { analysis_result.vehicle_type = vehicle_type_; } } else { analysis_result.vehicle_type = str_vehicle_type; } std::cout << "vehicle_type_: " << analysis_result.vehicle_type << std::endl; //5.VP车牌检测识别 if(param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN && (shot_type==0 || shot_type==1)) { vplate_results plate_result = result_info.vehicle_plate_det_recg_res; std::cout << " car plate info:"<< endl; int special_type=plate_result.special_type;//常规车牌、临时车牌、低速车牌。0-common,1-temporary_license_plate,2-low_speed_license_plate. std::cout << " special_type:" << special_type<< std::endl; float detect_score=plate_result.detect_score; if(detect_score>0.3) { //车牌识别结果 std::string plate_recg=""; std::string character_prob; //if(num_score>0.99)//车牌识别建议置信度阈值0.99 { for (int m = 0; m < PLATENUM; m++) { plate_recg=plate_recg + plate_result.recg[m].character; character_prob += std::string(plate_result.recg[m].character) + "-" + std::to_string(plate_result.recg[m].maxprob) + ","; } } analysis_result.plate_det_score = plate_result.detect_score; analysis_result.plate_rect = plate_result.rect;//车牌检测坐标 analysis_result.plate_type = plate_result.type; //车牌类型:0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色 analysis_result.plate_num = plate_recg; analysis_result.character_prob = character_prob; analysis_result.plate_num_score = plate_result.num_score;//识别置信度 // analysis_result.special_type; //常规车牌、临时车牌、低速车牌。0-common,1-temporary_license_plate,2-low_speed_license_plate. } } //6.车属性结果: if(param.vehicle_pendant_det_config==SY_CONFIG_OPEN && (shot_type==0|| shot_type==4)) { std::cout << " vehicle_pendant_det_res info:"<< endl; int vpd_num = result_info.vehicle_pendant_det_res.count; //std::cout << vpd_num<< std::endl; std::cout << " vpd_num:"<= 3){ analysis_result.motor_manned = 1; } } } } //delete result // for(int b=0;b