Merge branch 'bugfix/change_alloc_interface' into 'master'

[ba76b65] update esp-face & adjust new alloc interface

See merge request face-recognition-framework/esp-who!52
pull/131/head
XiaochaoGONG 2019-10-22 19:09:35 +08:00
commit 65d4587d76
9 changed files with 122 additions and 105 deletions

@ -1 +1 @@
Subproject commit 519ea068567fd59a0dcbd6a5a1cc641cdc9c1a1f
Subproject commit ba76b6546f56933e571b98bc8431fb291db11668

View File

@ -183,11 +183,11 @@ ESP-EYE 开发板的工作流程如下图所示:
- 人像采集完成后,开发板红灯常灭,表明已完成录入该 Face ID。此时网页显示**ENROLLED FACE ID xxx**
- Face ID 录入成功后,系统将返回“人脸检测”。
目前ESP-EYE 开发板默认可录入 10 个 Face ID可配置具体与用户的 flash 内存分配有关,但建议不要超过 30 个 Face ID)。
目前ESP-EYE 开发板默认可录入 10 个 Face ID可配置具体与用户的 flash 内存分配有关)。
##### 5.2 删除 Face ID
- 用户双击侧面轻触按键,进入“删除 FACE ID”
- 用户单击表面BOOT按键,进入“删除 FACE ID”
- 双击后,开发板白灯闪烁,系统将自动删除系统中存在的最早一条 FACE ID终端显示**XXX ID(S) LEFT**。
#### 异常情况

View File

