Commit d5345ee9595c574afb6a878a984a63c32befb912

Authored by Hu Chunming
1 parent 5accab74

代码优化

src/ai_engine_module/HumanFeature.h
  1 +#ifndef __AI_ENGINE_MODULE_HUMAN_FEATURE__
  2 +#define __AI_ENGINE_MODULE_HUMAN_FEATURE__
  3 +
1 #include "acl/acl.h" 4 #include "acl/acl.h"
2 #include "acl/ops/acl_dvpp.h" 5 #include "acl/ops/acl_dvpp.h"
3 6
@@ -8,7 +11,7 @@ @@ -8,7 +11,7 @@
8 using namespace std; 11 using namespace std;
9 12
10 struct HFResult{ 13 struct HFResult{
11 - float feature[HUMANREID_FEATURESIZE]; 14 + float feature[HUMANREID_FEATURE_SIZE];
12 }; 15 };
13 16
14 class HumanFeature 17 class HumanFeature
@@ -27,4 +30,6 @@ private: @@ -27,4 +30,6 @@ private:
27 int m_devId; 30 int m_devId;
28 aclrtContext m_algorthim_ctx; 31 aclrtContext m_algorthim_ctx;
29 void* m_handle{nullptr}; 32 void* m_handle{nullptr};
30 -};  
31 \ No newline at end of file 33 \ No newline at end of file
  34 +};
  35 +
  36 +#endif // __AI_ENGINE_MODULE_HUMAN_FEATURE__
32 \ No newline at end of file 37 \ No newline at end of file
src/ai_engine_module/HumanParsing.h
  1 +#ifndef __AI_ENGINE_MODULE_HUMAN_PARSING__
  2 +#define __AI_ENGINE_MODULE_HUMAN_PARSING__
  3 +
1 #include <vector> 4 #include <vector>
2 #include "acl/acl.h" 5 #include "acl/acl.h"
3 #include "acl/ops/acl_dvpp.h" 6 #include "acl/ops/acl_dvpp.h"
@@ -24,4 +27,6 @@ private: @@ -24,4 +27,6 @@ private:
24 int m_devId; 27 int m_devId;
25 aclrtContext m_algorthim_ctx; 28 aclrtContext m_algorthim_ctx;
26 void* m_handle{nullptr}; 29 void* m_handle{nullptr};
27 -};  
28 \ No newline at end of file 30 \ No newline at end of file
  31 +};
  32 +
  33 +#endif
29 \ No newline at end of file 34 \ No newline at end of file
src/ai_engine_module/VPDProcess.h
  1 +#ifndef __AI_ENGINE_MODULE_VPD__
  2 +#define __AI_ENGINE_MODULE_VPD__
  3 +
1 #include "acl/acl.h" 4 #include "acl/acl.h"
2 #include "acl/ops/acl_dvpp.h" 5 #include "acl/ops/acl_dvpp.h"
3 6
@@ -30,4 +33,6 @@ private: @@ -30,4 +33,6 @@ private:
30 int m_devId; 33 int m_devId;
31 aclrtContext m_algorthim_ctx; 34 aclrtContext m_algorthim_ctx;
32 void* m_handle{nullptr}; 35 void* m_handle{nullptr};
33 -};  
34 \ No newline at end of file 36 \ No newline at end of file
  37 +};
  38 +
  39 +#endif // __AI_ENGINE_MODULE_VPD__
35 \ No newline at end of file 40 \ No newline at end of file
src/ai_engine_module/VPTProcess.h
@@ -4,7 +4,9 @@ @@ -4,7 +4,9 @@
4 * UpdateDate: 20170705 4 * UpdateDate: 20170705
5 * Content: 人车物监测跟踪 5 * Content: 人车物监测跟踪
6 ********************************************************************************************/ 6 ********************************************************************************************/
7 -#pragma once 7 +#ifndef __AI_ENGINE_MODULE_VPT__
  8 +#define __AI_ENGINE_MODULE_VPT__
  9 +
8 #include <iostream> 10 #include <iostream>
9 #include <vector> 11 #include <vector>
10 #include <string> 12 #include <string>
@@ -82,3 +84,6 @@ private: @@ -82,3 +84,6 @@ private:
82 int m_max_batchsize; 84 int m_max_batchsize;
83 map<string, TaskTracker> taskTrackers; 85 map<string, TaskTracker> taskTrackers;
84 }; 86 };
  87 +
  88 +
  89 +#endif // __AI_ENGINE_MODULE_VPT__
85 \ No newline at end of file 90 \ No newline at end of file
src/ai_engine_module/VehicleColor.h
  1 +#ifndef __AI_ENGINE_MODULE_VEHICLE_COLOR__
  2 +#define __AI_ENGINE_MODULE_VEHICLE_COLOR__
  3 +
