add face_recognition examples

pull/190/head
yuanjiong 2021-10-20 20:16:02 +08:00
parent ecd5785d02
commit 0266875718
18 changed files with 350 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS ../../../components)
add_compile_options(-fdiagnostics-color=always)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(human_face_recognition_lcd)

View File

@ -0,0 +1,5 @@
set(src_dirs .)
set(include_dirs .)
idf_component_register(SRC_DIRS ${src_dirs} INCLUDE_DIRS ${include_dirs})

View File

@ -0,0 +1,30 @@
#include "who_camera.h"
#include "who_human_face_recognition.hpp"
#include "who_lcd.h"
#include "who_button.h"
#include "event_logic.hpp"
#include "who_adc_button.h"
static QueueHandle_t xQueueAIFrame = NULL;
static QueueHandle_t xQueueLCDFrame = NULL;
static QueueHandle_t xQueueKeyState = NULL;
static QueueHandle_t xQueueEventLogic = NULL;
static button_adc_config_t buttons[4] = {{1, 2800, 3000}, {2, 2250, 2450}, {3, 300, 500}, {4, 850, 1050}};
#define GPIO_BOOT GPIO_NUM_0
extern "C" void app_main()
{
xQueueAIFrame = xQueueCreate(2, sizeof(camera_fb_t *));
xQueueLCDFrame = xQueueCreate(2, sizeof(camera_fb_t *));
xQueueKeyState = xQueueCreate(1, sizeof(int *));
xQueueEventLogic = xQueueCreate(1, sizeof(int *));
register_camera(PIXFORMAT_RGB565, FRAMESIZE_240X240, 2, xQueueAIFrame);
register_button(GPIO_BOOT, xQueueKeyState);
// register_adc_button(buttons, 4, xQueueKeyState);
register_event(xQueueKeyState, xQueueEventLogic);
register_human_face_recognition(xQueueAIFrame, xQueueEventLogic, NULL, xQueueLCDFrame, false);
register_lcd(xQueueLCDFrame, NULL, true);
}

View File

@ -0,0 +1,84 @@
#include <stdio.h>
#include "event_logic.hpp"
#include "who_button.h"
#include "who_human_face_recognition.hpp"
typedef enum
{
MENU = 1,
PLAY,
UP,
DOWN
}key_name_t;
static QueueHandle_t xQueueKeyStateI = NULL;
static QueueHandle_t xQueueEventO = NULL;
static key_state_t key_state;
static key_name_t adc_button_name;
static recognizer_state_t recognizer_state;
void event_generate(void *arg)
{
while (1)
{
xQueueReceive(xQueueKeyStateI, &key_state, portMAX_DELAY);
switch (key_state)
{
case KEY_SHORT_PRESS:
recognizer_state = RECOGNIZE;
break;
case KEY_LONG_PRESS:
recognizer_state = ENROLL;
break;
case KEY_DOUBLE_CLICK:
recognizer_state = DELETE;
break;
default:
recognizer_state = DETECT;
break;
}
xQueueSend(xQueueEventO, &recognizer_state, portMAX_DELAY);
}
}
void event_generate_from_adc_button(void *arg)
{
while (1)
{
xQueueReceive(xQueueKeyStateI, &adc_button_name, portMAX_DELAY);
switch (adc_button_name)
{
case MENU:
recognizer_state = ENROLL;
break;
case PLAY:
recognizer_state = DELETE;
break;
case UP:
recognizer_state = RECOGNIZE;
break;
case DOWN:
recognizer_state = RECOGNIZE;
break;
default:
recognizer_state = DETECT;
break;
}
xQueueSend(xQueueEventO, &recognizer_state, portMAX_DELAY);
}
}
void register_event(const QueueHandle_t key_state_i, const QueueHandle_t event_o)
{
xQueueKeyStateI = key_state_i;
xQueueEventO = event_o;
xTaskCreatePinnedToCore(event_generate, "event_logic_task", 1024, NULL, 5, NULL, 0);
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
/**
* @brief
*
* @param key_state_i
* @param event_o
*/
void register_event(const QueueHandle_t key_state_i, const QueueHandle_t event_o);

View File

@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
factory, app, factory, 0x010000, 3840K
nvs, data, nvs, 0x3D0000, 16K
fr, 32, 32, 0x3E0000, 128K
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 factory, app, factory, 0x010000, 3840K
4 nvs, data, nvs, 0x3D0000, 16K
5 fr, 32, 32, 0x3E0000, 128K

View File

@ -0,0 +1,12 @@
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_S16=y

View File

@ -0,0 +1,15 @@
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_8WAYS=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_CAMERA_MODULE_ESP_S3_EYE=y
CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789=y
CONFIG_ESPTOOLPY_NO_STUB=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_S8=y

View File

@ -0,0 +1,8 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS ../../../components)
add_compile_options(-fdiagnostics-color=always)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(human_face_recognition_terminal)

