forked from xuos/xiuos
Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into 1220
This commit is contained in:
commit
37cbb51afa
|
@ -1,6 +1,6 @@
|
|||
[submodule "Ubiquitous/RT_Thread/rt-thread"]
|
||||
path = Ubiquitous/RT_Thread/rt-thread
|
||||
url = https://git.trustie.net/chunyexixiaoyu/rt-thread.git
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/rt-thread.git
|
||||
[submodule "Ubiquitous/RT_Thread/bsp/k210/kendryte-sdk/kendryte-sdk-source"]
|
||||
path = Ubiquitous/RT_Thread/bsp/k210/kendryte-sdk/kendryte-sdk-source
|
||||
url = https://git.trustie.net/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
path = Ubiquitous/RT_Thread/aiit_board/k210/kendryte-sdk/kendryte-sdk-source
|
||||
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Applications/Make.defs
|
||||
############################################################################
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
|
||||
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)
|
|
@ -1,25 +1,36 @@
|
|||
SRC_DIR := general_functions app_test
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
SRC_FILES := main.c framework_init.c
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += framework_init.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_OTA),y)
|
||||
SRC_DIR += ota
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
|
||||
SRC_DIR += sensor_app
|
||||
endif
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_DIR := general_functions app_test
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_CONNECTION),y)
|
||||
SRC_DIR += connection_app
|
||||
endif
|
||||
SRC_FILES := main.c framework_init.c
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_KNOWING),y)
|
||||
SRC_DIR += knowing_app
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_OTA),y)
|
||||
SRC_DIR += ota
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_CONTROL),y)
|
||||
SRC_DIR += control_app
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
|
||||
SRC_DIR += sensor_app
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_APPLICATION_CONNECTION),y)
|
||||
SRC_DIR += connection_app
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_KNOWING),y)
|
||||
SRC_DIR += knowing_app
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_CONTROL),y)
|
||||
SRC_DIR += control_app
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
|
@ -28,6 +28,8 @@ extern int D124VoiceInit(void);
|
|||
extern int Hs300xTemperatureInit(void);
|
||||
extern int Hs300xHumidityInit(void);
|
||||
extern int Ps5308Pm1_0Init(void);
|
||||
extern int Ps5308Pm2_5Init(void);
|
||||
extern int Ps5308Pm10Init(void);
|
||||
extern int Zg09Co2Init(void);
|
||||
extern int As830Ch4Init(void);
|
||||
extern int Tb600bIaq10IaqInit(void);
|
||||
|
@ -87,6 +89,12 @@ static struct InitDesc sensor_desc[] =
|
|||
#ifdef SENSOR_QUANTITY_PS5308_PM1_0
|
||||
{ "ps5308_pm1_0", Ps5308Pm1_0Init },
|
||||
#endif
|
||||
#ifdef SENSOR_QUANTITY_PS5308_PM2_5
|
||||
{ "ps5308_pm2_5", Ps5308Pm2_5Init },
|
||||
#endif
|
||||
#ifdef SENSOR_QUANTITY_PS5308_PM10
|
||||
{ "ps5308_pm10", Ps5308Pm10Init },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_ZG09
|
||||
|
@ -190,7 +198,7 @@ static int ConnectionDeviceFrameworkInit(struct InitDesc sub_desc[])
|
|||
* This function will init system framework
|
||||
*
|
||||
*/
|
||||
int FrameworkInit()
|
||||
int FrameworkInit(void)
|
||||
{
|
||||
#ifdef SUPPORT_SENSOR_FRAMEWORK
|
||||
SensorDeviceFrameworkInit(framework);
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
SRC_FILES := double_list.c single_list.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += double_list.c single_list.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := double_list.c single_list.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
|
@ -22,7 +22,9 @@
|
|||
#ifndef __LIST_H__
|
||||
#define __LIST_H__
|
||||
|
||||
#include "libc.h"
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
#include<stddef.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
menu "knowing app"
|
||||
menuconfig APPLICATION_KNOWING
|
||||
bool "Using knowing apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_KNOWING
|
||||
source "$APP_DIR/Applications/knowing_app/mnist/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/face_detect/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/instrusion_detect/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/helmet_detect/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/iris_ml_demo/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/k210_fft_test/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/image_processing/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/cmsis_5_demo/Kconfig"
|
||||
|
||||
endif
|
||||
endmenu
|
||||
menu "knowing app"
|
||||
menuconfig APPLICATION_KNOWING
|
||||
bool "Using knowing apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_KNOWING
|
||||
source "$APP_DIR/Applications/knowing_app/mnist/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/k210_detect_entry/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/iris_ml_demo/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/k210_fft_test/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/image_processing/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/cmsis_5_demo/Kconfig"
|
||||
|
||||
endif
|
||||
endmenu
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
config FACE_DETECT
|
||||
bool "enable apps/face detect"
|
||||
depends on BOARD_K210_EVB
|
||||
depends on DRV_USING_OV2640
|
||||
depends on USING_KPU_POSTPROCESSING
|
||||
depends on USING_YOLOV2
|
||||
select LIB_USING_CJSON
|
||||
default n
|
|
@ -1,9 +0,0 @@
|
|||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = ['FACE_DETECT'], LOCAL_CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
|
@ -1,379 +0,0 @@
|
|||
#include <transform.h>
|
||||
#ifdef LIB_USING_CJSON
|
||||
#include <cJSON.h>
|
||||
#endif
|
||||
#include "region_layer.h"
|
||||
#define ANCHOR_NUM 5
|
||||
#define STACK_SIZE (128 * 1024)
|
||||
#define JSON_FILE_PATH "/kmodel/detect.json"
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
|
||||
// params from json
|
||||
static float anchor[ANCHOR_NUM * 2] = {};
|
||||
static int net_output_shape[3] = {};
|
||||
static int net_input_size[2] = {};
|
||||
static int sensor_output_size[2] = {};
|
||||
static char kmodel_path[127] = "";
|
||||
static int kmodel_size = 0;
|
||||
static float obj_thresh[20] = {};
|
||||
static float nms_thresh = 0.0;
|
||||
static char labels[20][32] = {};
|
||||
static int class_num = 0;
|
||||
|
||||
#define THREAD_PRIORITY_FACE_D (11)
|
||||
static pthread_t facetid = 0;
|
||||
static void *thread_face_detcet_entry(void *parameter);
|
||||
static int g_fd = 0;
|
||||
static int kmodel_fd = 0;
|
||||
static int if_exit = 0;
|
||||
static unsigned char *showbuffer = NULL;
|
||||
static unsigned char *kpurgbbuffer = NULL;
|
||||
|
||||
static _ioctl_shoot_para shoot_para_t = {0};
|
||||
unsigned char *model_data = NULL; // kpu data load memory
|
||||
unsigned char *model_data_align = NULL;
|
||||
|
||||
kpu_model_context_t face_detect_task;
|
||||
static region_layer_t face_detect_rl;
|
||||
static obj_info_t face_detect_info;
|
||||
volatile uint32_t g_ai_done_flag;
|
||||
|
||||
static void ai_done(void *ctx) { g_ai_done_flag = 1; }
|
||||
|
||||
static void param_parse()
|
||||
{
|
||||
int fin;
|
||||
char buffer[JSON_BUFFER_SIZE] = "";
|
||||
// char *buffer;
|
||||
// if (NULL != (buffer = (char*)malloc(JSON_BUFFER_SIZE * sizeof(char)))) {
|
||||
// memset(buffer, 0, JSON_BUFFER_SIZE * sizeof(char));
|
||||
// } else {
|
||||
// printf("Json buffer malloc failed!");
|
||||
// exit(-1);
|
||||
// }
|
||||
int array_size;
|
||||
cJSON *json_obj;
|
||||
cJSON *json_item;
|
||||
cJSON *json_array_item;
|
||||
|
||||
fin = open(JSON_FILE_PATH, O_RDONLY);
|
||||
if (!fin) {
|
||||
printf("Error open file %s", JSON_FILE_PATH);
|
||||
exit(-1);
|
||||
}
|
||||
read(fin, buffer, sizeof(buffer));
|
||||
close(fin);
|
||||
|
||||
// read json string
|
||||
json_obj = cJSON_Parse(buffer);
|
||||
// free(buffer);
|
||||
char *json_print_str = cJSON_Print(json_obj);
|
||||
printf("Json file content: \n%s\n", json_print_str);
|
||||
cJSON_free(json_print_str);
|
||||
// get anchors
|
||||
json_item = cJSON_GetObjectItem(json_obj, "anchors");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (ANCHOR_NUM * 2 != array_size) {
|
||||
printf("Expect anchor size: %d, got %d in json file", ANCHOR_NUM * 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d anchors from json file\n", ANCHOR_NUM);
|
||||
}
|
||||
for (int i = 0; i < ANCHOR_NUM * 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
anchor[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, anchor[i]);
|
||||
}
|
||||
// net_input_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_input_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect net_input_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_input_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_input_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_input_size[i]);
|
||||
}
|
||||
// net_output_shape
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_output_shape");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (3 != array_size) {
|
||||
printf("Expect net_output_shape: %d, got %d in json file", 3, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_output_shape from json file\n", 3);
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_output_shape[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_output_shape[i]);
|
||||
}
|
||||
// sensor_output_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "sensor_output_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect sensor_output_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d sensor_output_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
sensor_output_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, sensor_output_size[i]);
|
||||
}
|
||||
// kmodel_path
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_path");
|
||||
memcpy(kmodel_path, json_item->valuestring, strlen(json_item->valuestring));
|
||||
printf("Got kmodel_path: %s\n", kmodel_path);
|
||||
// kmodel_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_size");
|
||||
kmodel_size = json_item->valueint;
|
||||
printf("Got kmodel_size: %d\n", kmodel_size);
|
||||
// labels
|
||||
json_item = cJSON_GetObjectItem(json_obj, "labels");
|
||||
class_num = cJSON_GetArraySize(json_item);
|
||||
if (0 >= class_num) {
|
||||
printf("No labels!");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d labels\n", class_num);
|
||||
}
|
||||
for (int i = 0; i < class_num; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
memcpy(labels[i], json_array_item->valuestring, strlen(json_array_item->valuestring));
|
||||
printf("%d: %s\n", i, labels[i]);
|
||||
}
|
||||
// obj_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "obj_thresh");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (class_num != array_size) {
|
||||
printf("label number and thresh number mismatch! label number : %d, obj thresh number %d", class_num, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d obj_thresh\n", array_size);
|
||||
}
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
obj_thresh[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, obj_thresh[i]);
|
||||
}
|
||||
// nms_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "nms_thresh");
|
||||
nms_thresh = json_item->valuedouble;
|
||||
printf("Got nms_thresh: %f\n", nms_thresh);
|
||||
|
||||
cJSON_Delete(json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
void face_detect()
|
||||
{
|
||||
int ret = 0;
|
||||
int result = 0;
|
||||
int size = 0;
|
||||
param_parse();
|
||||
g_fd = open("/dev/ov2640", O_RDONLY);
|
||||
if (g_fd < 0) {
|
||||
printf("open ov2640 fail !!");
|
||||
return;
|
||||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
rt_free_align(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
rt_free_align(showbuffer);
|
||||
rt_free_align(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
memset(showbuffer, 0, sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
memset(kpurgbbuffer, 0, net_input_size[0] * net_input_size[1] * 3);
|
||||
shoot_para_t.pdata = (unsigned int *)(showbuffer);
|
||||
shoot_para_t.length = (size_t)(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
/*
|
||||
load memory
|
||||
*/
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
if (kmodel_fd < 0) {
|
||||
printf("open kmodel fail");
|
||||
close(g_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
} else {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
|
||||
} else {
|
||||
printf("read kmodel success \n");
|
||||
}
|
||||
}
|
||||
unsigned char *model_data_align = (unsigned char *)(((unsigned int)model_data + 255) & (~255));
|
||||
dvp_set_ai_addr((uint32_t)kpurgbbuffer, (uint32_t)(kpurgbbuffer + net_input_size[0] * net_input_size[1]),
|
||||
(uint32_t)(kpurgbbuffer + net_input_size[0] * net_input_size[1] * 2));
|
||||
if (kpu_load_kmodel(&face_detect_task, model_data_align) != 0) {
|
||||
printf("\nmodel init error\n");
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
}
|
||||
face_detect_rl.anchor_number = ANCHOR_NUM;
|
||||
face_detect_rl.anchor = anchor;
|
||||
face_detect_rl.threshold = malloc(class_num * sizeof(float));
|
||||
for (int idx = 0; idx < class_num; idx++) {
|
||||
face_detect_rl.threshold[idx] = obj_thresh[idx];
|
||||
}
|
||||
face_detect_rl.nms_value = nms_thresh;
|
||||
result = region_layer_init(&face_detect_rl, net_output_shape[0], net_output_shape[1], net_output_shape[2],
|
||||
net_input_size[1], net_input_size[0]);
|
||||
printf("region_layer_init result %d \n\r", result);
|
||||
size_t stack_size = STACK_SIZE;
|
||||
pthread_attr_t attr; /* 线程属性 */
|
||||
struct sched_param prio; /* 线程优先级 */
|
||||
prio.sched_priority = 8; /* 优先级设置为 8 */
|
||||
pthread_attr_init(&attr); /* 先使用默认值初始化属性 */
|
||||
pthread_attr_setschedparam(&attr, &prio); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attr, stack_size);
|
||||
|
||||
/* 创建线程 1, 属性为 attr,入口函数是 thread_entry,入口函数参数是 1 */
|
||||
result = pthread_create(&facetid, &attr, thread_face_detcet_entry, NULL);
|
||||
if (0 == result) {
|
||||
printf("thread_face_detcet_entry successfully!\n");
|
||||
} else {
|
||||
printf("thread_face_detcet_entry failed! error code is %d\n", result);
|
||||
close(g_fd);
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(face_detect, face detect task);
|
||||
#endif
|
||||
|
||||
static void *thread_face_detcet_entry(void *parameter)
|
||||
{
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
printf("thread_face_detcet_entry start!\n");
|
||||
int ret = 0;
|
||||
// sysctl_enable_irq();
|
||||
while (1) {
|
||||
// memset(showbuffer,0,320*240*2);
|
||||
g_ai_done_flag = 0;
|
||||
ret = ioctl(g_fd, IOCTRL_CAMERA_START_SHOT, &shoot_para_t);
|
||||
if (RT_ERROR == ret) {
|
||||
printf("ov2640 can't wait event flag");
|
||||
rt_free(showbuffer);
|
||||
close(g_fd);
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (dmalock_sync_take(&dma_ch, 2000))
|
||||
{
|
||||
printf("Fail to take DMA channel");
|
||||
}
|
||||
kpu_run_kmodel(&face_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
dmalock_release(dma_ch);
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&face_detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
face_detect_rl.input = output;
|
||||
region_layer_run(&face_detect_rl, &face_detect_info);
|
||||
/* display result */
|
||||
|
||||
for (int face_cnt = 0; face_cnt < face_detect_info.obj_number; face_cnt++) {
|
||||
draw_edge((uint32_t *)showbuffer, &face_detect_info, face_cnt, 0xF800, (uint16_t)sensor_output_size[1],
|
||||
(uint16_t)sensor_output_size[0]);
|
||||
// printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", face_cnt, face_detect_info.obj[face_cnt].x1,
|
||||
// face_detect_info.obj[face_cnt].y1, face_detect_info.obj[face_cnt].x2, face_detect_info.obj[face_cnt].y2,
|
||||
// labels[face_detect_info.obj[face_cnt].class_id], face_detect_info.obj[face_cnt].prob);
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
|
||||
//lcd_show_image(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
|
||||
#endif
|
||||
usleep(500);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
printf("thread_face_detcet_entry exit");
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void face_detect_delete()
|
||||
{
|
||||
if (showbuffer != NULL) {
|
||||
int ret = 0;
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
printf("face detect task cancel!!! ret %d ", ret);
|
||||
if_exit = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(face_detect_delete, face detect task delete);
|
||||
#endif
|
||||
|
||||
void kmodel_load(unsigned char *model_data)
|
||||
{
|
||||
int kmodel_fd = 0;
|
||||
int size = 0;
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
|
||||
if (kmodel_fd >= 0) {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
|
||||
} else {
|
||||
printf("read kmodel success");
|
||||
}
|
||||
} else {
|
||||
free(model_data);
|
||||
printf("open kmodel fail");
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(kmodel_load, kmodel load memory);
|
||||
#endif
|
|
@ -1,8 +0,0 @@
|
|||
config HELMET_DETECT
|
||||
bool "enable apps/helmet detect"
|
||||
depends on BOARD_K210_EVB
|
||||
depends on DRV_USING_OV2640
|
||||
depends on USING_KPU_POSTPROCESSING
|
||||
depends on USING_YOLOV2
|
||||
select LIB_USING_CJSON
|
||||
default n
|
|
@ -1,167 +0,0 @@
|
|||
# Helmet detection demo
|
||||
|
||||
### A helmet and head without helmet object detection task demo. Running MobileNet-yolo on K210-based edge devices.
|
||||
|
||||
---
|
||||
|
||||
## Training
|
||||
|
||||
### Enviroment preparation
|
||||
|
||||
Model generated by [aXeleRate](https://forgeplus.trustie.net/projects/yangtuo250/aXeleRate) and converted to kmodel by [nncase](https://github.com/kendryte/nncase/tree/v0.1.0-rc5).
|
||||
|
||||
```shell
|
||||
# master branch for MobileNetv1-yolov2 and unstable branch to test MobileNetv1(v2)-yolov2(v3)
|
||||
git clone https://git.trustie.net/yangtuo250/aXeleRate.git (-b unstable)
|
||||
cd aXeleRate
|
||||
pip install -r requirments.txt && pip install -e .
|
||||
```
|
||||
|
||||
### training config setting
|
||||
|
||||
Example [config](https://forgeplus.trustie.net/projects/yangtuo250/aXeleRate/tree/master/configs/detector.json), some hyper-parameters:
|
||||
|
||||
- architecture: backbone, MobileNet7_5 for default, MobileNet1_0(α = 1.0) and above cannot run on K210 because of OOM on feature map in master branch. For unstable branch MobileNetV2_1_0 is OK.
|
||||
|
||||
- input_size: fixed model input size, single integer for height equals to width, otherwise a list([height, width]).
|
||||
- anchors: yolov2 anchor(for master) or anchor scaled to 1.0(for unstable), can be generate by [darknet](https://github.com/AlexeyAB/darknet).
|
||||
- labels: labels of all classes.
|
||||
- train(valid)_image(annot)_folder: path of images and annoations for training and validation.
|
||||
- saved_folder: path for trainig result storage(models, checkpoints, logs ...).
|
||||
|
||||
Mine config for unstable:
|
||||
```json
|
||||
{
|
||||
"model": {
|
||||
"type": "Detector",
|
||||
"architecture": "MobileNetV2_1_0",
|
||||
"input_size": [
|
||||
224,
|
||||
320
|
||||
],
|
||||
"anchors": [
|
||||
[
|
||||
[
|
||||
0.1043,
|
||||
0.1560
|
||||
],
|
||||
[
|
||||
0.0839,
|
||||
0.3036
|
||||
],
|
||||
[
|
||||
0.1109,
|
||||
0.3923
|
||||
],
|
||||
[
|
||||
0.1378,
|
||||
0.5244
|
||||
],
|
||||
[
|
||||
0.2049,
|
||||
0.6673
|
||||
]
|
||||
]
|
||||
],
|
||||
"labels": [
|
||||
"human"
|
||||
],
|
||||
"obj_thresh": 0.5,
|
||||
"iou_thresh": 0.45,
|
||||
"coord_scale": 1.0,
|
||||
"class_scale": 0.0,
|
||||
"object_scale": 5.0,
|
||||
"no_object_scale": 3.0
|
||||
},
|
||||
"weights": {
|
||||
"full": "",
|
||||
"backend": ""
|
||||
},
|
||||
"train": {
|
||||
"actual_epoch": 2000,
|
||||
"train_image_folder": "mydata/human/Images/train",
|
||||
"train_annot_folder": "mydata/human/Annotations/train",
|
||||
"train_times": 2,
|
||||
"valid_image_folder": "mydata/human/Images/val",
|
||||
"valid_annot_folder": "mydata/human/Annotations/val",
|
||||
"valid_times": 1,
|
||||
"valid_metric": "precision",
|
||||
"batch_size": 32,
|
||||
"learning_rate": 2e-5,
|
||||
"saved_folder": "mydata/human/results",
|
||||
"first_trainable_layer": "",
|
||||
"augmentation": true,
|
||||
"is_only_detect": false,
|
||||
"validation_freq": 5,
|
||||
"quantize": false,
|
||||
"class_weights": [1.0]
|
||||
},
|
||||
"converter": {
|
||||
"type": [
|
||||
"k210"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*(For more detailed config usage, please refer to original aXeleRate repo.)*
|
||||
|
||||
### data preparation
|
||||
|
||||
Please refer to [VOC format](https://towardsdatascience.com/coco-data-format-for-object-detection-a4c5eaf518c5), path as config above.
|
||||
|
||||
### train it!
|
||||
|
||||
```shell
|
||||
python -m aXeleRate.train -c PATH_TO_YOUR_CONFIG
|
||||
```
|
||||
|
||||
### model convert
|
||||
|
||||
Please refer to [nncase repo](https://github.com/kendryte/nncase/tree/v0.1.0-rc5).
|
||||
|
||||
---
|
||||
|
||||
## Deployment
|
||||
|
||||
### compile and burn
|
||||
|
||||
Use `(scons --)menuconfig` in bsp folder *(Ubiquitous/RT_Thread/bsp/k210)*, open:
|
||||
|
||||
- More Drivers --> ov2640 driver
|
||||
- Board Drivers Config --> Enable LCD on SPI0
|
||||
- Board Drivers Config --> Enable SDCARD (spi1(ss0))
|
||||
- Board Drivers Config --> Enable DVP(camera)
|
||||
- RT-Thread Components --> POSIX layer and C standard library --> Enable pthreads APIs
|
||||
- APP_Framework --> Framework --> support knowing framework --> kpu model postprocessing --> yolov2 region layer
|
||||
- APP_Framework --> Applications --> knowing app --> enable apps/helmet detect
|
||||
|
||||
`scons -j(n)` to compile and burn in by *kflash*.
|
||||
|
||||
### json config and kmodel
|
||||
|
||||
Copy json config for deployment o SD card */kmodel*. Example config file is *helmet.json* in this directory. Something to be modified:
|
||||
|
||||
- net_input_size: same as *input_size* in training config file, but array only.
|
||||
- net_output_shape: final feature map size, can be found in **nncase** output.
|
||||
- sensor_output_size: image height and width from camera.
|
||||
- kmodel_size: kmodel size shown in file system.
|
||||
- anchors: same as *anchor* in training config file(multi-dimention anchors flatten to 1 dim).
|
||||
- labels: same as *label* in training config file.
|
||||
- obj_thresh: array, object threshold of each label.
|
||||
- nms_thresh: NMS threshold of boxes.
|
||||
|
||||
Copy final kmodel to SD card */kmodel* either.
|
||||
|
||||
---
|
||||
|
||||
## Run
|
||||
|
||||
In serial terminal, `helmet_detect` to start a detection thread, `helmet_detect_delete` to stop it. Detection results can be found in output.
|
||||
|
||||
---
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] Fix LCD real-time result display.
|
||||
- [ ] Test more object detection backbone and algorithm(like yolox).
|
|
@ -1,380 +0,0 @@
|
|||
#include <transform.h>
|
||||
#ifdef LIB_USING_CJSON
|
||||
#include <cJSON.h>
|
||||
#endif
|
||||
#include "region_layer.h"
|
||||
#define ANCHOR_NUM 5
|
||||
#define STACK_SIZE (128 * 1024)
|
||||
#define JSON_FILE_PATH "/kmodel/helmet.json"
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
|
||||
// params from json
|
||||
static float anchor[ANCHOR_NUM * 2] = {};
|
||||
static int net_output_shape[3] = {};
|
||||
static int net_input_size[2] = {};
|
||||
static int sensor_output_size[2] = {};
|
||||
static char kmodel_path[127] = "";
|
||||
static int kmodel_size = 0;
|
||||
static float obj_thresh[20] = {};
|
||||
static float nms_thresh = 0.0;
|
||||
static char labels[20][32] = {};
|
||||
static int class_num = 0;
|
||||
|
||||
#define THREAD_PRIORITY_HELMET_D (11)
|
||||
static pthread_t helmettid = 0;
|
||||
static void *thread_helmet_detect_entry(void *parameter);
|
||||
static int g_fd = 0;
|
||||
static int kmodel_fd = 0;
|
||||
static int if_exit = 0;
|
||||
static unsigned char *showbuffer = NULL;
|
||||
static unsigned char *kpurgbbuffer = NULL;
|
||||
|
||||
static _ioctl_shoot_para shoot_para_t = {0};
|
||||
unsigned char *model_data = NULL; // kpu data load memory
|
||||
unsigned char *model_data_align = NULL;
|
||||
|
||||
kpu_model_context_t helmet_detect_task;
|
||||
static region_layer_t helmet_detect_rl;
|
||||
static obj_info_t helmet_detect_info;
|
||||
volatile uint32_t g_ai_done_flag;
|
||||
|
||||
static void ai_done(void *ctx) { g_ai_done_flag = 1; }
|
||||
|
||||
static void param_parse()
|
||||
{
|
||||
int fin;
|
||||
char buffer[JSON_BUFFER_SIZE] = "";
|
||||
// char *buffer;
|
||||
// if (NULL != (buffer = (char*)malloc(JSON_BUFFER_SIZE * sizeof(char)))) {
|
||||
// memset(buffer, 0, JSON_BUFFER_SIZE * sizeof(char));
|
||||
// } else {
|
||||
// printf("Json buffer malloc failed!");
|
||||
// exit(-1);
|
||||
// }
|
||||
int array_size;
|
||||
cJSON *json_obj;
|
||||
cJSON *json_item;
|
||||
cJSON *json_array_item;
|
||||
|
||||
fin = open(JSON_FILE_PATH, O_RDONLY);
|
||||
if (!fin) {
|
||||
printf("Error open file %s", JSON_FILE_PATH);
|
||||
exit(-1);
|
||||
}
|
||||
read(fin, buffer, sizeof(buffer));
|
||||
close(fin);
|
||||
|
||||
// read json string
|
||||
json_obj = cJSON_Parse(buffer);
|
||||
// free(buffer);
|
||||
char *json_print_str = cJSON_Print(json_obj);
|
||||
printf("Json file content: \n%s\n", json_print_str);
|
||||
cJSON_free(json_print_str);
|
||||
// get anchors
|
||||
json_item = cJSON_GetObjectItem(json_obj, "anchors");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (ANCHOR_NUM * 2 != array_size) {
|
||||
printf("Expect anchor size: %d, got %d in json file", ANCHOR_NUM * 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d anchors from json file\n", ANCHOR_NUM);
|
||||
}
|
||||
for (int i = 0; i < ANCHOR_NUM * 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
anchor[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, anchor[i]);
|
||||
}
|
||||
// net_input_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_input_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect net_input_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_input_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_input_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_input_size[i]);
|
||||
}
|
||||
// net_output_shape
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_output_shape");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (3 != array_size) {
|
||||
printf("Expect net_output_shape: %d, got %d in json file", 3, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_output_shape from json file\n", 3);
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_output_shape[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_output_shape[i]);
|
||||
}
|
||||
// sensor_output_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "sensor_output_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect sensor_output_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d sensor_output_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
sensor_output_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, sensor_output_size[i]);
|
||||
}
|
||||
// kmodel_path
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_path");
|
||||
memcpy(kmodel_path, json_item->valuestring, strlen(json_item->valuestring));
|
||||
printf("Got kmodel_path: %s\n", kmodel_path);
|
||||
// kmodel_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_size");
|
||||
kmodel_size = json_item->valueint;
|
||||
printf("Got kmodel_size: %d\n", kmodel_size);
|
||||
// labels
|
||||
json_item = cJSON_GetObjectItem(json_obj, "labels");
|
||||
class_num = cJSON_GetArraySize(json_item);
|
||||
if (0 >= class_num) {
|
||||
printf("No labels!");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d labels\n", class_num);
|
||||
}
|
||||
for (int i = 0; i < class_num; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
memcpy(labels[i], json_array_item->valuestring, strlen(json_array_item->valuestring));
|
||||
printf("%d: %s\n", i, labels[i]);
|
||||
}
|
||||
// obj_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "obj_thresh");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (class_num != array_size) {
|
||||
printf("label number and thresh number mismatch! label number : %d, obj thresh number %d", class_num, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d obj_thresh\n", array_size);
|
||||
}
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
obj_thresh[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, obj_thresh[i]);
|
||||
}
|
||||
// nms_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "nms_thresh");
|
||||
nms_thresh = json_item->valuedouble;
|
||||
printf("Got nms_thresh: %f\n", nms_thresh);
|
||||
|
||||
cJSON_Delete(json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
void helmet_detect()
|
||||
{
|
||||
int ret = 0;
|
||||
int result = 0;
|
||||
int size = 0;
|
||||
param_parse();
|
||||
g_fd = open("/dev/ov2640", O_RDONLY);
|
||||
if (g_fd < 0) {
|
||||
printf("open ov2640 fail !!");
|
||||
return;
|
||||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer = (unsigned char *)malloc(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)malloc(net_input_size[0] * net_input_size[1] * 3);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
free(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
memset(showbuffer, 0, sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
memset(kpurgbbuffer, 127, net_input_size[0] * net_input_size[1] * 3);
|
||||
shoot_para_t.pdata = (unsigned int *)(showbuffer);
|
||||
shoot_para_t.length = (size_t)(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
/*
|
||||
load memory
|
||||
*/
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
if (kmodel_fd < 0) {
|
||||
printf("open kmodel fail");
|
||||
close(g_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
} else {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
|
||||
} else {
|
||||
printf("read kmodel success \n");
|
||||
}
|
||||
}
|
||||
unsigned char *model_data_align = (unsigned char *)(((unsigned int)model_data + 255) & (~255));
|
||||
dvp_set_ai_addr((uint32_t)(kpurgbbuffer + net_input_size[1] * (net_input_size[0] - sensor_output_size[0])),
|
||||
(uint32_t)(kpurgbbuffer + net_input_size[1] * (net_input_size[0] - sensor_output_size[0]) +
|
||||
net_input_size[0] * net_input_size[1]),
|
||||
(uint32_t)(kpurgbbuffer + net_input_size[0] * net_input_size[1] * 2 +
|
||||
net_input_size[1] * (net_input_size[0] - sensor_output_size[0])));
|
||||
if (kpu_load_kmodel(&helmet_detect_task, model_data_align) != 0) {
|
||||
printf("\nmodel init error\n");
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
}
|
||||
helmet_detect_rl.anchor_number = ANCHOR_NUM;
|
||||
helmet_detect_rl.anchor = anchor;
|
||||
helmet_detect_rl.threshold = malloc(class_num * sizeof(float));
|
||||
for (int idx = 0; idx < class_num; idx++) {
|
||||
helmet_detect_rl.threshold[idx] = obj_thresh[idx];
|
||||
}
|
||||
helmet_detect_rl.nms_value = nms_thresh;
|
||||
result = region_layer_init(&helmet_detect_rl, net_output_shape[0], net_output_shape[1], net_output_shape[2],
|
||||
net_input_size[1], net_input_size[0]);
|
||||
printf("region_layer_init result %d \n\r", result);
|
||||
size_t stack_size = STACK_SIZE;
|
||||
pthread_attr_t attr; /* 线程属性 */
|
||||
struct sched_param prio; /* 线程优先级 */
|
||||
prio.sched_priority = 8; /* 优先级设置为 8 */
|
||||
pthread_attr_init(&attr); /* 先使用默认值初始化属性 */
|
||||
pthread_attr_setschedparam(&attr, &prio); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attr, stack_size);
|
||||
|
||||
/* 创建线程 1, 属性为 attr,入口函数是 thread_entry,入口函数参数是 1 */
|
||||
result = pthread_create(&helmettid, &attr, thread_helmet_detect_entry, NULL);
|
||||
if (0 == result) {
|
||||
printf("thread_helmet_detect_entry successfully!\n");
|
||||
} else {
|
||||
printf("thread_helmet_detect_entry failed! error code is %d\n", result);
|
||||
close(g_fd);
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(helmet_detect, helmet detect task);
|
||||
#endif
|
||||
|
||||
static void *thread_helmet_detect_entry(void *parameter)
|
||||
{
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
printf("thread_helmet_detect_entry start!\n");
|
||||
int ret = 0;
|
||||
// sysctl_enable_irq();
|
||||
while (1) {
|
||||
// memset(showbuffer,0,320*240*2);
|
||||
g_ai_done_flag = 0;
|
||||
ret = ioctl(g_fd, IOCTRL_CAMERA_START_SHOT, &shoot_para_t);
|
||||
if (RT_ERROR == ret) {
|
||||
printf("ov2640 can't wait event flag");
|
||||
rt_free(showbuffer);
|
||||
close(g_fd);
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
kpu_run_kmodel(&helmet_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&helmet_detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
helmet_detect_rl.input = output;
|
||||
region_layer_run(&helmet_detect_rl, &helmet_detect_info);
|
||||
/* display result */
|
||||
#ifdef BSP_USING_LCD
|
||||
for (int helmet_cnt = 0; helmet_cnt < helmet_detect_info.obj_number; helmet_cnt++) {
|
||||
// draw_edge((uint32_t *)showbuffer, &helmet_detect_info, helmet_cnt, 0xF800,
|
||||
// (uint16_t)sensor_output_size[1],
|
||||
// (uint16_t)sensor_output_size[0]);
|
||||
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", helmet_cnt, helmet_detect_info.obj[helmet_cnt].x1,
|
||||
helmet_detect_info.obj[helmet_cnt].y1, helmet_detect_info.obj[helmet_cnt].x2,
|
||||
helmet_detect_info.obj[helmet_cnt].y2, labels[helmet_detect_info.obj[helmet_cnt].class_id],
|
||||
helmet_detect_info.obj[helmet_cnt].prob);
|
||||
}
|
||||
if (0 != helmet_detect_info.obj_number) {
|
||||
printf("\n");
|
||||
}
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
|
||||
#endif
|
||||
usleep(1);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
printf("thread_helmet_detect_entry exit");
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void helmet_detect_delete()
|
||||
{
|
||||
if (showbuffer != NULL) {
|
||||
int ret = 0;
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
printf("helmet detect task cancel!!! ret %d ", ret);
|
||||
if_exit = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(helmet_detect_delete, helmet detect task delete);
|
||||
#endif
|
||||
|
||||
void kmodel_load(unsigned char *model_data)
|
||||
{
|
||||
int kmodel_fd = 0;
|
||||
int size = 0;
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
|
||||
if (kmodel_fd >= 0) {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
|
||||
} else {
|
||||
printf("read kmodel success");
|
||||
}
|
||||
} else {
|
||||
free(model_data);
|
||||
printf("open kmodel fail");
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(kmodel_load, kmodel load memory);
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
menuconfig USING_IMAGE_PROCESSING_APP
|
||||
bool "image processing app "
|
||||
default n
|
||||
if USING_IMAGE_PROCESSING_APP
|
||||
source "$APP_DIR/Applications/knowing_app/image_processing/TJpgDec_APP/Kconfig"
|
||||
endif
|
||||
menuconfig USING_IMAGE_PROCESSING_APP
|
||||
bool "image processing app "
|
||||
default n
|
||||
if USING_IMAGE_PROCESSING_APP
|
||||
source "$APP_DIR/Applications/knowing_app/image_processing/TJpgDec_APP/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
config IMAGE_PROCESSING_TJPGDEC_APP
|
||||
bool "image processing apps/TJpgDec(example)"
|
||||
select IMAGE_PROCESSING_USING_TJPGD
|
||||
default n
|
||||
config IMAGE_PROCESSING_TJPGDEC_APP
|
||||
bool "image processing apps/TJpgDec(example)"
|
||||
select IMAGE_PROCESSING_USING_TJPGD
|
||||
default n
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
config INSTRUSION_DETECT
|
||||
bool "enable apps/instrusion detect"
|
||||
depends on BOARD_K210_EVB
|
||||
depends on DRV_USING_OV2640
|
||||
depends on USING_KPU_POSTPROCESSING
|
||||
depends on USING_YOLOV2
|
||||
select LIB_USING_CJSON
|
||||
default n
|
|
@ -1,5 +0,0 @@
|
|||
# Instrusion detect demo
|
||||
|
||||
### A human object detection task demo. Running MobileNet-yolo on K210-based edge devices.
|
||||
|
||||
***Training, deployment and running, please see helmet_detect***
|
|
@ -1,9 +0,0 @@
|
|||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = ['INSTRUSION_DETECT'], LOCAL_CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
|
@ -1,390 +0,0 @@
|
|||
#include <transform.h>
|
||||
#include <unistd.h>
|
||||
#ifdef LIB_USING_CJSON
|
||||
#include <cJSON.h>
|
||||
#endif
|
||||
#include "region_layer.h"
|
||||
#define ANCHOR_NUM 5
|
||||
#define STACK_SIZE (128 * 1024)
|
||||
#define JSON_FILE_PATH "/kmodel/human.json"
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
|
||||
|
||||
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
|
||||
// params from json
|
||||
static float anchor[ANCHOR_NUM * 2] = {};
|
||||
static int net_output_shape[3] = {};
|
||||
static int net_input_size[2] = {};
|
||||
static int sensor_output_size[2] = {};
|
||||
static char kmodel_path[127] = "";
|
||||
static int kmodel_size = 0;
|
||||
static float obj_thresh[20] = {};
|
||||
static float nms_thresh = 0.0;
|
||||
static char labels[20][32] = {};
|
||||
static int class_num = 0;
|
||||
|
||||
#define THREAD_PRIORITY_HUMAN_D (11)
|
||||
static pthread_t instrusiontid = 0;
|
||||
static void *thread_instrusion_detect_entry(void *parameter);
|
||||
static int g_fd = 0;
|
||||
static int kmodel_fd = 0;
|
||||
static int if_exit = 0;
|
||||
static unsigned char *showbuffer = NULL;
|
||||
static unsigned char *kpurgbbuffer = NULL;
|
||||
|
||||
static _ioctl_shoot_para shoot_para_t = {0};
|
||||
unsigned char *model_data = NULL; // kpu data load memory
|
||||
unsigned char *model_data_align = NULL;
|
||||
|
||||
kpu_model_context_t instrusion_detect_task;
|
||||
static region_layer_t instrusion_detect_rl;
|
||||
static obj_info_t instrusion_detect_info;
|
||||
volatile uint32_t g_ai_done_flag;
|
||||
|
||||
static void ai_done(void *ctx) { g_ai_done_flag = 1; }
|
||||
|
||||
static void param_parse()
|
||||
{
|
||||
int fin;
|
||||
char buffer[JSON_BUFFER_SIZE] = "";
|
||||
// char *buffer;
|
||||
// if (NULL != (buffer = (char*)malloc(JSON_BUFFER_SIZE * sizeof(char)))) {
|
||||
// memset(buffer, 0, JSON_BUFFER_SIZE * sizeof(char));
|
||||
// } else {
|
||||
// printf("Json buffer malloc failed!");
|
||||
// exit(-1);
|
||||
// }
|
||||
int array_size;
|
||||
cJSON *json_obj;
|
||||
cJSON *json_item;
|
||||
cJSON *json_array_item;
|
||||
|
||||
fin = open(JSON_FILE_PATH, O_RDONLY);
|
||||
if (!fin) {
|
||||
printf("Error open file %s", JSON_FILE_PATH);
|
||||
exit(-1);
|
||||
}
|
||||
read(fin, buffer, sizeof(buffer));
|
||||
close(fin);
|
||||
|
||||
// read json string
|
||||
json_obj = cJSON_Parse(buffer);
|
||||
// free(buffer);
|
||||
char *json_print_str = cJSON_Print(json_obj);
|
||||
printf("Json file content: \n%s\n", json_print_str);
|
||||
cJSON_free(json_print_str);
|
||||
// get anchors
|
||||
json_item = cJSON_GetObjectItem(json_obj, "anchors");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (ANCHOR_NUM * 2 != array_size) {
|
||||
printf("Expect anchor size: %d, got %d in json file", ANCHOR_NUM * 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d anchors from json file\n", ANCHOR_NUM);
|
||||
}
|
||||
for (int i = 0; i < ANCHOR_NUM * 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
anchor[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, anchor[i]);
|
||||
}
|
||||
// net_input_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_input_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect net_input_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_input_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_input_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_input_size[i]);
|
||||
}
|
||||
// net_output_shape
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_output_shape");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (3 != array_size) {
|
||||
printf("Expect net_output_shape: %d, got %d in json file", 3, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d net_output_shape from json file\n", 3);
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
net_output_shape[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, net_output_shape[i]);
|
||||
}
|
||||
// sensor_output_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "sensor_output_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect sensor_output_size: %d, got %d in json file", 2, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d sensor_output_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
sensor_output_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, sensor_output_size[i]);
|
||||
}
|
||||
// kmodel_path
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_path");
|
||||
memcpy(kmodel_path, json_item->valuestring, strlen(json_item->valuestring));
|
||||
printf("Got kmodel_path: %s\n", kmodel_path);
|
||||
// kmodel_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "kmodel_size");
|
||||
kmodel_size = json_item->valueint;
|
||||
printf("Got kmodel_size: %d\n", kmodel_size);
|
||||
// labels
|
||||
json_item = cJSON_GetObjectItem(json_obj, "labels");
|
||||
class_num = cJSON_GetArraySize(json_item);
|
||||
if (0 >= class_num) {
|
||||
printf("No labels!");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d labels\n", class_num);
|
||||
}
|
||||
for (int i = 0; i < class_num; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
memcpy(labels[i], json_array_item->valuestring, strlen(json_array_item->valuestring));
|
||||
printf("%d: %s\n", i, labels[i]);
|
||||
}
|
||||
// obj_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "obj_thresh");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (class_num != array_size) {
|
||||
printf("label number and thresh number mismatch! label number : %d, obj thresh number %d", class_num, array_size);
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Got %d obj_thresh\n", array_size);
|
||||
}
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
obj_thresh[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, obj_thresh[i]);
|
||||
}
|
||||
// nms_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "nms_thresh");
|
||||
nms_thresh = json_item->valuedouble;
|
||||
printf("Got nms_thresh: %f\n", nms_thresh);
|
||||
|
||||
cJSON_Delete(json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
void instrusion_detect()
|
||||
{
|
||||
int ret = 0;
|
||||
int result = 0;
|
||||
int size = 0;
|
||||
param_parse();
|
||||
g_fd = open("/dev/ov2640", O_RDONLY);
|
||||
if (g_fd < 0) {
|
||||
printf("open ov2640 fail !!");
|
||||
return;
|
||||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
rt_free_align(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
rt_free_align(showbuffer);
|
||||
rt_free_align(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
memset(showbuffer, 0, sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
memset(kpurgbbuffer, 127, net_input_size[0] * net_input_size[1] * 3);
|
||||
shoot_para_t.pdata = (unsigned int *)(showbuffer);
|
||||
shoot_para_t.length = (size_t)(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
/*
|
||||
load memory
|
||||
*/
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
if (kmodel_fd < 0) {
|
||||
printf("open kmodel fail");
|
||||
close(g_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
} else {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
|
||||
} else {
|
||||
printf("read kmodel success \n");
|
||||
}
|
||||
}
|
||||
unsigned char *model_data_align = (unsigned char *)(((unsigned int)model_data + 255) & (~255));
|
||||
dvp_set_ai_addr((uint32_t)(kpurgbbuffer + net_input_size[1] * (net_input_size[0] - sensor_output_size[0])),
|
||||
(uint32_t)(kpurgbbuffer + net_input_size[1] * (net_input_size[0] - sensor_output_size[0]) +
|
||||
net_input_size[0] * net_input_size[1]),
|
||||
(uint32_t)(kpurgbbuffer + net_input_size[0] * net_input_size[1] * 2 +
|
||||
net_input_size[1] * (net_input_size[0] - sensor_output_size[0])));
|
||||
if (kpu_load_kmodel(&instrusion_detect_task, model_data_align) != 0) {
|
||||
printf("\nmodel init error\n");
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
}
|
||||
instrusion_detect_rl.anchor_number = ANCHOR_NUM;
|
||||
instrusion_detect_rl.anchor = anchor;
|
||||
instrusion_detect_rl.threshold = malloc(class_num * sizeof(float));
|
||||
for (int idx = 0; idx < class_num; idx++) {
|
||||
instrusion_detect_rl.threshold[idx] = obj_thresh[idx];
|
||||
}
|
||||
instrusion_detect_rl.nms_value = nms_thresh;
|
||||
result = region_layer_init(&instrusion_detect_rl, net_output_shape[0], net_output_shape[1], net_output_shape[2],
|
||||
net_input_size[1], net_input_size[0]);
|
||||
printf("region_layer_init result %d \n\r", result);
|
||||
size_t stack_size = STACK_SIZE;
|
||||
pthread_attr_t attr; /* 线程属性 */
|
||||
struct sched_param prio; /* 线程优先级 */
|
||||
prio.sched_priority = 8; /* 优先级设置为 8 */
|
||||
pthread_attr_init(&attr); /* 先使用默认值初始化属性 */
|
||||
pthread_attr_setschedparam(&attr, &prio); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attr, stack_size);
|
||||
|
||||
/* 创建线程 1, 属性为 attr,入口函数是 thread_entry,入口函数参数是 1 */
|
||||
result = pthread_create(&instrusiontid, &attr, thread_instrusion_detect_entry, NULL);
|
||||
if (0 == result) {
|
||||
printf("thread_instrusion_detect_entry successfully!\n");
|
||||
} else {
|
||||
printf("thread_instrusion_detect_entry failed! error code is %d\n", result);
|
||||
close(g_fd);
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(instrusion_detect, instrusion detect task);
|
||||
#endif
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
|
||||
extern void lcd_draw_16_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
|
||||
static void *thread_instrusion_detect_entry(void *parameter)
|
||||
{
|
||||
printf("thread_instrusion_detect_entry start!\n");
|
||||
int ret = 0;
|
||||
// sysctl_enable_irq();
|
||||
while (1) {
|
||||
// memset(showbuffer,0,320*240*2);
|
||||
g_ai_done_flag = 0;
|
||||
ret = ioctl(g_fd, IOCTRL_CAMERA_START_SHOT, &shoot_para_t);
|
||||
if (RT_ERROR == ret) {
|
||||
printf("ov2640 can't wait event flag");
|
||||
rt_free(showbuffer);
|
||||
close(g_fd);
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (dmalock_sync_take(&dma_ch, 2000))
|
||||
{
|
||||
printf("Fail to take DMA channel");
|
||||
}
|
||||
kpu_run_kmodel(&instrusion_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
dmalock_release(dma_ch);
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&instrusion_detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
instrusion_detect_rl.input = output;
|
||||
region_layer_run(&instrusion_detect_rl, &instrusion_detect_info);
|
||||
/* display result */
|
||||
for (int instrusion_cnt = 0; instrusion_cnt < instrusion_detect_info.obj_number; instrusion_cnt++)
|
||||
{
|
||||
draw_edge((uint32_t *)showbuffer, &instrusion_detect_info, instrusion_cnt, 0xF800,(uint16_t)sensor_output_size[1],(uint16_t)sensor_output_size[0]);
|
||||
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", instrusion_cnt, instrusion_detect_info.obj[instrusion_cnt].x1,
|
||||
instrusion_detect_info.obj[instrusion_cnt].y1, instrusion_detect_info.obj[instrusion_cnt].x2,
|
||||
instrusion_detect_info.obj[instrusion_cnt].y2, labels[instrusion_detect_info.obj[instrusion_cnt].class_id],
|
||||
instrusion_detect_info.obj[instrusion_cnt].prob);
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
//lcd_show_image(0, 0,(uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0],(unsigned int *)showbuffer);
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
|
||||
#endif
|
||||
if (0 != instrusion_detect_info.obj_number) {
|
||||
printf("\n");
|
||||
}
|
||||
usleep(1);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
printf("thread_instrusion_detect_entry exit");
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void instrusion_detect_delete()
|
||||
{
|
||||
if (showbuffer != NULL) {
|
||||
int ret = 0;
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
printf("instrusion detect task cancel!!! ret %d ", ret);
|
||||
if_exit = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(instrusion_detect_delete, instrusion detect task delete);
|
||||
#endif
|
||||
|
||||
void kmodel_load(unsigned char *model_data)
|
||||
{
|
||||
int kmodel_fd = 0;
|
||||
int size = 0;
|
||||
kmodel_fd = open(kmodel_path, O_RDONLY);
|
||||
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, kmodel_size + 255);
|
||||
|
||||
if (kmodel_fd >= 0) {
|
||||
size = read(kmodel_fd, model_data, kmodel_size);
|
||||
if (size != kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
|
||||
} else {
|
||||
printf("read kmodel success");
|
||||
}
|
||||
} else {
|
||||
free(model_data);
|
||||
printf("open kmodel fail");
|
||||
}
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(kmodel_load, kmodel load memory);
|
||||
#endif
|
|
@ -19,7 +19,8 @@ void simple_CSV_read()
|
|||
fin = open(CSV_PATH, O_RDONLY);
|
||||
if (!fin) {
|
||||
printf("Error open file %s", CSV_PATH);
|
||||
exit(-1);
|
||||
// exit(-1);
|
||||
return;
|
||||
}
|
||||
read(fin, buffer, sizeof(buffer));
|
||||
close(fin);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
config K210_DETECT_ENTRY
|
||||
bool "enable apps/k210 yolov2 detect entry"
|
||||
depends on BOARD_K210_EVB
|
||||
depends on DRV_USING_OV2640
|
||||
depends on USING_KPU_PROCESSING
|
||||
depends on USING_YOLOV2
|
||||
depends on USING_YOLOV2_JSONPARSER
|
||||
depends on USING_K210_YOLOV2_DETECT
|
||||
select LIB_USING_CJSON
|
||||
default n
|
|
@ -4,6 +4,6 @@ cwd = GetCurrentDir()
|
|||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = ['HELMET_DETECT'], LOCAL_CPPPATH = CPPPATH)
|
||||
group = DefineGroup('Applications', src, depend = ['USING_K210_YOLOV2_DETECT'], LOCAL_CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
|
@ -24,7 +24,6 @@
|
|||
6.718375,
|
||||
9.01025
|
||||
],
|
||||
"kmodel_path": "/kmodel/detect.kmodel",
|
||||
"kmodel_size": 388776,
|
||||
"obj_thresh": [
|
||||
0.7
|
|
@ -24,11 +24,10 @@
|
|||
2.1128,
|
||||
3.184
|
||||
],
|
||||
"kmodel_path": "/kmodel/helmet.kmodel",
|
||||
"kmodel_size": 2714044,
|
||||
"obj_thresh": [
|
||||
0.7,
|
||||
0.9
|
||||
0.99
|
||||
],
|
||||
"labels": [
|
||||
"head",
|
|
@ -24,7 +24,6 @@
|
|||
2.049,
|
||||
4.6711
|
||||
],
|
||||
"kmodel_path": "/kmodel/human.kmodel",
|
||||
"kmodel_size": 2713236,
|
||||
"obj_thresh": [
|
||||
0.7
|
|
@ -0,0 +1,16 @@
|
|||
#include "k210_yolov2_detect.h"
|
||||
static void detect_app(int argc, char *argv[])
|
||||
{
|
||||
if (2 != argc) {
|
||||
printf("Usage: detect_app <ABSOLUTE_CONFIG_JSON_PATH>");
|
||||
} else {
|
||||
k210_detect(argv[1]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// clang-format off
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(detect_app, k210 detect app usage: detect_app <ABSOLUTE_CONFIG_JSON_PATH>);
|
||||
#endif
|
||||
// clang-format on
|
|
@ -65,6 +65,26 @@ menu "sensor app"
|
|||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_PM2_5
|
||||
bool "Using sensor PM2.5 apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_SENSOR_PM2_5
|
||||
config APPLICATION_SENSOR_PM2_5_PS5308
|
||||
bool "Using sensor PS5308 apps"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_PM10
|
||||
bool "Using sensor PM10 apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_SENSOR_PM10
|
||||
config APPLICATION_SENSOR_PM10_PS5308
|
||||
bool "Using sensor PS5308 apps"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_VOICE
|
||||
bool "Using sensor voice apps"
|
||||
default n
|
||||
|
@ -75,16 +95,6 @@ menu "sensor app"
|
|||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_HUMIDITY
|
||||
bool "Using sensor humidity apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_SENSOR_HUMIDITY
|
||||
config APPLICATION_SENSOR_HUMIDITY_HS300X
|
||||
bool "Using sensor HS300x apps"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_TEMPERATURE
|
||||
bool "Using sensor temperature apps"
|
||||
default n
|
||||
|
@ -93,7 +103,26 @@ menu "sensor app"
|
|||
config APPLICATION_SENSOR_TEMPERATURE_HS300X
|
||||
bool "Using sensor HS300x apps"
|
||||
default n
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_HUMIDITY
|
||||
bool "Using sensor humidity apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_SENSOR_HUMIDITY
|
||||
config APPLICATION_SENSOR_HUMIDITY_HS300X
|
||||
bool "Using sensor HS300x apps"
|
||||
default n
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Applications/sensor_app/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_APPLICATION_SENSOR),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/sensor_app
|
||||
endif
|
|
@ -1,39 +1,103 @@
|
|||
SRC_FILES :=
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
|
||||
CSRCS += hcho_tb600b_wq_hcho1os.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
|
||||
CSRCS += tvoc_tb600b_tvoc10.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
|
||||
CSRCS += iaq_tb600b_iaq10.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
|
||||
CSRCS += ch4_as830.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
|
||||
CSRCS += co2_zg09.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
CSRCS += pm1_0_ps5308.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y)
|
||||
CSRCS += pm2_5_ps5308.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM10_PS5308), y)
|
||||
CSRCS += pm10_0_ps5308.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
|
||||
CSRCS += voice_d124.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
|
||||
CSRCS += humidity_hs300x.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
|
||||
CSRCS += temperature_hs300x.c
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
|
||||
SRC_FILES += hcho_tb600b_wq_hcho1os.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
|
||||
SRC_FILES += tvoc_tb600b_tvoc10.c
|
||||
endif
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES :=
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
|
||||
SRC_FILES += iaq_tb600b_iaq10.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
|
||||
SRC_FILES += hcho_tb600b_wq_hcho1os.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
|
||||
SRC_FILES += ch4_as830.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
|
||||
SRC_FILES += tvoc_tb600b_tvoc10.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
|
||||
SRC_FILES += co2_zg09.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
|
||||
SRC_FILES += iaq_tb600b_iaq10.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
SRC_FILES += pm1_0_ps5308.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
|
||||
SRC_FILES += ch4_as830.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
|
||||
SRC_FILES += voice_d124.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
|
||||
SRC_FILES += co2_zg09.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
|
||||
SRC_FILES += humidity_hs300x.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
SRC_FILES += pm1_0_ps5308.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
|
||||
SRC_FILES += temperature_hs300x.c
|
||||
endif
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y)
|
||||
SRC_FILES += pm2_5_ps5308.c
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM10_PS5308), y)
|
||||
SRC_FILES += pm10_0_ps5308.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
|
||||
SRC_FILES += voice_d124.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
|
||||
SRC_FILES += humidity_hs300x.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
|
||||
SRC_FILES += temperature_hs300x.c
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file pm1_0_ps5308.c
|
||||
* @brief PS5308 PM1.0 example
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
* @description: Read a PM10
|
||||
* @return 0
|
||||
*/
|
||||
void Pm100Ps5308(void)
|
||||
{
|
||||
struct SensorQuantity *pm10_0 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM10, SENSOR_QUANTITY_PM);
|
||||
SensorQuantityOpen(pm10_0);
|
||||
PrivTaskDelay(2000);
|
||||
printf("PM10 : %d ug/m³\n", SensorQuantityRead(pm10_0));
|
||||
SensorQuantityClose(pm10_0);
|
||||
}
|
|
@ -18,7 +18,10 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file pm1_0_ps5308.c
|
||||
* @brief PS5308 PM1.0 example
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
* @description: Read a PM2.5
|
||||
* @return 0
|
||||
*/
|
||||
void Pm25Ps5308(void)
|
||||
{
|
||||
struct SensorQuantity *pm2_5 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM2_5, SENSOR_QUANTITY_PM);
|
||||
SensorQuantityOpen(pm2_5);
|
||||
PrivTaskDelay(2000);
|
||||
printf("PM2.5 : %d ug/m³\n", SensorQuantityRead(pm2_5));
|
||||
SensorQuantityClose(pm2_5);
|
||||
}
|
|
@ -18,7 +18,10 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
@ -43,4 +46,3 @@ void TempHs300x(void)
|
|||
|
||||
SensorQuantityClose(temp);
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, TempHs300x, TempHs300x, TempHs300x function);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/Make.defs
|
||||
############################################################################
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/transform_layer/nuttx
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/*/Make.defs)
|
|
@ -8,6 +8,27 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using connection framework debug log function"
|
||||
default y
|
||||
|
||||
menuconfig CONNECTION_INDUSTRIAL_ETHERNET
|
||||
bool "Using industrial ethernet"
|
||||
default n
|
||||
if CONNECTION_INDUSTRIAL_ETHERNET
|
||||
source "$APP_DIR/Framework/connection/industrial_ethernet/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_INDUSTRIAL_FIELDBUS
|
||||
bool "Using industrial fieldbus"
|
||||
default n
|
||||
if CONNECTION_INDUSTRIAL_FIELDBUS
|
||||
source "$APP_DIR/Framework/connection/industrial_fieldbus/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_INDUSTRIAL_WLAN
|
||||
bool "Using industrial wlan"
|
||||
default n
|
||||
if CONNECTION_INDUSTRIAL_WLAN
|
||||
source "$APP_DIR/Framework/connection/industrial_wlan/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_ADAPTER_LORA
|
||||
bool "Using lora adapter device"
|
||||
default n
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
SRC_FILES := adapter.c adapter_agent.c
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y)
|
||||
SRC_DIR += industrial_ethernet
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
||||
SRC_DIR += industrial_fieldbus
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_WLAN),y)
|
||||
SRC_DIR += industrial_wlan
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||
SRC_DIR += lora
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -5,9 +5,9 @@ menuconfig SUPPORT_KNOWING_FRAMEWORK
|
|||
|
||||
if SUPPORT_KNOWING_FRAMEWORK
|
||||
source "$APP_DIR/Framework/knowing/tensorflow-lite/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/kpu-postprocessing/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/filter/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/ota/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/image_processing/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/cmsis_5/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/kpu/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
menuconfig USING_IMAGE_PROCESSING
|
||||
bool "image processing "
|
||||
default n
|
||||
if USING_IMAGE_PROCESSING
|
||||
source "$APP_DIR/Framework/knowing/image_processing/TJpgDec/Kconfig"
|
||||
endif
|
||||
menuconfig USING_IMAGE_PROCESSING
|
||||
bool "image processing "
|
||||
default n
|
||||
if USING_IMAGE_PROCESSING
|
||||
source "$APP_DIR/Framework/knowing/image_processing/TJpgDec/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
menuconfig IMAGE_PROCESSING_USING_TJPGD
|
||||
bool "TJpgDec: Tiny JPEG Decompressor."
|
||||
default n
|
||||
|
||||
if IMAGE_PROCESSING_USING_TJPGD
|
||||
config TJPGD_INPUT_BUFFER_SIZE
|
||||
int "Size of stream input buffer"
|
||||
default 512
|
||||
choice
|
||||
prompt "Output format"
|
||||
default TJPGD_USING_FORMAT_RGB888
|
||||
help
|
||||
Select the RGB output format
|
||||
config TJPGD_USING_FORMAT_RGB888
|
||||
bool "RGB888"
|
||||
config TJPGD_USING_FORMAT_RGB565
|
||||
bool "RGB565"
|
||||
endchoice
|
||||
|
||||
config TJPGD_USING_SCALE
|
||||
bool "Use output descaling"
|
||||
default y
|
||||
|
||||
config TJPGD_USING_TBLCLIP
|
||||
bool "Use table for saturation"
|
||||
default y
|
||||
endif
|
||||
menuconfig IMAGE_PROCESSING_USING_TJPGD
|
||||
bool "TJpgDec: Tiny JPEG Decompressor."
|
||||
default n
|
||||
|
||||
if IMAGE_PROCESSING_USING_TJPGD
|
||||
config TJPGD_INPUT_BUFFER_SIZE
|
||||
int "Size of stream input buffer"
|
||||
default 512
|
||||
choice
|
||||
prompt "Output format"
|
||||
default TJPGD_USING_FORMAT_RGB888
|
||||
help
|
||||
Select the RGB output format
|
||||
config TJPGD_USING_FORMAT_RGB888
|
||||
bool "RGB888"
|
||||
config TJPGD_USING_FORMAT_RGB565
|
||||
bool "RGB565"
|
||||
endchoice
|
||||
|
||||
config TJPGD_USING_SCALE
|
||||
bool "Use output descaling"
|
||||
default y
|
||||
|
||||
config TJPGD_USING_TBLCLIP
|
||||
bool "Use table for saturation"
|
||||
default y
|
||||
endif
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
menuconfig USING_KPU_POSTPROCESSING
|
||||
bool "kpu model postprocessing"
|
||||
default y
|
||||
if USING_KPU_POSTPROCESSING
|
||||
source "$APP_DIR/Framework/knowing/kpu-postprocessing/yolov2/Kconfig"
|
||||
endif
|
|
@ -0,0 +1,8 @@
|
|||
menuconfig USING_KPU_PROCESSING
|
||||
bool "kpu model processing"
|
||||
default y
|
||||
if USING_KPU_PROCESSING
|
||||
source "$APP_DIR/Framework/knowing/kpu/yolov2/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/kpu/yolov2_json/Kconfig"
|
||||
source "$APP_DIR/Framework/knowing/kpu/k210_yolov2_detect_procedure/Kconfig"
|
||||
endif
|
|
@ -0,0 +1,7 @@
|
|||
menuconfig USING_K210_YOLOV2_DETECT
|
||||
bool "k210 yolov2 detect procedure"
|
||||
depends on USING_KPU_PROCESSING
|
||||
default n
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
src = Glob('*.c')
|
||||
|
||||
group = DefineGroup('k210_yolov2_detect_procedure', src, depend = ['USING_YOLOV2', 'USING_YOLOV2_JSONPARSER', 'USING_KPU_PROCESSING'], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
|
@ -0,0 +1,278 @@
|
|||
#include "k210_yolov2_detect.h"
|
||||
|
||||
#include "cJSON.h"
|
||||
#ifdef USING_YOLOV2_JSONPARSER
|
||||
#include <json_parser.h>
|
||||
#endif
|
||||
#include "region_layer.h"
|
||||
#define STACK_SIZE (128 * 1024)
|
||||
|
||||
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
|
||||
|
||||
#define THREAD_PRIORITY_D (11)
|
||||
static pthread_t tid = 0;
|
||||
static void *thread_detect_entry(void *parameter);
|
||||
static int g_fd = 0;
|
||||
static int kmodel_fd = 0;
|
||||
static int if_exit = 0;
|
||||
static unsigned char *showbuffer = NULL;
|
||||
static unsigned char *kpurgbbuffer = NULL;
|
||||
|
||||
static _ioctl_shoot_para shoot_para_t = {0};
|
||||
unsigned char *model_data = NULL; // kpu data load memory
|
||||
unsigned char *model_data_align = NULL;
|
||||
|
||||
kpu_model_context_t detect_task;
|
||||
static region_layer_t detect_rl;
|
||||
static obj_info_t detect_info;
|
||||
volatile uint32_t g_ai_done_flag;
|
||||
|
||||
static void ai_done(void *ctx) { g_ai_done_flag = 1; }
|
||||
|
||||
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);
|
||||
if (!detect_params.is_valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_fd = open("/dev/ov2640", O_RDONLY);
|
||||
if (g_fd < 0) {
|
||||
printf("open ov2640 fail !!");
|
||||
return;
|
||||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {detect_params.sensor_output_size[1], detect_params.sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer =
|
||||
(unsigned char *)rt_malloc_align(detect_params.sensor_output_size[0] * detect_params.sensor_output_size[1] * 2, 64);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)rt_malloc_align(detect_params.net_input_size[0] * detect_params.net_input_size[1] * 3, 64);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
rt_free_align(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(detect_params.kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
rt_free_align(showbuffer);
|
||||
rt_free_align(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
memset(model_data, 0, detect_params.kmodel_size + 255);
|
||||
memset(showbuffer, 0, detect_params.sensor_output_size[0] * detect_params.sensor_output_size[1] * 2);
|
||||
memset(kpurgbbuffer, 0, detect_params.net_input_size[0] * detect_params.net_input_size[1] * 3);
|
||||
shoot_para_t.pdata = (unsigned int *)(showbuffer);
|
||||
shoot_para_t.length = (size_t)(detect_params.sensor_output_size[0] * detect_params.sensor_output_size[1] * 2);
|
||||
/*
|
||||
load memory
|
||||
*/
|
||||
// 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);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
} else {
|
||||
size = read(kmodel_fd, model_data, detect_params.kmodel_size);
|
||||
if (size != detect_params.kmodel_size) {
|
||||
printf("read kmodel error size %d\n", size);
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
|
||||
} else {
|
||||
printf("read kmodel success \n");
|
||||
}
|
||||
}
|
||||
unsigned char *model_data_align = (unsigned char *)(((unsigned int)model_data + 255) & (~255));
|
||||
// dvp_set_ai_addr((uint32_t)kpurgbbuffer,
|
||||
// (uint32_t)(kpurgbbuffer + detect_params.net_input_size[0] * detect_params.net_input_size[1]),
|
||||
// (uint32_t)(kpurgbbuffer + detect_params.net_input_size[0] * detect_params.net_input_size[1] * 2));
|
||||
dvp_set_ai_addr(
|
||||
(uint32_t)(kpurgbbuffer +
|
||||
detect_params.net_input_size[1] * (detect_params.net_input_size[0] - detect_params.sensor_output_size[0])),
|
||||
(uint32_t)(kpurgbbuffer +
|
||||
detect_params.net_input_size[1] * (detect_params.net_input_size[0] - detect_params.sensor_output_size[0]) +
|
||||
detect_params.net_input_size[0] * detect_params.net_input_size[1]),
|
||||
(uint32_t)(kpurgbbuffer +
|
||||
detect_params.net_input_size[1] * (detect_params.net_input_size[0] - detect_params.sensor_output_size[0]) +
|
||||
detect_params.net_input_size[0] * detect_params.net_input_size[1] * 2));
|
||||
if (kpu_load_kmodel(&detect_task, model_data_align) != 0) {
|
||||
printf("\nmodel init error\n");
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
return;
|
||||
}
|
||||
|
||||
detect_rl.anchor_number = ANCHOR_NUM;
|
||||
detect_rl.anchor = detect_params.anchor;
|
||||
detect_rl.nms_value = detect_params.nms_thresh;
|
||||
detect_rl.classes = detect_params.class_num;
|
||||
result =
|
||||
region_layer_init(&detect_rl, detect_params.net_output_shape[0], detect_params.net_output_shape[1],
|
||||
detect_params.net_output_shape[2], detect_params.net_input_size[1], detect_params.net_input_size[0]);
|
||||
printf("region_layer_init result %d \n\r", result);
|
||||
for (int idx = 0; idx < detect_params.class_num; idx++) {
|
||||
detect_rl.threshold[idx] = detect_params.obj_thresh[idx];
|
||||
}
|
||||
|
||||
size_t stack_size = STACK_SIZE;
|
||||
pthread_attr_t attr; /* 线程属性 */
|
||||
struct sched_param prio; /* 线程优先级 */
|
||||
prio.sched_priority = 8; /* 优先级设置为 8 */
|
||||
pthread_attr_init(&attr); /* 先使用默认值初始化属性 */
|
||||
pthread_attr_setschedparam(&attr, &prio); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attr, stack_size);
|
||||
|
||||
/* 创建线程 1, 属性为 attr,入口函数是 thread_entry,入口函数参数是 1 */
|
||||
result = pthread_create(&tid, &attr, thread_detect_entry, &detect_params);
|
||||
if (0 == result) {
|
||||
printf("thread_detect_entry successfully!\n");
|
||||
} else {
|
||||
printf("thread_detect_entry failed! error code is %d\n", result);
|
||||
close(g_fd);
|
||||
}
|
||||
}
|
||||
// #ifdef __RT_THREAD_H__
|
||||
// MSH_CMD_EXPORT(detect, detect task);
|
||||
// #endif
|
||||
|
||||
static void *thread_detect_entry(void *parameter)
|
||||
{
|
||||
yolov2_params_t detect_params = *(yolov2_params_t *)parameter;
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
printf("thread_detect_entry start!\n");
|
||||
int ret = 0;
|
||||
// sysctl_enable_irq();
|
||||
while (1) {
|
||||
// memset(showbuffer,0,320*240*2);
|
||||
g_ai_done_flag = 0;
|
||||
ret = ioctl(g_fd, IOCTRL_CAMERA_START_SHOT, &shoot_para_t);
|
||||
if (RT_ERROR == ret) {
|
||||
printf("ov2640 can't wait event flag");
|
||||
rt_free(showbuffer);
|
||||
close(g_fd);
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (dmalock_sync_take(&dma_ch, 2000)) {
|
||||
printf("Fail to take DMA channel");
|
||||
}
|
||||
kpu_run_kmodel(&detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
dmalock_release(dma_ch);
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
detect_rl.input = output;
|
||||
region_layer_run(&detect_rl, &detect_info);
|
||||
/* display result */
|
||||
|
||||
for (int cnt = 0; cnt < detect_info.obj_number; cnt++) {
|
||||
draw_edge((uint32_t *)showbuffer, &detect_info, cnt, 0xF800, (uint16_t)detect_params.sensor_output_size[1],
|
||||
(uint16_t)detect_params.sensor_output_size[0]);
|
||||
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", cnt, detect_info.obj[cnt].x1, detect_info.obj[cnt].y1,
|
||||
detect_info.obj[cnt].x2, detect_info.obj[cnt].y2, detect_params.labels[detect_info.obj[cnt].class_id],
|
||||
detect_info.obj[cnt].prob);
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
lcd_draw_picture(0, 0, (uint16_t)detect_params.sensor_output_size[1] - 1,
|
||||
(uint16_t)detect_params.sensor_output_size[0] - 1, (uint32_t *)showbuffer);
|
||||
// lcd_show_image(0, 0, (uint16_t)detect_params.sensor_output_size[1], (uint16_t)detect_params.sensor_output_size[0],
|
||||
// (unsigned int *)showbuffer);
|
||||
#endif
|
||||
usleep(500);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
printf("thread_detect_entry exit");
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detect_delete()
|
||||
{
|
||||
if (showbuffer != NULL) {
|
||||
int ret = 0;
|
||||
close(g_fd);
|
||||
close(kmodel_fd);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
free(model_data);
|
||||
printf("detect task cancel!!! ret %d ", ret);
|
||||
if_exit = 1;
|
||||
}
|
||||
}
|
||||
// #ifdef __RT_THREAD_H__
|
||||
// MSH_CMD_EXPORT(detect_delete, detect task delete);
|
||||
// #endif
|
||||
|
||||
// void kmodel_load(unsigned char *model_data)
|
||||
// {
|
||||
// int kmodel_fd = 0;
|
||||
// int size = 0;
|
||||
// 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) {
|
||||
// printf("model_data apply memory fail !!");
|
||||
// return;
|
||||
// }
|
||||
// memset(model_data, 0, detect_params.kmodel_size + 255);
|
||||
|
||||
// if (kmodel_fd >= 0) {
|
||||
// size = read(kmodel_fd, model_data, detect_params.kmodel_size);
|
||||
// if (size != detect_params.kmodel_size) {
|
||||
// printf("read kmodel error size %d\n", size);
|
||||
|
||||
// } else {
|
||||
// printf("read kmodel success");
|
||||
// }
|
||||
// } else {
|
||||
// free(model_data);
|
||||
// printf("open kmodel fail");
|
||||
// }
|
||||
// }
|
||||
// #ifdef __RT_THREAD_H__
|
||||
// MSH_CMD_EXPORT(kmodel_load, kmodel load memory);
|
||||
// #endif
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _K210_DETECT_H_
|
||||
#define _K210_DETECT_H_
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
void k210_detect(char *json_file_path);
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
menuconfig USING_YOLOV2
|
||||
bool "yolov2 region layer"
|
||||
depends on USING_KPU_POSTPROCESSING
|
||||
depends on USING_KPU_PROCESSING
|
||||
default n
|
||||
|
||||
|
|
@ -58,12 +58,14 @@ int region_layer_init(region_layer_t *rl, int width, int height, int channels, i
|
|||
goto malloc_error;
|
||||
}
|
||||
for (uint32_t i = 0; i < rl->boxes_number; i++) rl->probs[i] = &(rl->probs_buf[i * (rl->classes + 1)]);
|
||||
rl->threshold = malloc(rl->classes * sizeof(float));
|
||||
return 0;
|
||||
malloc_error:
|
||||
free(rl->output);
|
||||
free(rl->boxes);
|
||||
free(rl->probs_buf);
|
||||
free(rl->probs);
|
||||
free(rl->threshold);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
@ -73,6 +75,7 @@ void region_layer_deinit(region_layer_t *rl)
|
|||
free(rl->boxes);
|
||||
free(rl->probs_buf);
|
||||
free(rl->probs);
|
||||
free(rl->threshold);
|
||||
}
|
||||
|
||||
static inline float sigmoid(float x) { return 1.f / (1.f + expf(-x)); }
|
|
@ -0,0 +1,7 @@
|
|||
menuconfig USING_YOLOV2_JSONPARSER
|
||||
bool "yolov2 model json parser"
|
||||
depends on USING_KPU_PROCESSING
|
||||
default n
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
src = Glob('*.c')
|
||||
|
||||
group = DefineGroup('yolov2_json', src, depend = ['LIB_USING_CJSON'], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
|
@ -0,0 +1,157 @@
|
|||
#include "json_parser.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "cJSON.h"
|
||||
|
||||
yolov2_params_t param_parse(char *json_file_path)
|
||||
{
|
||||
yolov2_params_t params_return;
|
||||
params_return.is_valid = 1;
|
||||
int fin;
|
||||
char buffer[JSON_BUFFER_SIZE] = "";
|
||||
// char *buffer;
|
||||
// if ((yolov2_params_t *)NULL != (buffer = (char*)malloc(JSON_BUFFER_SIZE * sizeof(char)))) {
|
||||
// memset(buffer, 0, JSON_BUFFER_SIZE * sizeof(char));
|
||||
// } else {
|
||||
// printf("Json buffer malloc failed!");
|
||||
// params_return.is_valid = 0;
|
||||
// return params_return;
|
||||
// }
|
||||
int array_size;
|
||||
cJSON *json_obj;
|
||||
cJSON *json_item;
|
||||
cJSON *json_array_item;
|
||||
|
||||
fin = open(json_file_path, O_RDONLY);
|
||||
if (!fin) {
|
||||
printf("Error open file %s\n", json_file_path);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Reading config from: %s\n", json_file_path);
|
||||
}
|
||||
read(fin, buffer, sizeof(buffer));
|
||||
close(fin);
|
||||
|
||||
// read json string
|
||||
json_obj = cJSON_Parse(buffer);
|
||||
// free(buffer);
|
||||
char *json_print_str = cJSON_Print(json_obj);
|
||||
printf("Json file content: \n%s\n", json_print_str);
|
||||
cJSON_free(json_print_str);
|
||||
// get anchors
|
||||
json_item = cJSON_GetObjectItem(json_obj, "anchors");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (ANCHOR_NUM * 2 != array_size) {
|
||||
printf("Expect anchor size: %d, got %d in json file", ANCHOR_NUM * 2, array_size);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d anchors from json file\n", ANCHOR_NUM);
|
||||
}
|
||||
for (int i = 0; i < ANCHOR_NUM * 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
params_return.anchor[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, params_return.anchor[i]);
|
||||
}
|
||||
// net_input_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_input_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect net_input_size: %d, got %d in json file", 2, array_size);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d net_input_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
params_return.net_input_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, params_return.net_input_size[i]);
|
||||
}
|
||||
// net_output_shape
|
||||
json_item = cJSON_GetObjectItem(json_obj, "net_output_shape");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (3 != array_size) {
|
||||
printf("Expect net_output_shape: %d, got %d in json file", 3, array_size);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d net_output_shape from json file\n", 3);
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
params_return.net_output_shape[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, params_return.net_output_shape[i]);
|
||||
}
|
||||
// sensor_output_size
|
||||
json_item = cJSON_GetObjectItem(json_obj, "sensor_output_size");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (2 != array_size) {
|
||||
printf("Expect sensor_output_size: %d, got %d in json file", 2, array_size);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d sensor_output_size from json file\n", 2);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
params_return.sensor_output_size[i] = json_array_item->valueint;
|
||||
printf("%d: %d\n", i, params_return.sensor_output_size[i]);
|
||||
}
|
||||
// check sensor output width and net input width
|
||||
if (params_return.sensor_output_size[1] != params_return.net_input_size[1]) {
|
||||
printf("Net input width must match sensor output width!\n");
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
}
|
||||
// // 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;
|
||||
printf("Got kmodel_size: %d\n", params_return.kmodel_size);
|
||||
// labels
|
||||
json_item = cJSON_GetObjectItem(json_obj, "labels");
|
||||
params_return.class_num = cJSON_GetArraySize(json_item);
|
||||
if (0 >= params_return.class_num) {
|
||||
printf("No labels!");
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d labels\n", params_return.class_num);
|
||||
}
|
||||
for (int i = 0; i < params_return.class_num; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
memset(params_return.labels[i], 0, 127);
|
||||
memcpy(params_return.labels[i], json_array_item->valuestring, strlen(json_array_item->valuestring));
|
||||
printf("%d: %s\n", i, params_return.labels[i]);
|
||||
}
|
||||
// obj_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "obj_thresh");
|
||||
array_size = cJSON_GetArraySize(json_item);
|
||||
if (params_return.class_num != array_size) {
|
||||
printf("label number and thresh number mismatch! label number : %d, obj thresh number %d", params_return.class_num,
|
||||
array_size);
|
||||
params_return.is_valid = 0;
|
||||
return params_return;
|
||||
} else {
|
||||
printf("Got %d obj_thresh\n", array_size);
|
||||
}
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
json_array_item = cJSON_GetArrayItem(json_item, i);
|
||||
params_return.obj_thresh[i] = json_array_item->valuedouble;
|
||||
printf("%d: %f\n", i, params_return.obj_thresh[i]);
|
||||
}
|
||||
// nms_thresh
|
||||
json_item = cJSON_GetObjectItem(json_obj, "nms_thresh");
|
||||
params_return.nms_thresh = json_item->valuedouble;
|
||||
printf("Got nms_thresh: %f\n", params_return.nms_thresh);
|
||||
|
||||
cJSON_Delete(json_obj);
|
||||
return params_return;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef _JSON_PARSER_H_
|
||||
#define _JSON_PARSER_H_
|
||||
|
||||
#define ANCHOR_NUM 5
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
|
||||
// params from json
|
||||
typedef struct {
|
||||
float anchor[ANCHOR_NUM * 2];
|
||||
int net_output_shape[3];
|
||||
int net_input_size[2];
|
||||
int sensor_output_size[2];
|
||||
int kmodel_size;
|
||||
float obj_thresh[20];
|
||||
float nms_thresh;
|
||||
char labels[20][32];
|
||||
int class_num;
|
||||
int is_valid;
|
||||
} yolov2_params_t;
|
||||
|
||||
yolov2_params_t param_parse(char *json_file_path);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/*/Make.defs)
|
|
@ -1,39 +1,49 @@
|
|||
SRC_FILES := sensor.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += sensor.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_HCHO),y)
|
||||
SRC_DIR += hcho
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_TVOC),y)
|
||||
SRC_DIR += tvoc
|
||||
endif
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := sensor.c
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_IAQ),y)
|
||||
SRC_DIR += iaq
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_HCHO),y)
|
||||
SRC_DIR += hcho
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_CH4),y)
|
||||
SRC_DIR += ch4
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_TVOC),y)
|
||||
SRC_DIR += tvoc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_CO2),y)
|
||||
SRC_DIR += co2
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_IAQ),y)
|
||||
SRC_DIR += iaq
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_PM),y)
|
||||
SRC_DIR += pm
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_CH4),y)
|
||||
SRC_DIR += ch4
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_VOICE),y)
|
||||
SRC_DIR += voice
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_CO2),y)
|
||||
SRC_DIR += co2
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y)
|
||||
SRC_DIR += temperature
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_PM),y)
|
||||
SRC_DIR += pm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_HUMIDITY),y)
|
||||
SRC_DIR += humidity
|
||||
endif
|
||||
ifeq ($(CONFIG_SENSOR_VOICE),y)
|
||||
SRC_DIR += voice
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y)
|
||||
SRC_DIR += temperature
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_HUMIDITY),y)
|
||||
SRC_DIR += humidity
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
@ -34,6 +34,11 @@ config SENSOR_ZG09
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config SENSOR_DEVICE_ZG09_DEV
|
||||
string "CO2 device name"
|
||||
default "/dev/ttyS1"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/co2/Make.defs
|
||||
############################################################################
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/co2/*/Make.defs)
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/co2/zg09/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_ZG09),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/co2/zg09
|
||||
endif
|
|
@ -1,3 +1,13 @@
|
|||
SRC_FILES := zg09.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += zg09.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := zg09.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -38,6 +38,25 @@ static struct SensorProductInfo info =
|
|||
* @param sdev - sensor device pointer
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_ZG09_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("open %s error\n", SENSOR_DEVICE_ZG09_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = sdev->done->ioctl(sdev, SENSOR_DEVICE_PASSIVE);
|
||||
if (result != 0){
|
||||
printf("SensorDeviceOpen:ioctl failed, status=%d\n", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -70,6 +89,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: Read sensor device
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
config SENSOR_HS300X
|
||||
bool "Using HS300x"
|
||||
config SENSOR_HS300X_HUMIDITY
|
||||
bool "Using HS300x for humidity"
|
||||
default n
|
||||
|
||||
if SENSOR_HS300X
|
||||
if SENSOR_HS300X_HUMIDITY
|
||||
config SENSOR_DEVICE_HS300X
|
||||
string "HS300x sensor name"
|
||||
default "hs300x_1"
|
||||
|
@ -22,7 +22,15 @@ config SENSOR_HS300X
|
|||
default 0x44
|
||||
endif
|
||||
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config SENSOR_DEVICE_HS300X_DEV
|
||||
string "HS300x device name"
|
||||
default "/dev/i2c1_dev0"
|
||||
|
||||
config SENSOR_DEVICE_HS300X_I2C_ADDR
|
||||
hex "HS300x device i2c address"
|
||||
default 0x44
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/humidity/Make.defs
|
||||
############################################################################
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/humidity/*/Make.defs)
|
|
@ -1,4 +1,4 @@
|
|||
ifeq ($(CONFIG_SENSOR_HS300X),y)
|
||||
ifeq ($(CONFIG_SENSOR_HS300X_HUMIDITY),y)
|
||||
SRC_DIR += hs300x_humi
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/humidity/hs300x_humi/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_HS300X_HUMIDITY),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/humidity/hs300x_humi
|
||||
endif
|
|
@ -1,3 +1,13 @@
|
|||
SRC_FILES := hs300x_humi.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += hs300x_humi.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := hs300x_humi.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
|
@ -36,6 +36,12 @@ static struct SensorProductInfo info =
|
|||
*/
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_HS300X_DEV, O_RDWR);
|
||||
|
||||
return sdev->fd;
|
||||
|
||||
#else
|
||||
int result;
|
||||
uint16_t i2c_dev_addr = SENSOR_DEVICE_HS300X_I2C_ADDR;
|
||||
|
||||
|
@ -52,6 +58,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,6 +69,16 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
int ret;
|
||||
ret = PrivRead(sdev->fd, sdev->buffer, len);
|
||||
if (ret != len ){
|
||||
perror("Failed to read data!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
//send i2c device start signal and address, need to implemente in OS i2c driver
|
||||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
@ -73,6 +90,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
return -1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
|
|
|
@ -8,18 +8,36 @@ config SENSOR_PS5308
|
|||
string "PS5308 sensor name"
|
||||
default "ps5308_1"
|
||||
|
||||
config SENSOR_QUANTITY_PS5308_PM1_0
|
||||
string "PS5308 quantity PM1.0 name"
|
||||
default "pm1_0_1"
|
||||
config PS5308_PM1_0
|
||||
bool "Using pm1.0 function"
|
||||
default n
|
||||
|
||||
if PS5308_PM1_0
|
||||
config SENSOR_QUANTITY_PS5308_PM1_0
|
||||
string "PS5308 quantity PM1.0 name"
|
||||
default "pm1_0_1"
|
||||
endif
|
||||
|
||||
config PS5308_PM2_5
|
||||
bool "Using pm2.5 function"
|
||||
default n
|
||||
|
||||
if PS5308_PM2_5
|
||||
config SENSOR_QUANTITY_PS5308_PM2_5
|
||||
string "PS5308 quantity PM2.5 name"
|
||||
default "pm2_5_1"
|
||||
endif
|
||||
|
||||
config PS5308_PM10
|
||||
bool "Using pm10 function"
|
||||
default n
|
||||
|
||||
if PS5308_PM10
|
||||
config SENSOR_QUANTITY_PS5308_PM10
|
||||
string "PS5308 quantity PM10 name"
|
||||
default "pm10_1"
|
||||
endif
|
||||
|
||||
config SENSOR_QUANTITY_PS5308_PM2_5
|
||||
string "PS5308 quantity PM2.5 name"
|
||||
default "pm2_5_1"
|
||||
|
||||
config SENSOR_QUANTITY_PS5308_PM10
|
||||
string "PS5308 quantity PM10 name"
|
||||
default "pm10_1"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
config SENSOR_PS5308_DRIVER_EXTUART
|
||||
bool "Using extra uart to support PS5308"
|
||||
|
@ -42,6 +60,11 @@ config SENSOR_PS5308
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config SENSOR_DEVICE_PS5308_DEV
|
||||
string "PS5308 device name"
|
||||
default "/dev/ttyS1"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/pm/Make.defs
|
||||
############################################################################
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/*/Make.defs)
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/pm/ps5308/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_PS5308),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/ps5308
|
||||
endif
|
|
@ -1,3 +1,11 @@
|
|||
SRC_FILES := ps5308.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += ps5308.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := ps5308.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
@ -51,6 +51,32 @@ static void *ReadTask(void *parameter)
|
|||
* @param sdev - sensor device pointer
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
result = PrivMutexCreate(&buff_lock, 0);
|
||||
if (result != 0){
|
||||
printf("SensorDeviceOpen:mutex create failed, status=%d\n", result);
|
||||
}
|
||||
|
||||
sdev->fd = open(SENSOR_DEVICE_PS5308_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("SensorDeviceOpen:open %s error\n", SENSOR_DEVICE_PS5308_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
|
||||
if (result != 0){
|
||||
printf("SensorDeviceOpen:task create failed, status=%d\n", result);
|
||||
}
|
||||
|
||||
PrivTaskStartup(&active_task_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -76,13 +102,14 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
cfg.port_configure = PORT_CFG_INIT;
|
||||
#endif
|
||||
|
||||
result = ioctl(sdev->fd, OPE_INT, &cfg);
|
||||
result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
|
||||
|
||||
PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
|
||||
PrivTaskStartup(&active_task_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: Close PS5308 sensor device
|
||||
|
|
|
@ -151,12 +151,9 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
if (sdev->done->open != NULL)
|
||||
result = sdev->done->open(sdev);
|
||||
|
||||
if (result == 0) {
|
||||
if (result >= 0) {
|
||||
printf("Device %s open success.\n", sdev->name);
|
||||
}else{
|
||||
if (sdev->fd)
|
||||
PrivClose(sdev->fd);
|
||||
|
||||
printf("Device %s open failed(%d).\n", sdev->name, result);
|
||||
memset(sdev, 0, sizeof(struct SensorDevice));
|
||||
}
|
||||
|
@ -173,13 +170,13 @@ static int SensorDeviceClose(struct SensorDevice *sdev)
|
|||
{
|
||||
int result = 0;
|
||||
|
||||
if (sdev->fd)
|
||||
if (sdev->fd >= 0)
|
||||
PrivClose(sdev->fd);
|
||||
|
||||
if (sdev->done->close != NULL)
|
||||
result = sdev->done->close(sdev);
|
||||
|
||||
if (result == 0)
|
||||
if (result >= 0)
|
||||
printf("%s successfully closed.\n", sdev->name);
|
||||
else
|
||||
printf("Closed %s failure.\n", sdev->name);
|
||||
|
@ -276,7 +273,7 @@ int SensorQuantityOpen(struct SensorQuantity *quant)
|
|||
|
||||
if (sdev->ref_cnt == 0) {
|
||||
ret = SensorDeviceOpen(sdev);
|
||||
if (ret != 0) {
|
||||
if (ret < 0) {
|
||||
printf("%s: open sensor device failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
config SENSOR_HS300X
|
||||
bool "Using HS300x"
|
||||
config SENSOR_HS300X_TEMPERATURE
|
||||
bool "Using HS300x for temperature"
|
||||
default n
|
||||
|
||||
if SENSOR_HS300X
|
||||
if SENSOR_HS300X_TEMPERATURE
|
||||
config SENSOR_DEVICE_HS300X
|
||||
string "HS300x sensor name"
|
||||
default "hs300x_1"
|
||||
|
@ -23,6 +23,13 @@ config SENSOR_HS300X
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config SENSOR_DEVICE_HS300X_DEV
|
||||
string "HS300x device name"
|
||||
default "/dev/i2c1_dev0"
|
||||
|
||||
config SENSOR_DEVICE_HS300X_I2C_ADDR
|
||||
hex "HS300x device i2c address"
|
||||
default 0x44
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/temperature//Make.defs
|
||||
############################################################################
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/temperature/*/Make.defs)
|
|
@ -1,4 +1,4 @@
|
|||
ifeq ($(CONFIG_SENSOR_HS300X),y)
|
||||
ifeq ($(CONFIG_SENSOR_HS300X_TEMPERATURE),y)
|
||||
SRC_DIR += hs300x_temp
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/temperature/hs300x_temp/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_HS300X_TEMPERATURE),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/temperature/hs300x_temp
|
||||
endif
|
|
@ -1,3 +1,12 @@
|
|||
SRC_FILES := hs300x_temp.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += hs300x_temp.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := hs300x_temp.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
@ -36,6 +36,12 @@ static struct SensorProductInfo info =
|
|||
*/
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_HS300X_DEV, O_RDWR);
|
||||
|
||||
return sdev->fd;
|
||||
|
||||
#else
|
||||
int result;
|
||||
uint16_t i2c_dev_addr = SENSOR_DEVICE_HS300X_I2C_ADDR;
|
||||
|
||||
|
@ -51,6 +57,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,6 +68,16 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
int ret;
|
||||
ret = PrivRead(sdev->fd, sdev->buffer, len);
|
||||
if (ret != len ){
|
||||
perror("Failed to read data!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
//send i2c device start signal and address, need to implemente in OS i2c driver
|
||||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
@ -72,6 +89,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
return -1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
|
|
|
@ -34,6 +34,11 @@ config SENSOR_D124
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config SENSOR_DEVICE_D124_DEV
|
||||
string "D124 device name"
|
||||
default "/dev/ttyS1"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/voice/Make.defs
|
||||
############################################################################
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/voice/*/Make.defs)
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/sensor/voice/d124/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_D124),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/voice/d124
|
||||
endif
|
|
@ -1,3 +1,12 @@
|
|||
SRC_FILES := d124.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += d124.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := d124.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
@ -51,6 +51,35 @@ static void *ReadTask(void *parameter)
|
|||
* @param sdev - sensor device pointer
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
|
||||
result = PrivMutexCreate(&buff_lock, NULL);
|
||||
if (result != 0){
|
||||
printf("SensorDeviceOpen:mutex create failed, status=%d\n", result);
|
||||
}
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_D124_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("SensorDeviceOpen:open %s error\n", SENSOR_DEVICE_D124_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
attr.priority = 20;
|
||||
attr.stacksize = 2048;
|
||||
|
||||
result = PrivTaskCreate(&active_task_id, &attr, &ReadTask, sdev);
|
||||
if (result != 0){
|
||||
printf("SensorDeviceOpen:task create failed, status=%d\n", result);
|
||||
}
|
||||
PrivTaskStartup(&active_task_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -90,6 +119,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: Close D124 sensor device
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
include $(KERNEL_ROOT)/.config
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS = transform.c
|
||||
|
||||
include $(APPDIR)/Application.mk
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file xiuos.c
|
||||
* @brief Converts the framework interface to an operating system interface
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.06.07
|
||||
*/
|
||||
|
||||
#include "transform.h"
|
||||
|
||||
/**************************mutex***************************/
|
||||
/* private mutex API */
|
||||
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
|
||||
{
|
||||
return pthread_mutex_init(p_mutex, attr);
|
||||
}
|
||||
|
||||
int PrivMutexDelete(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_destroy(p_mutex);
|
||||
}
|
||||
|
||||
int PrivMutexObtain(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_lock(p_mutex);
|
||||
}
|
||||
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_unlock(p_mutex);
|
||||
}
|
||||
|
||||
/**********************semaphore****************************/
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
return sem_init(sem, pshared, value);
|
||||
}
|
||||
|
||||
int PrivSemaphoreDelete(sem_t *sem)
|
||||
{
|
||||
return sem_destroy(sem);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
|
||||
{
|
||||
return sem_timedwait(sem, abstime);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem)
|
||||
{
|
||||
return sem_trywait(sem);
|
||||
}
|
||||
|
||||
int PrivSemaphoreAbandon(sem_t *sem)
|
||||
{
|
||||
return sem_post(sem);
|
||||
}
|
||||
|
||||
/**************************task*************************/
|
||||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
return pthread_create(thread, attr, start_routine, arg);
|
||||
}
|
||||
|
||||
int PrivTaskStartup(pthread_t *thread)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PrivTaskDelete(pthread_t thread, int sig)
|
||||
{
|
||||
return pthread_kill(thread, sig);
|
||||
}
|
||||
|
||||
void PrivTaskQuit(void *value_ptr)
|
||||
{
|
||||
pthread_exit(value_ptr);
|
||||
}
|
||||
|
||||
int PrivTaskDelay(int32_t ms)
|
||||
{
|
||||
return usleep(ms);
|
||||
}
|
||||
|
||||
/*********************fs**************************/
|
||||
|
||||
/************************Driver Posix Transform***********************/
|
||||
int PrivOpen(const char *path, int flags)
|
||||
{
|
||||
return open(path, flags);
|
||||
}
|
||||
|
||||
int PrivClose(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
int PrivRead(int fd, void *buf, size_t len)
|
||||
{
|
||||
return read(fd, buf, len);
|
||||
}
|
||||
|
||||
int PrivWrite(int fd, const void *buf, size_t len)
|
||||
{
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
static int PrivSerialIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
|
||||
return ioctl(fd, cmd, serial_cfg);
|
||||
}
|
||||
|
||||
static int PrivPinIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct PinParam *pin_cfg = (struct PinParam *)args;
|
||||
|
||||
return ioctl(fd, cmd, pin_cfg);
|
||||
}
|
||||
|
||||
int PrivIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
int ret = 0;
|
||||
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
|
||||
|
||||
switch (ioctl_cfg->ioctl_driver_type)
|
||||
{
|
||||
case SERIAL_TYPE:
|
||||
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case PIN_TYPE:
|
||||
ret = PrivPinIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case I2C_TYPE:
|
||||
ret = ioctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/********************memory api************/
|
||||
void *PrivMalloc(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *PrivRealloc(void *pointer, size_t size)
|
||||
{
|
||||
return realloc(pointer, size);
|
||||
}
|
||||
|
||||
void *PrivCalloc(size_t count, size_t size)
|
||||
{
|
||||
return calloc(count, size);
|
||||
}
|
||||
|
||||
void PrivFree(void *pointer)
|
||||
{
|
||||
free(pointer);
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file transform.h
|
||||
* @brief Interface function declarations required by the framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.06.04
|
||||
*/
|
||||
|
||||
#ifndef TRANSFORM_H
|
||||
#define TRANSFORM_H
|
||||
|
||||
#include <nuttx/pthread.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/time.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
typedef int32_t int32;
|
||||
typedef int64_t int64;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OPE_INT 0x0000
|
||||
#define OPE_CFG 0x0001
|
||||
|
||||
#define NAME_NUM_MAX 32
|
||||
|
||||
/*********************GPIO define*********************/
|
||||
#define GPIO_LOW 0x00
|
||||
#define GPIO_HIGH 0x01
|
||||
|
||||
#define GPIO_CFG_OUTPUT 0x00
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
|
||||
#define GPIO_CONFIG_MODE 0xffffffff
|
||||
|
||||
/********************SERIAL define*******************/
|
||||
#define BAUD_RATE_2400 2400
|
||||
#define BAUD_RATE_4800 4800
|
||||
#define BAUD_RATE_9600 9600
|
||||
#define BAUD_RATE_19200 19200
|
||||
#define BAUD_RATE_38400 38400
|
||||
#define BAUD_RATE_57600 57600
|
||||
#define BAUD_RATE_115200 115200
|
||||
#define BAUD_RATE_230400 230400
|
||||
#define BAUD_RATE_460800 460800
|
||||
#define BAUD_RATE_921600 921600
|
||||
#define BAUD_RATE_2000000 2000000
|
||||
#define BAUD_RATE_3000000 3000000
|
||||
|
||||
#define DATA_BITS_5 5
|
||||
#define DATA_BITS_6 6
|
||||
#define DATA_BITS_7 7
|
||||
#define DATA_BITS_8 8
|
||||
#define DATA_BITS_9 9
|
||||
|
||||
#define STOP_BITS_1 1
|
||||
#define STOP_BITS_2 2
|
||||
#define STOP_BITS_3 3
|
||||
#define STOP_BITS_4 4
|
||||
|
||||
#define PARITY_NONE 1
|
||||
#define PARITY_ODD 2
|
||||
#define PARITY_EVEN 3
|
||||
|
||||
#define BIT_ORDER_LSB 1
|
||||
#define BIT_ORDER_MSB 2
|
||||
|
||||
#define NRZ_NORMAL 1
|
||||
#define NRZ_INVERTED 2
|
||||
|
||||
#ifndef SERIAL_RB_BUFSZ
|
||||
#define SERIAL_RB_BUFSZ 128
|
||||
#endif
|
||||
|
||||
struct PinDevIrq
|
||||
{
|
||||
int irq_mode;//< RISING/FALLING/HIGH/LOW
|
||||
void (*hdr) (void *args);//< callback function
|
||||
void *args;//< the params of callback function
|
||||
};
|
||||
|
||||
struct PinParam
|
||||
{
|
||||
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
|
||||
long pin;//< pin number
|
||||
int mode;//< pin mode: input/output
|
||||
struct PinDevIrq irq_set;//< pin irq set
|
||||
uint64 arg;
|
||||
};
|
||||
|
||||
struct PinStat
|
||||
{
|
||||
long pin;//< pin number
|
||||
uint16_t val;//< pin level
|
||||
};
|
||||
|
||||
enum ExtSerialPortConfigure
|
||||
{
|
||||
PORT_CFG_INIT = 0,
|
||||
PORT_CFG_PARITY_CHECK,
|
||||
PORT_CFG_DISABLE,
|
||||
PORT_CFG_DIV,
|
||||
};
|
||||
|
||||
struct SerialDataCfg
|
||||
{
|
||||
uint32_t serial_baud_rate;
|
||||
uint8_t serial_data_bits;
|
||||
uint8_t serial_stop_bits;
|
||||
uint8_t serial_parity_mode;
|
||||
uint8_t serial_bit_order;
|
||||
uint8_t serial_invert_mode;
|
||||
uint16_t serial_buffer_size;
|
||||
|
||||
uint8 ext_uart_no;
|
||||
enum ExtSerialPortConfigure port_configure;
|
||||
};
|
||||
|
||||
enum IoctlDriverType
|
||||
{
|
||||
SERIAL_TYPE = 0,
|
||||
SPI_TYPE,
|
||||
I2C_TYPE,
|
||||
PIN_TYPE,
|
||||
DEFAULT_TYPE,
|
||||
};
|
||||
|
||||
struct PrivIoctlCfg
|
||||
{
|
||||
enum IoctlDriverType ioctl_driver_type;
|
||||
void *args;
|
||||
};
|
||||
|
||||
int open(FAR const char *path, int oflags, ...);
|
||||
int ioctl(int fd, int req, ...);
|
||||
FAR void *malloc(size_t size);
|
||||
FAR void *realloc(FAR void *oldmem, size_t size);
|
||||
FAR void *calloc(size_t n, size_t elem_size);
|
||||
void free(FAR void *mem);
|
||||
|
||||
/**********************mutex**************************/
|
||||
|
||||
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
|
||||
int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************semaphore**********************/
|
||||
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||
int PrivSemaphoreDelete(sem_t *sem);
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem);
|
||||
int PrivSemaphoreAbandon(sem_t *sem);
|
||||
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
|
||||
|
||||
/*********************task**************************/
|
||||
|
||||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg);
|
||||
int PrivTaskStartup(pthread_t *thread);
|
||||
int PrivTaskDelete(pthread_t thread, int sig);
|
||||
void PrivTaskQuit(void *value_ptr);
|
||||
int PrivTaskDelay(int32_t ms);
|
||||
|
||||
/*********************driver*************************/
|
||||
|
||||
int PrivOpen(const char *path, int flags);
|
||||
int PrivRead(int fd, void *buf, size_t len);
|
||||
int PrivWrite(int fd, const void *buf, size_t len);
|
||||
int PrivClose(int fd);
|
||||
int PrivIoctl(int fd, int cmd, void *args);
|
||||
|
||||
/*********************memory***********************/
|
||||
|
||||
void *PrivMalloc(size_t size);
|
||||
void *PrivRealloc(void *pointer, size_t size);
|
||||
void *PrivCalloc(size_t count, size_t size);
|
||||
void PrivFree(void *pointer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue