Commit e3062370a5bacee76a868edd3cd68ecad1c78e67

Authored by Hu Chunming
1 parent 581a68a4

优化日志

jni/VehicleNativeInterface.cpp
@@ -129,14 +129,33 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI @@ -129,14 +129,33 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI
129 jfieldID fid_sdk_path = env->GetFieldID(cls_vehcileAnalysisParam, "sdk_path", "Ljava/lang/String;"); 129 jfieldID fid_sdk_path = env->GetFieldID(cls_vehcileAnalysisParam, "sdk_path", "Ljava/lang/String;");
130 jfieldID fid_gpuid = env->GetFieldID(cls_vehcileAnalysisParam, "gpuId", "I"); 130 jfieldID fid_gpuid = env->GetFieldID(cls_vehcileAnalysisParam, "gpuId", "I");
131 131
  132 + jfieldID fid_aiEngineParam_logLevel = env->GetFieldID(cls_vehcileAnalysisParam, "logLevel", "I");
  133 + jfieldID fid_aiEngineParam_logPath = env->GetFieldID(cls_vehcileAnalysisParam, "logPath", "Ljava/lang/String;");
  134 + jfieldID fid_aiEngineParam_logDays = env->GetFieldID(cls_vehcileAnalysisParam, "logDays", "I");
  135 + jfieldID fid_aiEngineParam_logMem = env->GetFieldID(cls_vehcileAnalysisParam, "logMem", "D");
  136 +
132 jstring str_sdk_path = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_sdk_path); 137 jstring str_sdk_path = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_sdk_path);
133 const char *sdk_path = env->GetStringUTFChars(str_sdk_path, JNI_FALSE); 138 const char *sdk_path = env->GetStringUTFChars(str_sdk_path, JNI_FALSE);
134 jint gpuid = env->GetIntField(vehicleAnalysisParam, fid_gpuid); 139 jint gpuid = env->GetIntField(vehicleAnalysisParam, fid_gpuid);
135 140
  141 + //log
  142 + jstring str_aiEngineParam_logPath = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_aiEngineParam_logPath);
  143 + const char* aiEngineParam_logPath = env->GetStringUTFChars(str_aiEngineParam_logPath, JNI_FALSE);
  144 + jint aiEngineParam_logDays = env->GetIntField(vehicleAnalysisParam, fid_aiEngineParam_logDays);
  145 + jdouble aiEngineParam_logMem = env->GetDoubleField(vehicleAnalysisParam, fid_aiEngineParam_logMem);
  146 + jint aiEngineParam_logLevel = env->GetIntField(vehicleAnalysisParam, fid_aiEngineParam_logLevel);
  147 +
136 void *vaHandle = NULL; 148 void *vaHandle = NULL;
137 VillageParam param; 149 VillageParam param;
138 param.dev_id = gpuid; 150 param.dev_id = gpuid;
139 param.sdk_path = sdk_path; 151 param.sdk_path = sdk_path;
  152 + param.log_level = aiEngineParam_logLevel;
  153 + param.log_path = aiEngineParam_logPath;
  154 + param.log_days = aiEngineParam_logDays;
  155 + param.log_mem = aiEngineParam_logMem;
  156 +
  157 + printf("jni dev_id:%d sdk_path:%s_log_level:%d\n", param.dev_id, param.sdk_path.c_str(), param.log_level);
  158 +
