diff --git a/APP_Framework/Applications/knowing_app/k210_detect_entry/Kconfig b/APP_Framework/Applications/knowing_app/k210_detect_entry/Kconfig index 30d6ca10..ccdd8026 100644 --- a/APP_Framework/Applications/knowing_app/k210_detect_entry/Kconfig +++ b/APP_Framework/Applications/knowing_app/k210_detect_entry/Kconfig @@ -8,9 +8,3 @@ config K210_DETECT_ENTRY depends on USING_K210_YOLOV2_DETECT select LIB_USING_CJSON default n - -config K210_DETECT_CONFIGJSON - string "k210 detect config path" - default "/kmodel/face.json" - ---help--- - k210 detect task config json path diff --git a/APP_Framework/Applications/knowing_app/k210_detect_entry/face.json b/APP_Framework/Applications/knowing_app/k210_detect_entry/face.json index e3eda7a4..d728931e 100644 --- a/APP_Framework/Applications/knowing_app/k210_detect_entry/face.json +++ b/APP_Framework/Applications/knowing_app/k210_detect_entry/face.json @@ -24,7 +24,6 @@ 6.718375, 9.01025 ], - "kmodel_path": "/kmodel/face.kmodel", "kmodel_size": 388776, "obj_thresh": [ 0.7 diff --git a/APP_Framework/Applications/knowing_app/k210_detect_entry/helmet.json b/APP_Framework/Applications/knowing_app/k210_detect_entry/helmet.json index 260a085b..d780d1c1 100644 --- a/APP_Framework/Applications/knowing_app/k210_detect_entry/helmet.json +++ b/APP_Framework/Applications/knowing_app/k210_detect_entry/helmet.json @@ -24,7 +24,6 @@ 2.1128, 3.184 ], - "kmodel_path": "/kmodel/helmet.kmodel", "kmodel_size": 2714044, "obj_thresh": [ 0.7, diff --git a/APP_Framework/Applications/knowing_app/k210_detect_entry/instrusion.json b/APP_Framework/Applications/knowing_app/k210_detect_entry/instrusion.json index 9642a4c1..55082d74 100644 --- a/APP_Framework/Applications/knowing_app/k210_detect_entry/instrusion.json +++ b/APP_Framework/Applications/knowing_app/k210_detect_entry/instrusion.json @@ -24,7 +24,6 @@ 2.049, 4.6711 ], - "kmodel_path": "/kmodel/instrusion.kmodel", "kmodel_size": 2713236, "obj_thresh": [ 0.7 diff --git a/APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c b/APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c index ab8db673..948d98cf 100644 --- a/APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c +++ b/APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c @@ -3,7 +3,19 @@ #endif #include -static void detect_app() { k210_detect(K210_DETECT_CONFIGJSON); } +static void detect_app(int argc, char *argv[]) +{ + if (2 != argc) { + printf("Usage: detect_app "); + exit(-1); + } + + k210_detect(argv[1]); + + return; +} +// clang-format off #ifdef __RT_THREAD_H__ -MSH_CMD_EXPORT(detect_app, detect app); -#endif \ No newline at end of file +MSH_CMD_EXPORT(detect_app, k210 detect app usage: detect_app ); +#endif +// clang-format on diff --git a/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c b/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c index 668e9fc6..0bdbe343 100644 --- a/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c +++ b/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c @@ -34,6 +34,8 @@ void k210_detect(char *json_file_path) int ret = 0; int result = 0; int size = 0; + char kmodel_path[127] = {}; + yolov2_params_t detect_params = param_parse(json_file_path); g_fd = open("/dev/ov2640", O_RDONLY); if (g_fd < 0) { @@ -72,8 +74,16 @@ void k210_detect(char *json_file_path) /* load memory */ - printf("%s\n", detect_params.kmodel_path); - kmodel_fd = open(detect_params.kmodel_path, O_RDONLY); + // kmodel path generate from json file path, *.json -> *.kmodel + memcpy(kmodel_path, json_file_path, strlen(json_file_path)); + int idx_suffix_start = strlen(json_file_path) - 4; + const char kmodel_suffix[7] = "kmodel"; + int kmodel_suffix_len = 6; + while (kmodel_suffix_len--) { + kmodel_path[idx_suffix_start + 5 - kmodel_suffix_len] = kmodel_suffix[5 - kmodel_suffix_len]; + } + printf("kmodel path: %s\n", kmodel_path); + kmodel_fd = open(kmodel_path, O_RDONLY); if (kmodel_fd < 0) { printf("open kmodel fail"); close(g_fd); @@ -225,7 +235,17 @@ void detect_delete() // { // int kmodel_fd = 0; // int size = 0; -// kmodel_fd = open(detect_params.kmodel_path, O_RDONLY); +// char kmodel_path[127] = {}; +// // kmodel path generate from json file path, *.json -> *.kmodel +// memcpy(kmodel_path, json_file_path, strlen(json_file_path)); +// int idx_suffix_start = strlen(json_file_path) - 4; +// const char kmodel_suffix[5] = "kmodel"; +// int kmodel_suffix_len = 5; +// while (kmodel_suffix_len--) { +// kmodel_path[idx_suffix_start + 4 - kmodel_suffix_len] = kmodel_suffix[4 - kmodel_suffix_len]; +// } +// printf("Kmodel path: %s\n", kmodel_path); +// kmodel_fd = open(kmodel_path, O_RDONLY); // model_data = (unsigned char *)malloc(detect_params.kmodel_size + 255); // if (NULL == model_data) { diff --git a/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.c b/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.c index ee33116f..a6db6348 100644 --- a/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.c +++ b/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.c @@ -23,8 +23,10 @@ yolov2_params_t param_parse(char *json_file_path) fin = open(json_file_path, O_RDONLY); if (!fin) { - printf("Error open file %s", json_file_path); + printf("Error open file %s\n", json_file_path); exit(-1); + } else{ + printf("Reading config from: %s\n", json_file_path); } read(fin, buffer, sizeof(buffer)); close(fin); @@ -96,11 +98,11 @@ yolov2_params_t param_parse(char *json_file_path) printf("Net input width must match sensor output width!\n"); exit(-1); } - // kmodel_path - json_item = cJSON_GetObjectItem(json_obj, "kmodel_path"); - memset(params_return.kmodel_path, 0, 127); - memcpy(params_return.kmodel_path, json_item->valuestring, strlen(json_item->valuestring)); - printf("Got kmodel_path: %s\n", params_return.kmodel_path); + // // kmodel_path + // json_item = cJSON_GetObjectItem(json_obj, "kmodel_path"); + // memset(params_return.kmodel_path, 0, 127); + // memcpy(params_return.kmodel_path, json_item->valuestring, strlen(json_item->valuestring)); + // printf("Got kmodel_path: %s\n", params_return.kmodel_path); // kmodel_size json_item = cJSON_GetObjectItem(json_obj, "kmodel_size"); params_return.kmodel_size = json_item->valueint; diff --git a/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.h b/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.h index 359400f3..862d66b5 100644 --- a/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.h +++ b/APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.h @@ -10,7 +10,6 @@ typedef struct { int net_output_shape[3]; int net_input_size[2]; int sensor_output_size[2]; - char kmodel_path[127]; int kmodel_size; float obj_thresh[20]; float nms_thresh; diff --git a/Ubiquitous/RT_Thread/aiit_board/k210/.config b/Ubiquitous/RT_Thread/aiit_board/k210/.config index 6b76bdcc..5e9e11b8 100644 --- a/Ubiquitous/RT_Thread/aiit_board/k210/.config +++ b/Ubiquitous/RT_Thread/aiit_board/k210/.config @@ -475,7 +475,6 @@ CONFIG_MAIN_KTASK_STACK_SIZE=1024 # CONFIG_APPLICATION_KNOWING=y CONFIG_K210_DETECT_ENTRY=y -CONFIG_K210_DETECT_CONFIGJSON="/kmodel/face.json" # CONFIG_IRIS_ML_DEMO is not set # CONFIG_K210_FFT_TEST is not set # CONFIG_USING_IMAGE_PROCESSING_APP is not set diff --git a/Ubiquitous/RT_Thread/aiit_board/k210/rtconfig.h b/Ubiquitous/RT_Thread/aiit_board/k210/rtconfig.h index e062aaaf..82fa89af 100644 --- a/Ubiquitous/RT_Thread/aiit_board/k210/rtconfig.h +++ b/Ubiquitous/RT_Thread/aiit_board/k210/rtconfig.h @@ -323,7 +323,6 @@ #define APPLICATION_KNOWING #define K210_DETECT_ENTRY -#define K210_DETECT_CONFIGJSON "/kmodel/face.json" /* sensor app */