From 5a4c4dc0574b3f73c620ca789cb2d3082c001dc7 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Thu, 27 Feb 2025 18:03:37 +0800 Subject: [PATCH] va库代码移到本项目中 --- src/PicAnalysis.cpp | 4 ---- src/ai_engine_module/VehicleAnalysis.cpp | 7 ++----- src/ai_engine_module/VehicleAnalysis.h | 4 ---- src/ai_engine_module/VehicleAnalysisDevice.cpp | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/ai_engine_module/VehicleAnalysisDevice.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ai_engine_module/VehicleAnalysisDevice.h0 | 13 ------------- 6 files changed, 220 insertions(+), 269 deletions(-) create mode 100644 src/ai_engine_module/VehicleAnalysisDevice.h delete mode 100644 src/ai_engine_module/VehicleAnalysisDevice.h0 diff --git a/src/PicAnalysis.cpp b/src/PicAnalysis.cpp index 3a7d795..9437923 100644 --- a/src/PicAnalysis.cpp +++ b/src/PicAnalysis.cpp @@ -38,10 +38,6 @@ int PicAnalysis::init(VillageParam param) { vehicle_analysis_param.devId = dev_id; vehicle_analysis_param.sdk_root = param.sdk_path; vehicle_analysis_param.max_batch_size = 16; - vehicle_analysis_param.log_level = param.log_level; - vehicle_analysis_param.log_path = param.log_path; - vehicle_analysis_param.log_days = param.log_days; - vehicle_analysis_param.log_mem = param.log_mem; ret = m_vehicle_analysis.init(vehicle_analysis_param); if(0 != ret){ return -1; diff --git a/src/ai_engine_module/VehicleAnalysis.cpp b/src/ai_engine_module/VehicleAnalysis.cpp index 40757b1..fdda364 100644 --- a/src/ai_engine_module/VehicleAnalysis.cpp +++ b/src/ai_engine_module/VehicleAnalysis.cpp @@ -1,5 +1,7 @@ #include "VehicleAnalysis.h" +#include "VehicleAnalysisDevice.h" + VehicleAnalysis::VehicleAnalysis() { cout << va_get_version() << endl; @@ -59,11 +61,6 @@ int VehicleAnalysis::init(VehicleAnalysisParam tParam) { param.dbPath= (char*)dbPath.data(); param.models_Path= (char*)models_path.data(); //所有模型的地址 - param.log_level = tParam.log_level; - param.log_path = tParam.log_path; - param.log_days = tParam.log_days; - param.log_mem = tParam.log_mem; - LOG_INFO("va_init start"); // 内部有 ctx int ret = va_init(&m_handle, param); diff --git a/src/ai_engine_module/VehicleAnalysis.h b/src/ai_engine_module/VehicleAnalysis.h index 0c0b972..a71c499 100644 --- a/src/ai_engine_module/VehicleAnalysis.h +++ b/src/ai_engine_module/VehicleAnalysis.h @@ -15,10 +15,6 @@ struct VehicleAnalysisParam { int devId; std::string sdk_root; int max_batch_size; - int log_level{2}; - int log_days{30}; //日志保存周期 - std::string log_path{"logs"}; //日志文件路径 - unsigned long log_mem{64 * 1024 * 1024}; //每个日志最大大小 }; struct VehicleAnalysisResult{ diff --git a/src/ai_engine_module/VehicleAnalysisDevice.cpp b/src/ai_engine_module/VehicleAnalysisDevice.cpp index ffa6974..d6e8ecf 100644 --- a/src/ai_engine_module/VehicleAnalysisDevice.cpp +++ b/src/ai_engine_module/VehicleAnalysisDevice.cpp @@ -27,7 +27,7 @@ #include "head_shoulder_det.h"//ͷ�磨����������ˣ� -// #include "VehicleAnalysisDevice.h" +#include "VehicleAnalysisDevice.h" #include "include.h" @@ -41,7 +41,6 @@ #define FEATURESIZE 256 //�������� - #define VR_HEAD_THRE 0.7 //��ͷ����ʶ����ֵ #define VR_REAR_THRE 0.8 //��β����ʶ����ֵ #define VR_CLS_THRE 0.25 //������������ֵ @@ -49,8 +48,6 @@ #define VR_LOGO_THRE 0.9 //��logo����ֵ #define VR_15CLS_THRE 0.8 //����15�������ֵ -#define IF_DEBUG_INFO 0 //�Ƿ��ӡdebug��Ϣ - #define VERSION_WUXI 0 //�л����а汾�������汾�������汾��ֻ��topn���������������Ͳ���ʶ�𣬵�Ҫ���ӳ���15������������ȱʧ�ij����͡� #define VR_WUXI_LOGO 1 //�����汾���Ƿ�����logo������ #define VPT_TOPN 10 //�˳���ȡtopn���з��� @@ -60,8 +57,6 @@ using namespace std; -//static int va_acl_flag=0; - typedef struct va_handle { void* vpt_handle; @@ -121,33 +116,14 @@ const char * va_get_version() return "sy_va_version:1.2.0.20231129.atlas310p.arm.withOfflineAuthorization"; } - -int va_acl_init() -{ - if(IF_DEBUG_INFO) { - LOG_INFO("start aclInit "); - } - ACL_CALL(aclInit(nullptr), ACL_ERROR_NONE, SY_FAILED); - if(IF_DEBUG_INFO){ - LOG_DEBUG("end aclInit "); - } - - return SUCCESS; -} - int va_init(void ** handle, va_param param) { - string log_path = param.log_path + "/va.log"; - - set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days); - va_handle *tools=new va_handle(); *handle=(void *)tools; int ret = SUCCESS; tools->param = param; - string str1=tools->param.models_Path; @@ -654,41 +630,12 @@ int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result * result[b].count=0; for(int c=0;c 0.1 && info_c.vehicle_plate_det_recg_res.stain_vp_result.type == 1) - { - 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; - } - - + info_c.vehicle_plate_det_recg_res.rect.left_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.left_ * scale_w[head_idx]+ info_c.vehicle_detect_res.rect.left_; info_c.vehicle_plate_det_recg_res.rect.top_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.top_ * scale_h[head_idx]+ info_c.vehicle_detect_res.rect.top_; info_c.vehicle_plate_det_recg_res.rect.width_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.width_ * scale_w[head_idx]; info_c.vehicle_plate_det_recg_res.rect.height_ = vp_result[head_idx].vehicle_plate_infos[max_index].rect.height_* scale_h[head_idx]; + int space_char_num = 0; 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 0.1 && info_c.vehicle_plate_det_recg_res.stain_vp_result.type == 1) - { - 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; - } info_c.vehicle_plate_det_recg_res.rect.left_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.left_ * scale_w[rear_idx] + info_c.vehicle_body_detect_res.rect.left_; info_c.vehicle_plate_det_recg_res.rect.top_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.top_ * scale_h[rear_idx] + info_c.vehicle_body_detect_res.rect.top_; info_c.vehicle_plate_det_recg_res.rect.width_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.width_* scale_w[rear_idx]; info_c.vehicle_plate_det_recg_res.rect.height_ = vp_result[rear_idx].vehicle_plate_infos[max_index].rect.height_* scale_h[rear_idx]; + int space_char_num = 0; 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;p0) { //double t22 = msecond(); @@ -2083,19 +1967,20 @@ int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result * { for(int c=0;c0) { LOG_DEBUG("start :tricycle_img_data."); @@ -2186,7 +2072,8 @@ int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result * { for(int c=0;c 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++; @@ -2261,10 +2155,49 @@ int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result * 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;ctm_year + 1900; - nMonth = info->tm_mon + 1; - nDay = info->tm_mday; - if (nYear == 2019 && nMonth < 7) - return 1; - LOG_ERROR("Software license is out of time! Please contact software developers."); - //exit(0); - return -1; -} - - - +} \ No newline at end of file diff --git a/src/ai_engine_module/VehicleAnalysisDevice.h b/src/ai_engine_module/VehicleAnalysisDevice.h new file mode 100644 index 0000000..78fd338 --- /dev/null +++ b/src/ai_engine_module/VehicleAnalysisDevice.h @@ -0,0 +1,79 @@ +#ifndef __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ +#define __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ + +#include "vehicle_analysis.h" + +/************************************************************************* +* function: va_init +* purpose: init resources +* param: +[in] handle - handle +[in] param - init param +* return: success(0) or error code(<0) +* notes: null +*************************************************************************/ +int va_init(void ** handle, va_param param); + +/************************************************************************* +* function: va_release +* purpose: release sources +* param: +[in] handle - handle +* return: null +* notes: null +*************************************************************************/ +void va_release(void ** handle); + +/************************************************************************* +* function: va_get_version +* purpose: get sdk version +* param: null +* return: null +* notes: null +*************************************************************************/ +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 +*************************************************************************/ +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模型。 +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: +*************************************************************************/ +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: +*************************************************************************/ +float va_compute_similarity_byvafeature(void * handle , float *Afea, float *Bfea, int featuresize); + + +#endif // __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ \ No newline at end of file diff --git a/src/ai_engine_module/VehicleAnalysisDevice.h0 b/src/ai_engine_module/VehicleAnalysisDevice.h0 deleted file mode 100644 index 20a365e..0000000 --- a/src/ai_engine_module/VehicleAnalysisDevice.h0 +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ -#define __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ - -#include "vehicle_analysis.h" - -int va_init(void ** handle, va_param param); - -int va_batch(void * handle, sy_img * img_data_array, int batch_size, va_result *result); - -void va_release(void ** handle); - - -#endif // __AI_ENGINE_MODULE_VEHICLE_ANALYSIS_DEVICE_H__ \ No newline at end of file -- libgit2 0.21.4