Commit e3062370a5bacee76a868edd3cd68ecad1c78e67
1 parent
581a68a4
优化日志
Showing
14 changed files
with
61 additions
and
34 deletions
jni/VehicleNativeInterface.cpp
... | ... | @@ -129,14 +129,33 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI |
129 | 129 | jfieldID fid_sdk_path = env->GetFieldID(cls_vehcileAnalysisParam, "sdk_path", "Ljava/lang/String;"); |
130 | 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 | 137 | jstring str_sdk_path = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_sdk_path); |
133 | 138 | const char *sdk_path = env->GetStringUTFChars(str_sdk_path, JNI_FALSE); |
134 | 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 | 148 | void *vaHandle = NULL; |
137 | 149 | VillageParam param; |
138 | 150 | param.dev_id = gpuid; |
139 | 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 | 159 | int ret = village_pic_init(&vaHandle, param); |
141 | 160 | if (ret != SUCCESS) { |
142 | 161 | printf("jni info:va_init failed."); | ... | ... |
src/PicAnalysis.cpp
... | ... | @@ -15,6 +15,14 @@ PicAnalysis::~PicAnalysis() |
15 | 15 | |
16 | 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 | 26 | int dev_id = param.dev_id; |
19 | 27 | |
20 | 28 | int ret = SY_FAILED; |
... | ... | @@ -393,12 +401,4 @@ int PicAnalysis::release() { |
393 | 401 | aclrtDestroyContext(m_ctx); |
394 | 402 | |
395 | 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 | 405 | \ No newline at end of file | ... | ... |
src/PicAnalysis.h
... | ... | @@ -28,13 +28,8 @@ public: |
28 | 28 | vector<AnalysisResult> analysis_img(vector<sy_img> vec_img); |
29 | 29 | |
30 | 30 | private: |
31 | - | |
32 | 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 | 33 | vector<AnalysisResult> va_result2AnalysisResult(va_result* result, int batchsize); |
39 | 34 | |
40 | 35 | private: | ... | ... |
src/ai_engine_module/HumanAnalysis.cpp
... | ... | @@ -21,13 +21,13 @@ int HumanAnalysis::init(int devId, std::string sdk_root){ |
21 | 21 | param.modelNames = (char*)model_path.data(); |
22 | 22 | param.devId = devId; |
23 | 23 | |
24 | - cout << "hp_init start " << endl; | |
24 | + LOG_INFO("hp_init start"); | |
25 | 25 | int ret = hp_init(&m_handle, param); |
26 | 26 | if (ret != 0) { |
27 | 27 | return -1; |
28 | 28 | } |
29 | 29 | |
30 | - cout << "hp_init success " << endl; | |
30 | + LOG_INFO("hp_init success"); | |
31 | 31 | |
32 | 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 | 23 | param.modelNames = (char*)model_path.data(); |
24 | 24 | param.devId = devId; |
25 | 25 | |
26 | - cout << "hcp_init start " << endl; | |
26 | + LOG_INFO("hcp_init start"); | |
27 | 27 | int ret = hcp_init(&m_handle, param); |
28 | 28 | if (ret != 0) { |
29 | 29 | return -1; |
30 | 30 | } |
31 | 31 | |
32 | - cout << "hcp_init success " << endl; | |
32 | + LOG_INFO("hcp_init success"); | |
33 | 33 | |
34 | 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 | 20 | param.thresld = 0.25; |
21 | 21 | param.devId = devId; |
22 | 22 | |
23 | - cout << "motor_phone_init start " << endl; | |
23 | + LOG_INFO("motor_phone_init start"); | |
24 | 24 | int ret = motor_phone_init(&m_handle, param); |
25 | 25 | if (ret != 0) { |
26 | 26 | return -1; |
27 | 27 | } |
28 | 28 | |
29 | - cout << "motor_phone_init success " << endl; | |
29 | + LOG_INFO("motor_phone_init success"); | |
30 | 30 | |
31 | 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 | 20 | param.thresld = 0.0; |
21 | 21 | param.devId = devId; |
22 | 22 | |
23 | - cout << "mrc_init start " << endl; | |
23 | + LOG_INFO("mrc_init start"); | |
24 | 24 | int ret = mrc_init(&m_handle, param); |
25 | 25 | if (ret != 0) { |
26 | 26 | return -1; |
27 | 27 | } |
28 | 28 | |
29 | - cout << "mrc_init success " << endl; | |
29 | + LOG_INFO("mrc_init success"); | |
30 | 30 | |
31 | 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 | 22 | param.thresld = 0.25; |
23 | 23 | param.devId = devId; |
24 | 24 | |
25 | - cout << "rs_init start " << endl; | |
25 | + LOG_INFO("rs_init start"); | |
26 | 26 | int ret = rs_init(&m_handle, param); |
27 | 27 | if (ret != 0) { |
28 | 28 | return -1; |
29 | 29 | } |
30 | 30 | |
31 | - cout << "rs_init success " << endl; | |
31 | + LOG_INFO("rs_init success"); | |
32 | 32 | |
33 | 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 | 58 | param.dbPath= (char*)dbPath.data(); |
59 | 59 | param.models_Path= (char*)models_path.data(); //所有模型的地址 |
60 | 60 | |
61 | - cout << "va_init start " << endl; | |
61 | + LOG_INFO("va_init start"); | |
62 | 62 | // 内部有 ctx |
63 | 63 | int ret = va_init(&m_handle, param); |
64 | 64 | if (ret != 0) { |
65 | 65 | return -1; |
66 | 66 | } |
67 | 67 | |
68 | - cout << "va_init success " << endl; | |
68 | + LOG_INFO("va_init success"); | |
69 | 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 | 19 | param.thresld = 0.0; |
20 | 20 | param.devId = devId; |
21 | 21 | |
22 | - cout << "vidclothes_init start " << endl; | |
22 | + LOG_INFO("vidclothes_init start"); | |
23 | 23 | int ret = vidclothes_init(&m_handle, param); |
24 | 24 | if (ret != 0) { |
25 | 25 | return -1; |
26 | 26 | } |
27 | 27 | |
28 | - cout << "vidclothes_init success " << endl; | |
28 | + LOG_INFO("vidclothes_init success"); | |
29 | 29 | |
30 | 30 | return SY_SUCCESS; |
31 | 31 | } | ... | ... |
src/ai_engine_module/include.h
src/common/sy_common.h
... | ... | @@ -21,21 +21,21 @@ |
21 | 21 | #define ENGINE_TENSORRT 201 |
22 | 22 | |
23 | 23 | |
24 | -//针对多功能SDK,用于初始化参数配置,根据该参数可判断所对应的功能模块是否启动运行 | |
24 | +//锟斤拷远喙︼拷锟絊DK锟斤拷锟斤拷锟节筹拷始锟斤拷锟斤拷锟斤拷锟斤拷锟矫o拷锟斤拷锟捷该诧拷锟斤拷锟斤拷锟叫讹拷锟斤拷锟斤拷应锟侥癸拷锟斤拷模锟斤拷锟角凤拷锟斤拷锟斤拷锟斤拷锟斤拷 | |
25 | 25 | #ifndef __SY_COMMAND__ |
26 | 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 | 31 | #endif |
32 | 32 | |
33 | 33 | |
34 | -//用于指定输入的图像数据的格式 | |
34 | +//锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟酵硷拷锟斤拷锟斤拷莸母锟绞 | |
35 | 35 | #ifndef __SY_FORMAT__ |
36 | 36 | #define __SY_FORMAT__ |
37 | -typedef enum sy_format { | |
38 | - SY_FORMAT_BGR888, //目前只支持该种解码格式 | |
37 | +enum sy_format { | |
38 | + SY_FORMAT_BGR888, //目前只支锟街革拷锟街斤拷锟斤拷锟绞 | |
39 | 39 | SY_FORMAT_BGRA888, |
40 | 40 | SY_FORMAT_GRAY8, |
41 | 41 | SY_FORMAT_YUV4420P, | ... | ... |
src/demo/main.cpp
src/village_inc.h
... | ... | @@ -12,6 +12,17 @@ |
12 | 12 | struct VillageParam { |
13 | 13 | int dev_id; |
14 | 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 | 28 | typedef struct pendant_info | ... | ... |