Commit 4bcfa5f5853993021583b66a343805878bdb708d

Authored by Hu Chunming
1 parent c766e4b0

代码优化

src/ai_engine_module/face_det_ai_engine.cpp
... ... @@ -23,16 +23,45 @@ face_det_ai_engine::~face_det_ai_engine(){
23 23 }
24 24 }
25 25  
26   -int face_det_ai_engine::init_ai_engine(const facedet_ai_engine_param &ai_param/*, person_det_algorthim_cache * cache*/){
  26 +int face_det_ai_engine::init_ai_engine(string models_dir, int devId){
27 27  
28 28 task_param_manager_ = task_param_manager::getInstance();
29 29  
30   - m_devId = ai_param.sdk_param.devId;
  30 + m_devId = devId;
31 31  
32 32 ACL_CALL(aclrtSetDevice(m_devId), ACL_ERROR_NONE, -1);
33 33 ACL_CALL(aclrtCreateContext(&m_algorthim_ctx, m_devId), ACL_ERROR_NONE, -1);
34 34  
35   - return fd_init(&handle, ai_param.sdk_param);
  35 + // 人脸检测初始化
  36 + fd_param sdk_param;
  37 + char model_path_yolov5s[100];
  38 + strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str());
  39 + sdk_param.det_modelNames = model_path_yolov5s;
  40 + char model_path_ldmk[100];
  41 + strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str());
  42 + sdk_param.ldmk_modelNames = model_path_ldmk;
  43 + char model_path_pose[100];
  44 + strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str());
  45 + sdk_param.pose_modelNames = model_path_pose;
  46 + char model_path_score[100];
  47 + strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str());
  48 + sdk_param.score_modelNames = model_path_score;
  49 + char model_path_fuzzy[100];
  50 + strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str());
  51 + sdk_param.fuzzy_modelNames = model_path_fuzzy;
  52 + char model_path_occlusion[100];
  53 + strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str());
  54 + sdk_param.occlusion_modelNames = model_path_occlusion;
  55 + sdk_param.thresld = 0.6;
  56 + sdk_param.devId = m_devId;
  57 + sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023";
  58 + sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测
  59 + sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角
  60 + sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测
  61 + sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE
  62 + sdk_param.max_result_count = 50;
  63 +
  64 + return fd_init(&handle, sdk_param);
36 65 }
37 66  
38 67 int face_det_ai_engine::ai_engine_process_batch(std::vector<std::string> &task_ids, sy_img *image_data_array, std::vector<onelevel_det_result> &result , std::vector<std::vector<int>> &deleteObjectID){
... ...
src/ai_engine_module/face_det_ai_engine.h
... ... @@ -35,7 +35,7 @@ public:
35 35 face_det_ai_engine();
36 36 ~face_det_ai_engine();
37 37  
38   - int init_ai_engine(const facedet_ai_engine_param &ai_param/*, person_det_algorthim_cache * cache*/);
  38 + int init_ai_engine(string models_dir, int devId);
39 39 int ai_engine_process_batch(std::vector<std::string> &task_ids, sy_img *image_data_array, std::vector<onelevel_det_result> &result
40 40 , std::vector<std::vector<int>> &deleteObjectID);
41 41 void finish_task(std::string task_id);
... ...
src/ai_platform/MultiSourceProcess.cpp
... ... @@ -108,35 +108,7 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){
108 108 }
109 109  
110 110 #ifdef WITH_FACE_DET_SS
111   - // 人脸检测初始化
112   - facedet_ai_engine_param fd_param;
113   - char model_path_yolov5s[100];
114   - strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str());
115   - fd_param.sdk_param.det_modelNames = model_path_yolov5s;
116   - char model_path_ldmk[100];
117   - strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str());
118   - fd_param.sdk_param.ldmk_modelNames = model_path_ldmk;
119   - char model_path_pose[100];
120   - strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str());
121   - fd_param.sdk_param.pose_modelNames = model_path_pose;
122   - char model_path_score[100];
123   - strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str());
124   - fd_param.sdk_param.score_modelNames = model_path_score;
125   - char model_path_fuzzy[100];
126   - strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str());
127   - fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy;
128   - char model_path_occlusion[100];
129   - strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str());
130   - fd_param.sdk_param.occlusion_modelNames = model_path_occlusion;
131   - fd_param.sdk_param.thresld = 0.6;
132   - fd_param.sdk_param.devId = m_devId;
133   - fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023";
134   - fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测
135   - fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角
136   - fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测
137   - fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE
138   - fd_param.sdk_param.max_result_count = 50;
139   - ret = m_face_det_ai_engine.init_ai_engine(fd_param);
  111 + ret = m_face_det_ai_engine.init_ai_engine(models_dir, m_devId);
140 112 if (ret < 0 ) {
141 113 LOG_FATAL("Init face detection failed");
142 114 return ret;
... ... @@ -200,7 +172,7 @@ int CMultiSourceProcess::AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_
200 172 LOG_ERROR("mq_manager_ is null");
201 173 return FAILED;
202 174 }
203   -
  175 +
204 176 if (!mq_manager_->add_conn(mq_type, mq_conn_param)) {
205 177 LOG_ERROR("Connection MQ failed, ip: {} port: {} uname: {} passwd: {}", mq_conn_param.ip, mq_conn_param.port,
206 178 mq_conn_param.uname, mq_conn_param.passwd);
... ...