Merge branch 'feature/improve_mtmn' into 'master'

improve mtmn

See merge request face-recognition-framework/esp-who!48
pull/78/head
XiaochaoGONG 2019-05-10 19:35:01 +08:00
commit f847d8986b
8 changed files with 50 additions and 18 deletions

@ -1 +1 @@
Subproject commit 08ba977a6ccf5ab7868bd30af60b3f1702a1a9d2 Subproject commit 9f64994450feeebc92350d9a66ab5b29d9fce2f4

View File

@ -310,6 +310,7 @@ static esp_err_t capture_handler(httpd_req_t *req){
} }
#endif #endif
draw_face_boxes(image_matrix, net_boxes, face_id); draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->score);
free(net_boxes->box); free(net_boxes->box);
free(net_boxes->landmark); free(net_boxes->landmark);
free(net_boxes); free(net_boxes);
@ -416,6 +417,7 @@ static esp_err_t stream_handler(httpd_req_t *req){
fr_recognize = esp_timer_get_time(); fr_recognize = esp_timer_get_time();
#endif #endif
draw_face_boxes(image_matrix, net_boxes, face_id); draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->score);
free(net_boxes->box); free(net_boxes->box);
free(net_boxes->landmark); free(net_boxes->landmark);
free(net_boxes); free(net_boxes);
@ -691,16 +693,18 @@ void app_httpd_main(){
ra_filter_init(&ra_filter, 20); ra_filter_init(&ra_filter, 20);
#if CONFIG_ESP_FACE_DETECT_ENABLED #if CONFIG_ESP_FACE_DETECT_ENABLED
mtmn_config.type = FAST;
mtmn_config.min_face = 80; mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7; mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6; mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7; mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 100; mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7; mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7; mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4; mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7; mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.4; mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1; mtmn_config.o_threshold.candidate_number = 1;
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED #if CONFIG_ESP_FACE_RECOGNITION_ENABLED
face_id_init(&id_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES); face_id_init(&id_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES);

View File

@ -33,16 +33,18 @@ static const char *TAG = "app_process";
mtmn_config_t init_config() mtmn_config_t init_config()
{ {
mtmn_config_t mtmn_config = {0}; mtmn_config_t mtmn_config = {0};
mtmn_config.type = FAST;
mtmn_config.min_face = 80; mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7; mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6; mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7; mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 100; mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7; mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7; mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4; mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7; mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.4; mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1; mtmn_config.o_threshold.candidate_number = 1;
return mtmn_config; return mtmn_config;
@ -85,6 +87,7 @@ void task_process (void *arg)
{ {
frame_num++; frame_num++;
ESP_LOGI(TAG, "DETECTED: %d\n", frame_num); ESP_LOGI(TAG, "DETECTED: %d\n", frame_num);
free(net_boxes->score);
free(net_boxes->box); free(net_boxes->box);
free(net_boxes->landmark); free(net_boxes->landmark);
free(net_boxes); free(net_boxes);

View File

@ -70,4 +70,13 @@ void app_camera_init()
ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); ESP_LOGE(TAG, "Camera init failed with error 0x%x", err);
return; return;
} }
sensor_t *s = esp_camera_sensor_get();
//initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID == OV3660_PID)
{
s->set_vflip(s, 1); //flip it back
s->set_brightness(s, 1); //up the blightness just a bit
s->set_saturation(s, -2); //lower the saturation
}
} }

View File

@ -283,6 +283,7 @@ esp_err_t facenet_stream_handler(httpd_req_t *req)
} }
draw_face_boxes(image_matrix, net_boxes); draw_face_boxes(image_matrix, net_boxes);
free(net_boxes->score);
free(net_boxes->box); free(net_boxes->box);
free(net_boxes->landmark); free(net_boxes->landmark);
free(net_boxes); free(net_boxes);

View File

@ -70,4 +70,13 @@ void app_camera_init()
ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); ESP_LOGE(TAG, "Camera init failed with error 0x%x", err);
return; return;
} }
sensor_t *s = esp_camera_sensor_get();
//initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID == OV3660_PID)
{
s->set_vflip(s, 1); //flip it back
s->set_brightness(s, 1); //up the blightness just a bit
s->set_saturation(s, -2); //lower the saturation
}
} }

View File

@ -37,16 +37,18 @@ extern QueueHandle_t gpst_output;
static inline mtmn_config_t app_mtmn_config() static inline mtmn_config_t app_mtmn_config()
{ {
mtmn_config_t mtmn_config; mtmn_config_t mtmn_config;
mtmn_config.type = FAST;
mtmn_config.min_face = 80; mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7; mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6; mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7; mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 100; mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.6; mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7; mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4; mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.6; mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.4; mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1; mtmn_config.o_threshold.candidate_number = 1;
return mtmn_config; return mtmn_config;

View File

@ -52,15 +52,18 @@ char *number_suffix(int32_t number)
mtmn_config_t init_config() mtmn_config_t init_config()
{ {
mtmn_config_t mtmn_config = {0}; mtmn_config_t mtmn_config = {0};
mtmn_config.type = FAST;
mtmn_config.min_face = 80; mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7; mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6; mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7; mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7; mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7; mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4; mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7; mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.4; mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1; mtmn_config.o_threshold.candidate_number = 1;
return mtmn_config; return mtmn_config;
@ -174,6 +177,7 @@ void task_process(void *arg)
ESP_LOGI(TAG, "Detected face is not proper."); ESP_LOGI(TAG, "Detected face is not proper.");
} }
free(net_boxes->score);
free(net_boxes->box); free(net_boxes->box);
free(net_boxes->landmark); free(net_boxes->landmark);
free(net_boxes); free(net_boxes);