View File

@ -0,0 +1,5 @@
set(src_dirs .)
set(include_dirs .)
idf_component_register(SRC_DIRS ${src_dirs} INCLUDE_DIRS ${include_dirs})

View File

@ -0,0 +1,25 @@
#include "who_camera.h"
#include "who_human_face_recognition.hpp"
#include "who_button.h"
#include "event_logic.hpp"
#include "who_adc_button.h"
static QueueHandle_t xQueueAIFrame = NULL;
static QueueHandle_t xQueueKeyState = NULL;
static QueueHandle_t xQueueEventLogic = NULL;
static button_adc_config_t buttons[4] = {{1, 2800, 3000}, {2, 2250, 2450}, {3, 300, 500}, {4, 850, 1050}};
#define GPIO_BOOT GPIO_NUM_0
extern "C" void app_main()
{
xQueueAIFrame = xQueueCreate(2, sizeof(camera_fb_t *));
xQueueKeyState = xQueueCreate(1, sizeof(int *));
xQueueEventLogic = xQueueCreate(1, sizeof(int *));
register_camera(PIXFORMAT_RGB565, FRAMESIZE_240X240, 2, xQueueAIFrame);
register_button(GPIO_BOOT, xQueueKeyState);
register_event(xQueueKeyState, xQueueEventLogic);
register_human_face_recognition(xQueueAIFrame, xQueueEventLogic, NULL, NULL, true);
}

View File

@ -0,0 +1,84 @@
#include <stdio.h>
#include "event_logic.hpp"
#include "who_button.h"
#include "who_human_face_recognition.hpp"
typedef enum
{
MENU = 1,
PLAY,
UP,
DOWN
}key_name_t;
static QueueHandle_t xQueueKeyStateI = NULL;
static QueueHandle_t xQueueEventO = NULL;
static key_state_t key_state;
static key_name_t adc_button_name;
static recognizer_state_t recognizer_state;
void event_generate(void *arg)
{
while (1)
{
xQueueReceive(xQueueKeyStateI, &key_state, portMAX_DELAY);
switch (key_state)
{
case KEY_SHORT_PRESS:
recognizer_state = RECOGNIZE;
break;
case KEY_LONG_PRESS:
recognizer_state = ENROLL;
break;
case KEY_DOUBLE_CLICK:
recognizer_state = DELETE;
break;
default:
recognizer_state = DETECT;
break;
}
xQueueSend(xQueueEventO, &recognizer_state, portMAX_DELAY);
}
}
void event_generate_from_adc_button(void *arg)
{
while (1)
{
xQueueReceive(xQueueKeyStateI, &adc_button_name, portMAX_DELAY);
switch (adc_button_name)
{
case MENU:
recognizer_state = ENROLL;
break;
case PLAY:
recognizer_state = DELETE;
break;
case UP:
recognizer_state = RECOGNIZE;
break;
case DOWN:
recognizer_state = RECOGNIZE;
break;
default:
recognizer_state = DETECT;
break;
}
xQueueSend(xQueueEventO, &recognizer_state, portMAX_DELAY);
}
}
void register_event(const QueueHandle_t key_state_i, const QueueHandle_t event_o)
{
xQueueKeyStateI = key_state_i;
xQueueEventO = event_o;
xTaskCreatePinnedToCore(event_generate, "event_logic_task", 1024, NULL, 5, NULL, 0);
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
/**
* @brief
*
* @param key_state_i
* @param event_o
*/
void register_event(const QueueHandle_t key_state_i, const QueueHandle_t event_o);

View File

@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
factory, app, factory, 0x010000, 3840K
nvs, data, nvs, 0x3D0000, 16K
fr, 32, 32, 0x3E0000, 128K
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 factory, app, factory, 0x010000, 3840K
4 nvs, data, nvs, 0x3D0000, 16K
5 fr, 32, 32, 0x3E0000, 128K

View File

@ -0,0 +1,12 @@
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_S16=y

View File

@ -0,0 +1,4 @@
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_CAMERA_MODULE_ESP_EYE=y

View File

@ -0,0 +1,7 @@
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
CONFIG_ESP32S2_DATA_CACHE_16KB=y
ESP32S2_DATA_CACHE_LINE_32B=y
CONFIG_CAMERA_MODULE_ESP_S2_KALUGA=y

View File

@ -0,0 +1,15 @@
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_8WAYS=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_CAMERA_MODULE_ESP_S3_EYE=y
CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789=y
CONFIG_ESPTOOLPY_NO_STUB=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_S8=y