Browse Source

feat(knowing app): remove json config from menuconfig, adding to detect_app arg

pull/119/head
yangtuo250 8 months ago
parent
commit
c782dd26c4
  1. 6
      APP_Framework/Applications/knowing_app/k210_detect_entry/Kconfig
  2. 1
      APP_Framework/Applications/knowing_app/k210_detect_entry/face.json
  3. 1
      APP_Framework/Applications/knowing_app/k210_detect_entry/helmet.json
  4. 1
      APP_Framework/Applications/knowing_app/k210_detect_entry/instrusion.json
  5. 18
      APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c
  6. 26
      APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c
  7. 14
      APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.c
  8. 1
      APP_Framework/Framework/knowing/kpu/yolov2_json/json_parser.h
  9. 1
      Ubiquitous/RT_Thread/aiit_board/k210/.config
  10. 1
      Ubiquitous/RT_Thread/aiit_board/k210/rtconfig.h

6
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

1
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

1
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,

1
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

18
APP_Framework/Applications/knowing_app/k210_detect_entry/k210_detect_entry.c

@ -3,7 +3,19 @@
#endif
#include <transform.h>
static void detect_app() { k210_detect(K210_DETECT_CONFIGJSON); }
static void detect_app(int argc, char *argv[])
{
if (2 != argc) {
printf("Usage: detect_app <ABSOLUTE_CONFIG_JSON_PATH>");
exit(-1);
}
k210_detect(argv[1]);
return;
}
// clang-format off
#ifdef __RT_THREAD_H__
MSH_CMD_EXPORT(detect_app, detect app);
#endif
MSH_CMD_EXPORT(detect_app, k210 detect app usage: detect_app <ABSOLUTE_CONFIG_JSON_PATH>);
#endif
// clang-format on

26
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) {

14
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;

1
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;

1
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

1
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 */

Loading…
Cancel
Save