1 #include "acl/acl.h" 4 #include "acl/acl.h"
2 #include "acl/ops/acl_dvpp.h" 5 #include "acl/ops/acl_dvpp.h"
3 6
@@ -28,4 +31,6 @@ private: @@ -28,4 +31,6 @@ private:
28 int m_devId; 31 int m_devId;
29 aclrtContext m_algorthim_ctx; 32 aclrtContext m_algorthim_ctx;
30 void* m_handle{nullptr}; 33 void* m_handle{nullptr};
31 -};  
32 \ No newline at end of file 34 \ No newline at end of file
  35 +};
  36 +
  37 +#endif // __AI_ENGINE_MODULE_VEHICLE_COLOR__
33 \ No newline at end of file 38 \ No newline at end of file
src/ai_engine_module/VehiclePlate.h
  1 +#ifndef __AI_ENGINE_MODULE_VEHICLE_PLATE__
  2 +#define __AI_ENGINE_MODULE_VEHICLE_PLATE__
  3 +
1 #include "acl/acl.h" 4 #include "acl/acl.h"
2 #include "acl/ops/acl_dvpp.h" 5 #include "acl/ops/acl_dvpp.h"
3 6
@@ -25,4 +28,6 @@ private: @@ -25,4 +28,6 @@ private:
25 int m_devId; 28 int m_devId;
26 aclrtContext m_algorthim_ctx; 29 aclrtContext m_algorthim_ctx;
27 void* m_handle{nullptr}; 30 void* m_handle{nullptr};
28 -};  
29 \ No newline at end of file 31 \ No newline at end of file
  32 +};
  33 +
  34 +#endif // __AI_ENGINE_MODULE_VEHICLE_PLATE__
30 \ No newline at end of file 35 \ No newline at end of file
src/ai_platform/FeatureAnalysis.cpp
@@ -88,7 +88,7 @@ void FeatureAnalysis::update_human_info(ObjectInfo&amp; res_obj, vpc_img_info&amp; img_i @@ -88,7 +88,7 @@ void FeatureAnalysis::update_human_info(ObjectInfo&amp; res_obj, vpc_img_info&amp; img_i
88 if (vec_hf_res.size() > 0) 88 if (vec_hf_res.size() > 0)
89 { 89 {
90 HFResult hf_res = vec_hf_res[0]; 90 HFResult hf_res = vec_hf_res[0];
91 - memcpy(res_obj.hp_feature, hf_res.feature, sizeof(float) * HUMANREID_FEATURESIZE); 91 + memcpy(res_obj.hp_feature, hf_res.feature, sizeof(float) * HUMANREID_FEATURE_SIZE);
92 } 92 }
93 } 93 }
94 94
src/ai_platform/header.h
1 -#pragma once 1 +#ifndef __AI_PLATFORM_HEADER__
  2 +#define __AI_PLATFORM_HEADER__
2 3
3 #ifdef _MSC_VER 4 #ifdef _MSC_VER
4 #include <windows.h> 5 #include <windows.h>
@@ -13,11 +14,11 @@ @@ -13,11 +14,11 @@
13 #include <vector> 14 #include <vector>
14 #include <string> 15 #include <string>
15 16
16 -#include "../ai_engine_module/humanreid.h"  
17 -#include "../ai_engine_module/human_parsing.h"  
18 17
19 18
20 -#define VEHICLE_FEA_SIZE 128 19 +#define HUMANREID_FEATURE_SIZE 384
  20 +#define HP_ATTRI_SIZE 16
  21 +