@ -310,10 +310,10 @@ static esp_err_t capture_handler(httpd_req_t *req){
}
#endif
draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->score);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
}
jpg_chunking_t jchunk = {req, 0};
@ -419,10 +419,10 @@ static esp_err_t stream_handler(httpd_req_t *req){
fr_recognize = esp_timer_get_time();
#endif
draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->score);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
}
if(!fmt2jpg(image_matrix->item, fb->width*fb->height*3, fb->width, fb->height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len)){
ESP_LOGE(TAG, "fmt2jpg failed");

View File

@ -94,10 +94,10 @@ void task_process (void *arg)
{
frame_num++;
ESP_LOGI(TAG, "DETECTED: %d\n", frame_num);
free(net_boxes->score);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
}
dl_matrix3du_free(image_matrix);

View File

@ -67,11 +67,11 @@ The users can add/delete a Face ID after the network is successfully established
- After the Face ID enrollment, the red LED on the board is off and the browser displays **ENROLLED FACE ID XXX**;
- The board enters Face Detection after the Face ID enrollment.
Currently, ESP-EYE can enroll up to 10 Face IDs. Please note that the maximum number of enrolled Face IDs can be configured according to how users allocate the flash memory. However, we recommend a number that is no greater than 30.
Currently, ESP-EYE can enroll up to 10 Face IDs. Please note that the maximum number of enrolled Face IDs can be configured according to how users allocate the flash memory.
##### 5.2 Delete a Face ID
- Double-click the Side Tactile Button to delete an existing Face ID.
- Single-click the Top Tactile Button "BOOT" to delete an existing Face ID.
- After that, the board deletes the earliest record of all the existing enrolled Face IDs. The white LED on the board flashes, and the browser displays: **XXX ID(S) LEFT**.
#### Troubleshooting

View File

@ -49,7 +49,7 @@ face_id_list st_face_list = {0};
dl_matrix3du_t *aligned_face = NULL;
static void oneshot_timer_callback(void* arg);
//static void oneshot_timer_callback(void* arg);
const char *number_suffix(int32_t number)
{
@ -196,7 +196,8 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
// exec event
if (g_state == START_DELETE)
{
uint8_t left = delete_face_id_in_flash(&st_face_list);
int8_t left = delete_face_id_in_flash(&st_face_list);
if (left >= 0)
ESP_LOGW(TAG, "%d ID Left", left);
g_state = START_DETECT;
continue;
@ -227,10 +228,14 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
if(!fmt2rgb888(fb->buf, fb->len, fb->format, image_matrix->item))
{
ESP_LOGW(TAG, "fmt2rgb888 failed");
_jpg_buf = fb->buf;
_jpg_buf_len = fb->len;
//res = ESP_FAIL;
//dl_matrix3du_free(image_matrix);
//break;
}
else
{
fr_ready = esp_timer_get_time();
box_array_t *net_boxes = face_detect(image_matrix, &mtmn_config);
@ -260,8 +265,8 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
if (left_sample_face == 0)
{
ESP_LOGI(TAG, "Enrolled Face ID: %d", st_face_list.tail);
rgb_printf(image_matrix, FACE_COLOR_CYAN, "\n\nEnrolled Face ID: %d", st_face_list.tail);
ESP_LOGI(TAG, "Enrolled Face ID: %d", st_face_list.tail ? st_face_list.tail - 1 : FACE_ID_SAVE_NUMBER - 1);
rgb_printf(image_matrix, FACE_COLOR_CYAN, "\n\nEnrolled Face ID: %d", st_face_list.tail - 1);
g_is_enrolling = 0;
g_state = START_RECOGNITION;
}
@ -283,10 +288,10 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
}
draw_face_boxes(image_matrix, net_boxes);
free(net_boxes->score);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
fr_recognize = esp_timer_get_time();
if(!fmt2jpg(image_matrix->item, fb->width*fb->height*3, fb->width, fb->height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len))
@ -301,6 +306,7 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
_jpg_buf = fb->buf;
_jpg_buf_len = fb->len;
}
}
dl_matrix3du_free(image_matrix);
fr_encode = esp_timer_get_time();
@ -357,30 +363,39 @@ httpd_uri_t _face_stream_handler = {
httpd_handle_t camera_httpd = NULL;
const esp_timer_create_args_t oneshot_timer_args = {
.callback = &oneshot_timer_callback,
/* argument specified here will be passed to timer callback function */
.name = "one-shot"
};
esp_timer_handle_t oneshot_timer;
//const esp_timer_create_args_t oneshot_timer_args = {
// .callback = &oneshot_timer_callback,
// /* argument specified here will be passed to timer callback function */
// .name = "one-shot"
//};
//esp_timer_handle_t oneshot_timer;
//
//static void oneshot_timer_callback(void* arg)
//{
// //if(g_state != START_ENROLL)
// // g_is_enrolling = 1;
//}
static void oneshot_timer_callback(void* arg)
static void IRAM_ATTR gpio_isr_handler_enroll(void* arg)
{
if(g_state != START_ENROLL)
g_is_enrolling = 1;
//esp_timer_start_once(oneshot_timer, 500000);
//if(err == ESP_ERR_INVALID_STATE)
//{
// ESP_ERROR_CHECK(esp_timer_stop(oneshot_timer));
// g_is_enrolling = 0;
// g_is_deleting = 1;
// gpio_set_level(GPIO_LED_WHITE, 0);
//}
}
static void IRAM_ATTR gpio_isr_handler(void* arg)
static void IRAM_ATTR gpio_isr_handler_delete(void* arg)
{
esp_err_t err = esp_timer_start_once(oneshot_timer, 500000);
if(err == ESP_ERR_INVALID_STATE)
{
ESP_ERROR_CHECK(esp_timer_stop(oneshot_timer));
g_is_enrolling = 0;
g_is_deleting = 1;
gpio_set_level(GPIO_LED_WHITE, 0);
}
}
void app_httpserver_init ()
@ -388,15 +403,16 @@ void app_httpserver_init ()
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.stack_size = 4096 * 2;
ESP_ERROR_CHECK(esp_timer_create(&oneshot_timer_args, &oneshot_timer));
//ESP_ERROR_CHECK(esp_timer_create(&oneshot_timer_args, &oneshot_timer));
gpio_config_t io_conf = {0};
io_conf.mode = GPIO_MODE_INPUT;
io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
io_conf.pin_bit_mask = 1LL << GPIO_BUTTON;
io_conf.pin_bit_mask = 1LL << GPIO_BUTTON | 1LL << GPIO_BOOT;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&io_conf);
gpio_isr_handler_add(GPIO_BUTTON, gpio_isr_handler, NULL);
gpio_isr_handler_add(GPIO_BUTTON, gpio_isr_handler_enroll, NULL);
gpio_isr_handler_add(GPIO_BOOT, gpio_isr_handler_delete, NULL);
face_id_init(&st_face_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES);
aligned_face = dl_matrix3du_alloc(1, FACE_WIDTH, FACE_HEIGHT, 3);

View File

@ -8,6 +8,7 @@
#define GPIO_LED_RED 21
#define GPIO_LED_WHITE 22
#define GPIO_BUTTON 15
#define GPIO_BOOT 0
typedef enum
{

View File

@ -245,10 +245,10 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
if (out_res.net_boxes)
{
draw_face_boxes(out_res.image, fb->width, fb->height, out_res.net_boxes);
free(out_res.net_boxes->score);
free(out_res.net_boxes->box);
free(out_res.net_boxes->landmark);
free(out_res.net_boxes);
dl_lib_free(out_res.net_boxes->score);
dl_lib_free(out_res.net_boxes->box);
dl_lib_free(out_res.net_boxes->landmark);
dl_lib_free(out_res.net_boxes);
if (out_res.face_id)
{

View File

@ -187,10 +187,10 @@ void task_process(void *arg)
ESP_LOGI(TAG, "Detected face is not proper.");
}
free(net_boxes->score);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
}
dl_matrix3du_free(image_matrix);