140 int ret = village_pic_init(&vaHandle, param); 159 int ret = village_pic_init(&vaHandle, param);
141 if (ret != SUCCESS) { 160 if (ret != SUCCESS) {
142 printf("jni info:va_init failed."); 161 printf("jni info:va_init failed.");
src/PicAnalysis.cpp
@@ -15,6 +15,14 @@ PicAnalysis::~PicAnalysis() @@ -15,6 +15,14 @@ PicAnalysis::~PicAnalysis()
15 15
16 int PicAnalysis::init(VillageParam param) { 16 int PicAnalysis::init(VillageParam param) {
17 17
  18 + set_default_logger(LogLevel(param.log_level), "PicAnalysis", param.log_path.c_str(), param.log_mem, param.log_days);
  19 +
  20 + // 输入参数
  21 + LOG_INFO("dev_id: {}", param.dev_id);
  22 + LOG_INFO("sdk_path: {}", param.sdk_path);
  23 + LOG_INFO("log_level: {}", param.log_level);
  24 + LOG_INFO("log_days: {}", param.log_days);
  25 +
18 int dev_id = param.dev_id; 26 int dev_id = param.dev_id;
19 27
20 int ret = SY_FAILED; 28 int ret = SY_FAILED;
@@ -393,12 +401,4 @@ int PicAnalysis::release() { @@ -393,12 +401,4 @@ int PicAnalysis::release() {
393 aclrtDestroyContext(m_ctx); 401 aclrtDestroyContext(m_ctx);
394 402
395 return 0; 403 return 0;
396 -}  
397 -  
398 -int PicAnalysis::human_analysis(vector<sy_img> vec_img) {  
399 - vector<BodyColorInfo> vec_body_color = m_human_algorithm.detect(vec_img);  
400 -}  
401 -  
402 -int PicAnalysis::check_motor_retrograde_motion(vector<sy_img> vec_motor_img) {  
403 - m_human_car_algorithm.detect(vec_motor_img);  
404 } 404 }
405 \ No newline at end of file 405 \ No newline at end of file
src/PicAnalysis.h
@@ -28,13 +28,8 @@ public: @@ -28,13 +28,8 @@ public:
28 vector<AnalysisResult> analysis_img(vector<sy_img> vec_img); 28 vector<AnalysisResult> analysis_img(vector<sy_img> vec_img);
29 29
30 private: 30 private:
31 -  
32 int release(); 31 int release();
33 32
34 - int human_analysis(vector<sy_img> vec_img);  
35 -  
36 - int check_motor_retrograde_motion(vector<sy_img> vec_img);  
37 -  
38 vector<AnalysisResult> va_result2AnalysisResult(va_result* result, int batchsize); 33 vector<AnalysisResult> va_result2AnalysisResult(va_result* result, int batchsize);
39 34
40 private: 35 private:
src/ai_engine_module/HumanAnalysis.cpp
@@ -21,13 +21,13 @@ int HumanAnalysis::init(int devId, std::string sdk_root){ @@ -21,13 +21,13 @@ int HumanAnalysis::init(int devId, std::string sdk_root){
21 param.modelNames = (char*)model_path.data(); 21 param.modelNames = (char*)model_path.data();
22 param.devId = devId; 22 param.devId = devId;
23 23
24 - cout << "hp_init start " << endl; 24 + LOG_INFO("hp_init start");
25 int ret = hp_init(&m_handle, param); 25 int ret = hp_init(&m_handle, param);
26 if (ret != 0) { 26 if (ret != 0) {
27 return -1; 27 return -1;
28 } 28 }
29 29
30 - cout << "hp_init success " << endl; 30 + LOG_INFO("hp_init success");
31 31
32 return SY_SUCCESS; 32 return SY_SUCCESS;
33 } 33 }
src/ai_engine_module/HumanCarAnalysis.cpp
@@ -23,13 +23,13 @@ int HumanCarAnalysis::init(int devId, std::string sdk_root){ @@ -23,13 +23,13 @@ int HumanCarAnalysis::init(int devId, std::string sdk_root){
23 param.modelNames = (char*)model_path.data(); 23 param.modelNames = (char*)model_path.data();
24 param.devId = devId; 24 param.devId = devId;
25 25
26 - cout << "hcp_init start " << endl; 26 + LOG_INFO("hcp_init start");
27 int ret = hcp_init(&m_handle, param); 27 int ret = hcp_init(&m_handle, param);
28 if (ret != 0) { 28 if (ret != 0) {
29 return -1; 29 return -1;
30 } 30 }
31 31
32 - cout << "hcp_init success " << endl; 32 + LOG_INFO("hcp_init success");
33 33
34 return SY_SUCCESS; 34 return SY_SUCCESS;
35 } 35 }
src/ai_engine_module/MotorPhoneAnalysis.cpp
@@ -20,13 +20,13 @@ int MotorPhoneAnalysis::init(int devId, std::string sdk_root){ @@ -20,13 +20,13 @@ int MotorPhoneAnalysis::init(int devId, std::string sdk_root){
20 param.thresld = 0.25; 20 param.thresld = 0.25;
21 param.devId = devId; 21 param.devId = devId;
22 22
23 - cout << "motor_phone_init start " << endl; 23 + LOG_INFO("motor_phone_init start");
24 int ret = motor_phone_init(&m_handle, param); 24 int ret = motor_phone_init(&m_handle, param);
25 if (ret != 0) { 25 if (ret != 0) {
26 return -1; 26 return -1;
27 } 27 }
28 28
29 - cout << "motor_phone_init success " << endl; 29 + LOG_INFO("motor_phone_init success");
30 30
31 return SY_SUCCESS; 31 return SY_SUCCESS;
32 } 32 }
src/ai_engine_module/MotorRainshedAnalysis.cpp
@@ -20,13 +20,13 @@ int MotorRainshedAnalysis::init(int devId, std::string sdk_root){ @@ -20,13 +20,13 @@ int MotorRainshedAnalysis::init(int devId, std::string sdk_root){
20 param.thresld = 0.0; 20 param.thresld = 0.0;
21 param.devId = devId; 21 param.devId = devId;
22 22
23 - cout << "mrc_init start " << endl; 23 + LOG_INFO("mrc_init start");
24 int ret = mrc_init(&m_handle, param); 24 int ret = mrc_init(&m_handle, param);
25 if (ret != 0) { 25 if (ret != 0) {
26 return -1; 26 return -1;
27 } 27 }
28 28
29 - cout << "mrc_init success " << endl; 29 + LOG_INFO("mrc_init success");
30 30
31 return SY_SUCCESS; 31 return SY_SUCCESS;
32 } 32 }
src/ai_engine_module/RoadSegAnalysis.cpp
@@ -22,13 +22,13 @@ int RoadSegAnalysis::init(int devId, std::string sdk_root){ @@ -22,13 +22,13 @@ int RoadSegAnalysis::init(int devId, std::string sdk_root){
22 param.thresld = 0.25; 22 param.thresld = 0.25;
23 param.devId = devId; 23 param.devId = devId;
24 24
25 - cout << "rs_init start " << endl; 25 + LOG_INFO("rs_init start");
26 int ret = rs_init(&m_handle, param); 26 int ret = rs_init(&m_handle, param);
27 if (ret != 0) { 27 if (ret != 0) {
28 return -1; 28 return -1;
29 } 29 }
30 30
31 - cout << "rs_init success " << endl; 31 + LOG_INFO("rs_init success");
32 32
33 return SY_SUCCESS; 33 return SY_SUCCESS;
34 } 34 }
src/ai_engine_module/VehicleAnalysis.cpp
@@ -58,14 +58,14 @@ int VehicleAnalysis::init(int devId, std::string sdk_root, int max_batch_size) { @@ -58,14 +58,14 @@ int VehicleAnalysis::init(int devId, std::string sdk_root, int max_batch_size) {
58 param.dbPath= (char*)dbPath.data(); 58 param.dbPath= (char*)dbPath.data();
59 param.models_Path= (char*)models_path.data(); //所有模型的地址 59 param.models_Path= (char*)models_path.data(); //所有模型的地址
60 60
61 - cout << "va_init start " << endl; 61 + LOG_INFO("va_init start");
62 // 内部有 ctx 62 // 内部有 ctx
63 int ret = va_init(&m_handle, param); 63 int ret = va_init(&m_handle, param);
64 if (ret != 0) { 64 if (ret != 0) {
65 return -1; 65 return -1;
66 } 66 }
67 67
68 - cout << "va_init success " << endl; 68 + LOG_INFO("va_init success");
69 return 0; 69 return 0;
70 } 70 }
71 71
src/ai_engine_module/VidClothes.cpp
@@ -19,13 +19,13 @@ int VidClothes::init(int devId, std::string sdk_root){ @@ -19,13 +19,13 @@ int VidClothes::init(int devId, std::string sdk_root){
19 param.thresld = 0.0; 19 param.thresld = 0.0;
20 param.devId = devId; 20 param.devId = devId;
21 21
22 - cout << "vidclothes_init start " << endl; 22 + LOG_INFO("vidclothes_init start");
23 int ret = vidclothes_init(&m_handle, param); 23 int ret = vidclothes_init(&m_handle, param);
24 if (ret != 0) { 24 if (ret != 0) {
25 return -1; 25 return -1;
26 } 26 }
27 27
28 - cout << "vidclothes_init success " << endl; 28 + LOG_INFO("vidclothes_init success");
29 29
30 return SY_SUCCESS; 30 return SY_SUCCESS;
31 } 31 }
src/ai_engine_module/include.h
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 #include "utils.h" 17 #include "utils.h"
18 #include "dvpp_process.h" 18 #include "dvpp_process.h"
19 19
  20 +#include "../utils/logger.hpp"
20 21
21 #include <chrono> 22 #include <chrono>
22 #include <dirent.h> 23 #include <dirent.h>
src/common/sy_common.h
@@ -21,21 +21,21 @@ @@ -21,21 +21,21 @@
21 #define ENGINE_TENSORRT 201 21 #define ENGINE_TENSORRT 201
22 22
23 23
24 -//针对多功能SDK,用于初始化参数配置,根据该参数可判断所对应的功能模块是否启动运行 24 +//锟斤拷远喙︼拷锟絊DK锟斤拷锟斤拷锟节筹拷始锟斤拷锟斤拷锟斤拷锟斤拷锟矫o拷锟斤拷锟捷该诧拷锟斤拷锟斤拷锟叫讹拷锟斤拷锟斤拷应锟侥癸拷锟斤拷模锟斤拷锟角凤拷锟斤拷锟斤拷锟斤拷锟斤拷
25 #ifndef __SY_COMMAND__ 25 #ifndef __SY_COMMAND__
26 #define __SY_COMMAND__ 26 #define __SY_COMMAND__
27 -typedef enum sy_command {  
28 - SY_CONFIG_OPEN, //该功能启动  
29 - SY_CONFIG_CLOSE //该功能不启动 27 +enum sy_command {
  28 + SY_CONFIG_OPEN, //锟矫癸拷锟斤拷锟斤拷锟斤拷
  29 + SY_CONFIG_CLOSE //锟矫癸拷锟杰诧拷锟斤拷锟斤拷
30 }; 30 };
31 #endif 31 #endif
32 32
33 33
34 -//用于指定输入的图像数据的格式 34 +//锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟酵硷拷锟斤拷锟斤拷莸母锟绞
35 #ifndef __SY_FORMAT__ 35 #ifndef __SY_FORMAT__
36 #define __SY_FORMAT__ 36 #define __SY_FORMAT__
37 -typedef enum sy_format {  
38 - SY_FORMAT_BGR888, //目前只支持该种解码格式 37 +enum sy_format {
  38 + SY_FORMAT_BGR888, //目前只支锟街革拷锟街斤拷锟斤拷锟绞
39 SY_FORMAT_BGRA888, 39 SY_FORMAT_BGRA888,
40 SY_FORMAT_GRAY8, 40 SY_FORMAT_GRAY8,
41 SY_FORMAT_YUV4420P, 41 SY_FORMAT_YUV4420P,
src/demo/main.cpp
@@ -11,6 +11,7 @@ int main() { @@ -11,6 +11,7 @@ int main() {
11 VillageParam param; 11 VillageParam param;
12 param.dev_id = 0; 12 param.dev_id = 0;
13 param.sdk_path = "."; 13 param.sdk_path = ".";
  14 + param.log_level = 1;
14 int ret = village_pic_init(&vaHandle, param); 15 int ret = village_pic_init(&vaHandle, param);
15 16
16 vector<string> vec_path; 17 vector<string> vec_path;
src/village_inc.h
@@ -12,6 +12,17 @@ @@ -12,6 +12,17 @@
12 struct VillageParam { 12 struct VillageParam {
13 int dev_id; 13 int dev_id;
14 std::string sdk_path; 14 std::string sdk_path;
  15 +
  16 + // AI_LOG_LEVEL_CLOSE = -1, // 关闭日
  17 + // AI_LOG_LEVEL_TRACE = 0, // 跟踪变量
  18 + // AI_LOG_LEVEL_DEBUG = 1, // 调试日志
  19 + // AI_LOG_LEVEL_INFO = 2, // 普通日志信息 (如:无关紧要的信息输出)
  20 + // AI_LOG_LEVEL_WARNING = 3, // 警告日志通知,模块一切正常(如:重要流程通知)
  21 + // AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误
  22 + int log_level{2};
  23 + int log_days{30}; //日志保存周期
  24 + std::string log_path{"logs/main.log"}; //日志文件路径
  25 + unsigned long log_mem{64 * 1024 * 1024}; //每个日志最大大小
15 }; 26 };
16 27
17 typedef struct pendant_info 28 typedef struct pendant_info