21 #define PLATENUM 8 //车牌号码位数 22 #define PLATENUM 8 //车牌号码位数
22 #define MAX_PALTE_COUNT 10 //每张图片中最多检测出10个车牌 23 #define MAX_PALTE_COUNT 10 //每张图片中最多检测出10个车牌
23 24
@@ -35,8 +36,6 @@ using namespace std; @@ -35,8 +36,6 @@ using namespace std;
35 36
36 37
37 //返回的检测物体结果信息 38 //返回的检测物体结果信息
38 -#ifndef __VIDEO_OBJECT_INFO__  
39 -#define __VIDEO_OBJECT_INFO__  
40 typedef struct video_object_info { 39 typedef struct video_object_info {
41 char task_id[128]; //该物体属于的任务ID号 40 char task_id[128]; //该物体属于的任务ID号
42 int task_frame_count; //该物体当前出现的帧号 41 int task_frame_count; //该物体当前出现的帧号
@@ -48,7 +47,6 @@ typedef struct video_object_info { @@ -48,7 +47,6 @@ typedef struct video_object_info {
48 int index; //该物体所属类别的编号 47 int index; //该物体所属类别的编号
49 double confidence; //该物体的置信度 48 double confidence; //该物体的置信度
50 } video_object_info; 49 } video_object_info;
51 -#endif  
52 50
53 51
54 52
@@ -106,8 +104,8 @@ typedef struct ObjectData { @@ -106,8 +104,8 @@ typedef struct ObjectData {
106 string ori_pic_path; 104 string ori_pic_path;
107 string obj_pic_path; 105 string obj_pic_path;
108 106
109 - hp_cls_info hp_cls[HP_ATTRI_INDEX_SIZE];  
110 - float hp_feature[HUMANREID_FEATURESIZE]; 107 + hp_cls_info hp_cls[HP_ATTRI_SIZE];
  108 + float hp_feature[HUMANREID_FEATURE_SIZE];
111 109
112 int vehicle_color_index; 110 int vehicle_color_index;
113 float vehicle_color_prob; 111 float vehicle_color_prob;
@@ -118,9 +116,6 @@ typedef struct ObjectData { @@ -118,9 +116,6 @@ typedef struct ObjectData {
118 116
119 117
120 // TASK初始化参数 118 // TASK初始化参数
121 -#ifndef __TASK_PARAM__  
122 -#define __TASK_PARAM__  
123 -  
124 typedef struct task_param { 119 typedef struct task_param {
125 string ipc_url; //rtsp流地址 120 string ipc_url; //rtsp流地址
126 string task_id; //外部传入任务id 121 string task_id; //外部传入任务id
@@ -129,10 +124,8 @@ typedef struct task_param { @@ -129,10 +124,8 @@ typedef struct task_param {
129 string result_folder_little; //目标快照抠图保存地址 124 string result_folder_little; //目标快照抠图保存地址
130 string result_folder; //目标快照大图保存地址 125 string result_folder; //目标快照大图保存地址
131 } task_param; 126 } task_param;
132 -#endif  
133 127
134 -#ifndef __AI_LOG_LEVEL__  
135 -#define __AI_LOG_LEVEL__ 128 +
136 enum ai_log_level { 129 enum ai_log_level {
137 AI_LOG_LEVEL_CLOSE = -1, // 关闭日志 130 AI_LOG_LEVEL_CLOSE = -1, // 关闭日志
138 AI_LOG_LEVEL_TRACE = 0, // 跟踪变量 131 AI_LOG_LEVEL_TRACE = 0, // 跟踪变量
@@ -141,12 +134,9 @@ enum ai_log_level { @@ -141,12 +134,9 @@ enum ai_log_level {
141 AI_LOG_LEVEL_WARNING = 3, // 警告日志通知,模块一切正常(如:重要流程通知) 134 AI_LOG_LEVEL_WARNING = 3, // 警告日志通知,模块一切正常(如:重要流程通知)
142 AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误 135 AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误
143 }; 136 };
144 -#endif  
145 137
146 138
147 //VPT初始化参数 139 //VPT初始化参数
148 -#ifndef __TSL_AIPLATFORM_PARAM__  
149 -#define __TSL_AIPLATFORM_PARAM__  
150 typedef struct tsl_aiplatform_param { 140 typedef struct tsl_aiplatform_param {
151 int gpuid; //指定显卡id 141 int gpuid; //指定显卡id
152 string models_dir; // 模型文件目录 142 string models_dir; // 模型文件目录
@@ -156,4 +146,5 @@ typedef struct tsl_aiplatform_param { @@ -156,4 +146,5 @@ typedef struct tsl_aiplatform_param {
156 int log_days; //日志保存周期 146 int log_days; //日志保存周期
157 double log_mem; //每个日志最大大小 147 double log_mem; //每个日志最大大小
158 } tsl_aiplatform_param; 148 } tsl_aiplatform_param;
159 -#endif  
160 \ No newline at end of file 149 \ No newline at end of file
  150 +
  151 +#endif // __AI_PLATFORM_HEADER__
161 \ No newline at end of file 152 \ No newline at end of file
src/ai_platform/mvpt.cpp
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 22
23 // #define VEHICLE_MULTI_BOXES 23 // #define VEHICLE_MULTI_BOXES
24 24
25 -#define AUTHORIZATION 25 +// #define AUTHORIZATION
26 #define productSN "51C4B28135604F649671727185949A91" //linux 通途抓拍引擎产品序列号 26 #define productSN "51C4B28135604F649671727185949A91" //linux 通途抓拍引擎产品序列号
27 27
28 using namespace std; 28 using namespace std;