diff --git a/jni/VehicleNativeInterface.cpp b/jni/VehicleNativeInterface.cpp index bf725a3..0ab6b1a 100644 --- a/jni/VehicleNativeInterface.cpp +++ b/jni/VehicleNativeInterface.cpp @@ -129,14 +129,33 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI jfieldID fid_sdk_path = env->GetFieldID(cls_vehcileAnalysisParam, "sdk_path", "Ljava/lang/String;"); jfieldID fid_gpuid = env->GetFieldID(cls_vehcileAnalysisParam, "gpuId", "I"); + jfieldID fid_aiEngineParam_logLevel = env->GetFieldID(cls_vehcileAnalysisParam, "logLevel", "I"); + jfieldID fid_aiEngineParam_logPath = env->GetFieldID(cls_vehcileAnalysisParam, "logPath", "Ljava/lang/String;"); + jfieldID fid_aiEngineParam_logDays = env->GetFieldID(cls_vehcileAnalysisParam, "logDays", "I"); + jfieldID fid_aiEngineParam_logMem = env->GetFieldID(cls_vehcileAnalysisParam, "logMem", "D"); + jstring str_sdk_path = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_sdk_path); const char *sdk_path = env->GetStringUTFChars(str_sdk_path, JNI_FALSE); jint gpuid = env->GetIntField(vehicleAnalysisParam, fid_gpuid); + //log + jstring str_aiEngineParam_logPath = (jstring)env->GetObjectField(vehicleAnalysisParam, fid_aiEngineParam_logPath); + const char* aiEngineParam_logPath = env->GetStringUTFChars(str_aiEngineParam_logPath, JNI_FALSE); + jint aiEngineParam_logDays = env->GetIntField(vehicleAnalysisParam, fid_aiEngineParam_logDays); + jdouble aiEngineParam_logMem = env->GetDoubleField(vehicleAnalysisParam, fid_aiEngineParam_logMem); + jint aiEngineParam_logLevel = env->GetIntField(vehicleAnalysisParam, fid_aiEngineParam_logLevel); + void *vaHandle = NULL; VillageParam param; param.dev_id = gpuid; param.sdk_path = sdk_path; + param.log_level = aiEngineParam_logLevel; + param.log_path = aiEngineParam_logPath; + param.log_days = aiEngineParam_logDays; + param.log_mem = aiEngineParam_logMem; + + printf("jni dev_id:%d sdk_path:%s_log_level:%d\n", param.dev_id, param.sdk_path.c_str(), param.log_level); + int ret = village_pic_init(&vaHandle, param); if (ret != SUCCESS) { printf("jni info:va_init failed."); diff --git a/src/PicAnalysis.cpp b/src/PicAnalysis.cpp index cf06196..39fb5d5 100644 --- a/src/PicAnalysis.cpp +++ b/src/PicAnalysis.cpp @@ -15,6 +15,14 @@ PicAnalysis::~PicAnalysis() int PicAnalysis::init(VillageParam param) { + set_default_logger(LogLevel(param.log_level), "PicAnalysis", param.log_path.c_str(), param.log_mem, param.log_days); + + // 输入参数 + LOG_INFO("dev_id: {}", param.dev_id); + LOG_INFO("sdk_path: {}", param.sdk_path); + LOG_INFO("log_level: {}", param.log_level); + LOG_INFO("log_days: {}", param.log_days); + int dev_id = param.dev_id; int ret = SY_FAILED; @@ -393,12 +401,4 @@ int PicAnalysis::release() { aclrtDestroyContext(m_ctx); return 0; -} - -int PicAnalysis::human_analysis(vector vec_img) { - vector vec_body_color = m_human_algorithm.detect(vec_img); -} - -int PicAnalysis::check_motor_retrograde_motion(vector vec_motor_img) { - m_human_car_algorithm.detect(vec_motor_img); } \ No newline at end of file diff --git a/src/PicAnalysis.h b/src/PicAnalysis.h index cb19b45..150b125 100644 --- a/src/PicAnalysis.h +++ b/src/PicAnalysis.h @@ -28,13 +28,8 @@ public: vector analysis_img(vector vec_img); private: - int release(); - int human_analysis(vector vec_img); - - int check_motor_retrograde_motion(vector vec_img); - vector va_result2AnalysisResult(va_result* result, int batchsize); private: diff --git a/src/ai_engine_module/HumanAnalysis.cpp b/src/ai_engine_module/HumanAnalysis.cpp index e2cb8d6..a6fd6c5 100644 --- a/src/ai_engine_module/HumanAnalysis.cpp +++ b/src/ai_engine_module/HumanAnalysis.cpp @@ -21,13 +21,13 @@ int HumanAnalysis::init(int devId, std::string sdk_root){ param.modelNames = (char*)model_path.data(); param.devId = devId; - cout << "hp_init start " << endl; + LOG_INFO("hp_init start"); int ret = hp_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "hp_init success " << endl; + LOG_INFO("hp_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/HumanCarAnalysis.cpp b/src/ai_engine_module/HumanCarAnalysis.cpp index bc0e8c8..9ffde7a 100644 --- a/src/ai_engine_module/HumanCarAnalysis.cpp +++ b/src/ai_engine_module/HumanCarAnalysis.cpp @@ -23,13 +23,13 @@ int HumanCarAnalysis::init(int devId, std::string sdk_root){ param.modelNames = (char*)model_path.data(); param.devId = devId; - cout << "hcp_init start " << endl; + LOG_INFO("hcp_init start"); int ret = hcp_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "hcp_init success " << endl; + LOG_INFO("hcp_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/MotorPhoneAnalysis.cpp b/src/ai_engine_module/MotorPhoneAnalysis.cpp index a011287..4bb99bd 100644 --- a/src/ai_engine_module/MotorPhoneAnalysis.cpp +++ b/src/ai_engine_module/MotorPhoneAnalysis.cpp @@ -20,13 +20,13 @@ int MotorPhoneAnalysis::init(int devId, std::string sdk_root){ param.thresld = 0.25; param.devId = devId; - cout << "motor_phone_init start " << endl; + LOG_INFO("motor_phone_init start"); int ret = motor_phone_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "motor_phone_init success " << endl; + LOG_INFO("motor_phone_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/MotorRainshedAnalysis.cpp b/src/ai_engine_module/MotorRainshedAnalysis.cpp index 0988fbf..21c438e 100644 --- a/src/ai_engine_module/MotorRainshedAnalysis.cpp +++ b/src/ai_engine_module/MotorRainshedAnalysis.cpp @@ -20,13 +20,13 @@ int MotorRainshedAnalysis::init(int devId, std::string sdk_root){ param.thresld = 0.0; param.devId = devId; - cout << "mrc_init start " << endl; + LOG_INFO("mrc_init start"); int ret = mrc_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "mrc_init success " << endl; + LOG_INFO("mrc_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/RoadSegAnalysis.cpp b/src/ai_engine_module/RoadSegAnalysis.cpp index 40c495d..981a66b 100644 --- a/src/ai_engine_module/RoadSegAnalysis.cpp +++ b/src/ai_engine_module/RoadSegAnalysis.cpp @@ -22,13 +22,13 @@ int RoadSegAnalysis::init(int devId, std::string sdk_root){ param.thresld = 0.25; param.devId = devId; - cout << "rs_init start " << endl; + LOG_INFO("rs_init start"); int ret = rs_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "rs_init success " << endl; + LOG_INFO("rs_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/VehicleAnalysis.cpp b/src/ai_engine_module/VehicleAnalysis.cpp index 9f760a1..da8a640 100644 --- a/src/ai_engine_module/VehicleAnalysis.cpp +++ b/src/ai_engine_module/VehicleAnalysis.cpp @@ -58,14 +58,14 @@ int VehicleAnalysis::init(int devId, std::string sdk_root, int max_batch_size) { param.dbPath= (char*)dbPath.data(); param.models_Path= (char*)models_path.data(); //所有模型的地址 - cout << "va_init start " << endl; + LOG_INFO("va_init start"); // 内部有 ctx int ret = va_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "va_init success " << endl; + LOG_INFO("va_init success"); return 0; } diff --git a/src/ai_engine_module/VidClothes.cpp b/src/ai_engine_module/VidClothes.cpp index 8984b0e..b12f860 100644 --- a/src/ai_engine_module/VidClothes.cpp +++ b/src/ai_engine_module/VidClothes.cpp @@ -19,13 +19,13 @@ int VidClothes::init(int devId, std::string sdk_root){ param.thresld = 0.0; param.devId = devId; - cout << "vidclothes_init start " << endl; + LOG_INFO("vidclothes_init start"); int ret = vidclothes_init(&m_handle, param); if (ret != 0) { return -1; } - cout << "vidclothes_init success " << endl; + LOG_INFO("vidclothes_init success"); return SY_SUCCESS; } diff --git a/src/ai_engine_module/include.h b/src/ai_engine_module/include.h index 5b43049..f3d6922 100644 --- a/src/ai_engine_module/include.h +++ b/src/ai_engine_module/include.h @@ -17,6 +17,7 @@ #include "utils.h" #include "dvpp_process.h" +#include "../utils/logger.hpp" #include #include diff --git a/src/common/sy_common.h b/src/common/sy_common.h index 2e4b211..7c00157 100644 --- a/src/common/sy_common.h +++ b/src/common/sy_common.h @@ -21,21 +21,21 @@ #define ENGINE_TENSORRT 201 -//Զ๦SDKڳʼãݸòжӦĹģǷ +//��Զ๦��SDK�����ڳ�ʼ���������ã����ݸò������ж�����Ӧ�Ĺ���ģ���Ƿ��������� #ifndef __SY_COMMAND__ #define __SY_COMMAND__ -typedef enum sy_command { - SY_CONFIG_OPEN, //ù - SY_CONFIG_CLOSE //ùܲ +enum sy_command { + SY_CONFIG_OPEN, //�ù������� + SY_CONFIG_CLOSE //�ù��ܲ����� }; #endif -//ָͼݵĸʽ +//����ָ�������ͼ�����ݵĸ�ʽ #ifndef __SY_FORMAT__ #define __SY_FORMAT__ -typedef enum sy_format { - SY_FORMAT_BGR888, //Ŀǰָֻֽ֧ʽ +enum sy_format { + SY_FORMAT_BGR888, //Ŀǰֻ֧�ָ��ֽ����ʽ SY_FORMAT_BGRA888, SY_FORMAT_GRAY8, SY_FORMAT_YUV4420P, diff --git a/src/demo/main.cpp b/src/demo/main.cpp index 35596c4..e9b048f 100644 --- a/src/demo/main.cpp +++ b/src/demo/main.cpp @@ -11,6 +11,7 @@ int main() { VillageParam param; param.dev_id = 0; param.sdk_path = "."; + param.log_level = 1; int ret = village_pic_init(&vaHandle, param); vector vec_path; diff --git a/src/village_inc.h b/src/village_inc.h index 4d9af79..aafbbca 100644 --- a/src/village_inc.h +++ b/src/village_inc.h @@ -12,6 +12,17 @@ struct VillageParam { int dev_id; std::string sdk_path; + + // AI_LOG_LEVEL_CLOSE = -1, // 关闭日 + // AI_LOG_LEVEL_TRACE = 0, // 跟踪变量 + // AI_LOG_LEVEL_DEBUG = 1, // 调试日志 + // AI_LOG_LEVEL_INFO = 2, // 普通日志信息 (如:无关紧要的信息输出) + // AI_LOG_LEVEL_WARNING = 3, // 警告日志通知,模块一切正常(如:重要流程通知) + // AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误 + int log_level{2}; + int log_days{30}; //日志保存周期 + std::string log_path{"logs/main.log"}; //日志文件路径 + unsigned long log_mem{64 * 1024 * 1024}; //每个日志最大大小 }; typedef struct pendant_info