From 3e43f0c7172fc961dc67c2c8845f0f05737516df Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Mon, 10 Mar 2025 10:20:36 +0800 Subject: [PATCH] 优化初始化值 --- algorithm/vehicle_analysis/vehicle_analysis.h | 83 ++--------------------------------------------------------------------------------- algorithm/vehicle_analysis/vehicle_result.h | 80 ++++++++++++++++++++++++++++++++++++++------------------------------------------ 2 files changed, 40 insertions(+), 123 deletions(-) diff --git a/algorithm/vehicle_analysis/vehicle_analysis.h b/algorithm/vehicle_analysis/vehicle_analysis.h index d027dd2..ef73bbf 100644 --- a/algorithm/vehicle_analysis/vehicle_analysis.h +++ b/algorithm/vehicle_analysis/vehicle_analysis.h @@ -55,8 +55,8 @@ #ifndef __VEHICLE_ANALYSIS_RESULT__ #define __VEHICLE_ANALYSIS_RESULT__ typedef struct va_result { //车辆分析结果 内存在外部申请 - vehicle_info *info; //单车辆全部分析结果 - int count; //车辆数量 + vehicle_info info[100]; //单车辆全部分析结果 + int count{0}; //车辆数量 } va_result; #endif @@ -106,88 +106,9 @@ float vc_thresld=0.5; //车颜色阈值 char* dbPath; //车型识别车型数据路路径 <当前仅支持英文路径> char* models_Path; //所有模型的路径 <当前仅支持英文路径>//20210615 - - int log_level{2}; - int log_days{30}; //日志保存周期 - std::string log_path{"logs"}; //日志文件路径 - unsigned long log_mem{64 * 1024 * 1024}; //每个日志最大大小 }va_param; #endif - /************************************************************************* - * function: va_init - * purpose: init resources - * param: - [in] handle - handle - [in] param - init param - * return: success(0) or error code(<0) - * notes: null - *************************************************************************/ - VEHICLEANALYSIS_API int va_init(void ** handle, va_param param); - VEHICLEANALYSIS_API int va_acl_init();//仅调用一次,先调用va_acl_init,再调用va_init - - /************************************************************************* - * function: va_release - * purpose: release sources - * param: - [in] handle - handle - * return: null - * notes: null - *************************************************************************/ - VEHICLEANALYSIS_API void va_release(void ** handle); - VEHICLEANALYSIS_API void va_acl_release();//仅调用一次,当所有的va_release都释放了,最后调用va_acl_release - - /************************************************************************* - * function: va_get_version - * purpose: get sdk version - * param: null - * return: null - * notes: null - *************************************************************************/ - VEHICLEANALYSIS_API const char * va_get_version(); - - /************************************************************************* - * function: va_batch - * purpose: vehicle analysis batch - * param: - [in] handle - handle - [in] img_data_array - data array - [in] format - data format - [in] batch_size - batch size - [in] result - vehicle analysis result - * return: success(0) or error code(<0) - * notes: null - *************************************************************************/ - VEHICLEANALYSIS_API int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result *result); - //img_data_array是device数据,batch_size==16时调用固定16模型,小于16时调用固定1模型。 - VEHICLEANALYSIS_API int va_batch16_device(void * handle, sy_img * img_data_array, int batch_size, va_result *result); - - - - /************************************************************************* - * FUNCTION: VA_ComputeSimilarity - * PURPOSE: 比对相似度(通用) - * PARAM: - [in] Afea - 第一张图片特征 - [in] Bfea - 第二张图片特征 - [in] featuresize - 特征长度 - * RETURN: 相似度 - * NOTES: - *************************************************************************/ - VEHICLEANALYSIS_API float va_compute_similarity(float *Afea, float *Bfea, int featuresize); - - /************************************************************************* - * FUNCTION: va_compute_similarity_byvafeature - * PURPOSE: 比对相似度(针对va特征) - * PARAM: - [in] Afea - 第一张图片va特征 - [in] Bfea - 第二张图片va特征 - [in] featuresize - 特征长度VA_FEATURESIZE - * RETURN: 相似度 - * NOTES: - *************************************************************************/ - VEHICLEANALYSIS_API float va_compute_similarity_byvafeature(void * handle , float *Afea, float *Bfea, int featuresize); - #endif diff --git a/algorithm/vehicle_analysis/vehicle_result.h b/algorithm/vehicle_analysis/vehicle_result.h index a2c9200..d3b5308 100644 --- a/algorithm/vehicle_analysis/vehicle_result.h +++ b/algorithm/vehicle_analysis/vehicle_result.h @@ -6,20 +6,16 @@ #define VPT_INFO_MIDD_TEMP_ typedef struct vpt_info_midd_temp { - int obj_id; + int obj_id {-1}; sy_rect obj_rect; - int obj_index; - float obj_score; - int dis; //20220308到最佳目标点的加权距离 + int obj_index {-1}; + float obj_score {0.0}; + int dis {-1}; //20220308到最佳目标点的加权距离 }vpt_info_midd_temp; #endif - - - - //1.车检测结果 #define MAXCARCOUNT 100 //支持最多100个车检测 @@ -28,7 +24,7 @@ typedef struct vpt_info_midd_temp typedef struct vd_result { sy_rect rect; - float score; + float score{0.0}; }vd_result; #endif @@ -38,8 +34,8 @@ typedef struct vd_result #define VC_RESULT_ typedef struct vc_result { - float score; - int index;//车颜色索引0-12,对应"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑" + float score{0.0}; + int index{-1};//车颜色索引0-12,对应"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑" }vc_result; #endif @@ -49,13 +45,13 @@ typedef struct vc_result #define VR_RESULT_ typedef struct vr_result //结果 { - char vehicle_brand[260]; //车辆品牌 - char vehicle_subbrand[260]; //车辆子品牌 - char vehicle_issue_year[260]; //车辆年款 - char vehicle_type[260]; //车辆类型 - char freight_ton[260]; //货车吨级 - float name_score; //识别置信度 - int index; + char vehicle_brand[260] {}; //车辆品牌 + char vehicle_subbrand[260] {}; //车辆子品牌 + char vehicle_issue_year[260] {}; //车辆年款 + char vehicle_type[260] {}; //车辆类型 + char freight_ton[260] {}; //货车吨级 + float name_score{0.0}; //识别置信度 + int index{-1}; }vr_result; #endif @@ -80,9 +76,9 @@ typedef struct vr_result //结果 #define VPLATENUM_RESULT_ typedef struct vplate_num { - char character[4]; - float maxprob; - int index; + char character[4] {}; + float maxprob{0.0}; + int index{-1}; }vplate_num; #endif @@ -96,8 +92,8 @@ typedef struct vplate_num #define SVP_RESULT_ typedef struct stain_vplate_result { - float score; //识别置信度 - int type; //COVER 或者 NO_COVER 或者 NORMAL 或者 PARTIAL + float score{0.0}; //识别置信度 + int type{0}; //车牌状态:0-无车牌,1-车牌,2-遮挡车牌 }stain_vplate_result; #endif @@ -106,12 +102,12 @@ typedef struct vplate_num typedef struct vplate_results { sy_rect rect;//车牌检测坐标 - float detect_score;//车牌检测置信度 + float detect_score{0.0};//车牌检测置信度 vplate_num recg[PLATENUM];//识别号码结果 - float num_score;//识别置信度 - int type; //车牌类型:0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色 + float num_score{0.0};//识别置信度 + int type{-1}; //车牌类型:0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色 - int special_type; //常规车牌、临时车牌、低速车牌。0-common,1-temporary_license_plate,2-low_speed_license_plate. + int special_type{0}; //常规车牌、临时车牌、低速车牌。0-common,1-temporary_license_plate,2-low_speed_license_plate. stain_vplate_result stain_vp_result; //车牌遮挡识别结果 }vplate_results; #endif @@ -125,17 +121,17 @@ typedef struct vplate_results typedef struct v_pendant_d_info { sy_rect rect; - int index; //类型 0-driver 1-face 2-belt 3-sunshield 4-tag 5-decoration 6-napkinbox 7-zhuanjt 8-callPhone 9-sunRoof 10-holder 11-smoke - float confidence; //置信度 + int index{-1}; //类型 0-driver 1-face 2-belt 3-sunshield 4-tag 5-decoration 6-napkinbox 7-zhuanjt 8-callPhone 9-sunRoof 10-holder 11-smoke + float confidence{0.0}; //置信度 - int driver_copilot_info; //车属性的主驾副驾信息,0-不分主驾副驾,1-主驾,2-副驾,(只有司机 、人脸、安全带、遮阳板、打电话、抽烟 区分主驾副驾,其他属性默认是输出0) + int driver_copilot_info{0}; //车属性的主驾副驾信息,0-不分主驾副驾,1-主驾,2-副驾,(只有司机 、人脸、安全带、遮阳板、打电话、抽烟 区分主驾副驾,其他属性默认是输出0) //float feature[VPD_FACE_FEATURESIZE]; //车属性中的人脸特征。 }v_pendant_d_info; typedef struct v_pendant_d_result { - v_pendant_d_info* vpd_res; - int count; + v_pendant_d_info vpd_res[300]; + int count{0}; }v_pendant_d_result; #endif @@ -152,8 +148,8 @@ typedef struct v_pendant_d_result typedef struct vid_details { - int status; //是否违规 ILLEGAL:违规(抽烟 未系安全带 打电话) lEGAL:未违规(未抽烟 系安全带 未打电话) UNCERTAINTY:不确定 - float confidence; //置信度 + int status {UNCERTAINTY}; //是否违规 ILLEGAL:违规(抽烟 未系安全带 打电话) lEGAL:未违规(未抽烟 系安全带 未打电话) UNCERTAINTY:不确定 + float confidence{0.0}; //置信度 }vid_details; typedef struct vid_info @@ -181,7 +177,7 @@ typedef struct vid_result #define VF_RESULT_ typedef struct vf_result { - float feature[VA_FEATURESIZE]; + float feature[VA_FEATURESIZE] {}; }vf_result; #endif @@ -190,8 +186,8 @@ typedef struct vf_result #define VS_INFORMATION_ typedef struct vs_information { - float score;//车类型置信度 - int index; //车类型索引0-10:"吊车", "罐装车", "货车", "渣土车", "轿运车","救援车", "垃圾车", "消防车", "清扫车", "随车吊","危化品车" + float score {0.0};//车类型置信度 + int index {-1}; //车类型索引0-10:"吊车", "罐装车", "货车", "渣土车", "轿运车","救援车", "垃圾车", "消防车", "清扫车", "随车吊","危化品车" }vs_information; #endif @@ -201,7 +197,7 @@ typedef struct vs_information typedef struct vs_result { vs_information vs_info[2];//车类型信息 - int count;//车类型的数量,是1,内部没设阈值 + int count {-1};//车类型的数量,是1,内部没设阈值 }vs_result; #endif @@ -214,8 +210,8 @@ typedef struct vs_result #define MUCKTRUCKCOVER_RESULT_ typedef struct mucktruckcover_result { - int status; //是否盖盖 COVER-盖盖 NOCOVER_NODIRT-无盖无土 NOCOVER_DIRT-无盖有土 - float confidence; //置信度 + int status {-1}; //是否盖盖 COVER-盖盖 NOCOVER_NODIRT-无盖无土 NOCOVER_DIRT-无盖有土 + float confidence {0.0}; //置信度 }mucktruckcover_result; #endif @@ -234,7 +230,7 @@ typedef struct mucktruckcover_result typedef struct mta_details { - int status; //摩托车是否载人/摩托车驾驶人是否戴头盔/三轮车是否载人 UNCERTAINTY:不确定 + int status{-1}; //摩托车是否载人/摩托车驾驶人是否戴头盔/三轮车是否载人 UNCERTAINTY:不确定 float confidence{0.0}; //置信度 }mta_details; @@ -259,7 +255,7 @@ typedef struct manned_result //float confidence; //置信度 vd_result hs_rect[10]; //头肩坐标 - int hs_count; //头肩个数 + int hs_count{0}; //头肩个数 }manned_result; #endif -- libgit2 0.21.4