Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit af40992

Browse files
authoredOct 10, 2024··
IDF release/v5.3 (#10444)
* IDF release/v5.3 707d097b * fix(camera): Remove support for face detection and recognition
1 parent ba9a3a1 commit af40992

File tree

2 files changed

+37
-515
lines changed

2 files changed

+37
-515
lines changed
 

‎libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp

Lines changed: 21 additions & 499 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,6 @@
2424
#include "esp32-hal-log.h"
2525
#endif
2626

27-
// Face Detection will not work on boards without (or with disabled) PSRAM
28-
#ifdef BOARD_HAS_PSRAM
29-
// Face Recognition takes upward from 15 seconds per frame on chips other than ESP32S3
30-
// Makes no sense to have it enabled for them
31-
#if CONFIG_IDF_TARGET_ESP32S3
32-
#define CONFIG_ESP_FACE_RECOGNITION_ENABLED 1
33-
#define CONFIG_ESP_FACE_DETECT_ENABLED 1
34-
#else
35-
#define CONFIG_ESP_FACE_RECOGNITION_ENABLED 0
36-
#define CONFIG_ESP_FACE_DETECT_ENABLED 0
37-
#endif
38-
#else
39-
#define CONFIG_ESP_FACE_DETECT_ENABLED 0
40-
#define CONFIG_ESP_FACE_RECOGNITION_ENABLED 0
41-
#endif
42-
43-
#if CONFIG_ESP_FACE_DETECT_ENABLED
44-
45-
#include <vector>
46-
#include "human_face_detect_msr01.hpp"
47-
#include "human_face_detect_mnp01.hpp"
48-
49-
#define TWO_STAGE 1 /*<! 1: detect by two-stage which is more accurate but slower(with keypoints). */
50-
/*<! 0: detect by one-stage which is less accurate but faster(without keypoints). */
51-
52-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
53-
#pragma GCC diagnostic ignored "-Wformat"
54-
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
55-
#include "face_recognition_tool.hpp"
56-
#include "face_recognition_112_v1_s16.hpp"
57-
#include "face_recognition_112_v1_s8.hpp"
58-
#pragma GCC diagnostic error "-Wformat"
59-
#pragma GCC diagnostic warning "-Wstrict-aliasing"
60-
61-
#define QUANT_TYPE 0 //if set to 1 => very large firmware, very slow, reboots when streaming...
62-
63-
#define FACE_ID_SAVE_NUMBER 7
64-
#endif
65-
66-
#define FACE_COLOR_WHITE 0x00FFFFFF
67-
#define FACE_COLOR_BLACK 0x00000000
68-
#define FACE_COLOR_RED 0x000000FF
69-
#define FACE_COLOR_GREEN 0x0000FF00
70-
#define FACE_COLOR_BLUE 0x00FF0000
71-
#define FACE_COLOR_YELLOW (FACE_COLOR_RED | FACE_COLOR_GREEN)
72-
#define FACE_COLOR_CYAN (FACE_COLOR_BLUE | FACE_COLOR_GREEN)
73-
#define FACE_COLOR_PURPLE (FACE_COLOR_BLUE | FACE_COLOR_RED)
74-
#endif
75-
7627
// Enable LED FLASH setting
7728
#define CONFIG_LED_ILLUMINATOR_ENABLED 1
7829

@@ -100,32 +51,6 @@ static const char *_STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %
10051
httpd_handle_t stream_httpd = NULL;
10152
httpd_handle_t camera_httpd = NULL;
10253

103-
#if CONFIG_ESP_FACE_DETECT_ENABLED
104-
105-
static int8_t detection_enabled = 0;
106-
107-
// #if TWO_STAGE
108-
// static HumanFaceDetectMSR01 s1(0.1F, 0.5F, 10, 0.2F);
109-
// static HumanFaceDetectMNP01 s2(0.5F, 0.3F, 5);
110-
// #else
111-
// static HumanFaceDetectMSR01 s1(0.3F, 0.5F, 10, 0.2F);
112-
// #endif
113-
114-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
115-
static int8_t recognition_enabled = 0;
116-
static int8_t is_enrolling = 0;
117-
118-
#if QUANT_TYPE
119-
// S16 model
120-
FaceRecognition112V1S16 recognizer;
121-
#else
122-
// S8 model
123-
FaceRecognition112V1S8 recognizer;
124-
#endif
125-
#endif
126-
127-
#endif
128-
12954
typedef struct {
13055
size_t size; //number of values used for filtering
13156
size_t index; //current value index
@@ -166,105 +91,6 @@ static int ra_filter_run(ra_filter_t *filter, int value) {
16691
}
16792
#endif
16893

169-
#if CONFIG_ESP_FACE_DETECT_ENABLED
170-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
171-
static void rgb_print(fb_data_t *fb, uint32_t color, const char *str) {
172-
fb_gfx_print(fb, (fb->width - (strlen(str) * 14)) / 2, 10, color, str);
173-
}
174-
175-
static int rgb_printf(fb_data_t *fb, uint32_t color, const char *format, ...) {
176-
char loc_buf[64];
177-
char *temp = loc_buf;
178-
int len;
179-
va_list arg;
180-
va_list copy;
181-
va_start(arg, format);
182-
va_copy(copy, arg);
183-
len = vsnprintf(loc_buf, sizeof(loc_buf), format, arg);
184-
va_end(copy);
185-
if (len >= sizeof(loc_buf)) {
186-
temp = (char *)malloc(len + 1);
187-
if (temp == NULL) {
188-
return 0;
189-
}
190-
}
191-
vsnprintf(temp, len + 1, format, arg);
192-
va_end(arg);
193-
rgb_print(fb, color, temp);
194-
if (len > 64) {
195-
free(temp);
196-
}
197-
return len;
198-
}
199-
#endif
200-
static void draw_face_boxes(fb_data_t *fb, std::list<dl::detect::result_t> *results, int face_id) {
201-
int x, y, w, h;
202-
uint32_t color = FACE_COLOR_YELLOW;
203-
if (face_id < 0) {
204-
color = FACE_COLOR_RED;
205-
} else if (face_id > 0) {
206-
color = FACE_COLOR_GREEN;
207-
}
208-
if (fb->bytes_per_pixel == 2) {
209-
//color = ((color >> 8) & 0xF800) | ((color >> 3) & 0x07E0) | (color & 0x001F);
210-
color = ((color >> 16) & 0x001F) | ((color >> 3) & 0x07E0) | ((color << 8) & 0xF800);
211-
}
212-
int i = 0;
213-
for (std::list<dl::detect::result_t>::iterator prediction = results->begin(); prediction != results->end(); prediction++, i++) {
214-
// rectangle box
215-
x = (int)prediction->box[0];
216-
y = (int)prediction->box[1];
217-
w = (int)prediction->box[2] - x + 1;
218-
h = (int)prediction->box[3] - y + 1;
219-
if ((x + w) > fb->width) {
220-
w = fb->width - x;
221-
}
222-
if ((y + h) > fb->height) {
223-
h = fb->height - y;
224-
}
225-
fb_gfx_drawFastHLine(fb, x, y, w, color);
226-
fb_gfx_drawFastHLine(fb, x, y + h - 1, w, color);
227-
fb_gfx_drawFastVLine(fb, x, y, h, color);
228-
fb_gfx_drawFastVLine(fb, x + w - 1, y, h, color);
229-
#if TWO_STAGE
230-
// landmarks (left eye, mouth left, nose, right eye, mouth right)
231-
int x0, y0, j;
232-
for (j = 0; j < 10; j += 2) {
233-
x0 = (int)prediction->keypoint[j];
234-
y0 = (int)prediction->keypoint[j + 1];
235-
fb_gfx_fillRect(fb, x0, y0, 3, 3, color);
236-
}
237-
#endif
238-
}
239-
}
240-
241-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
242-
static int run_face_recognition(fb_data_t *fb, std::list<dl::detect::result_t> *results) {
243-
std::vector<int> landmarks = results->front().keypoint;
244-
int id = -1;
245-
246-
Tensor<uint8_t> tensor;
247-
tensor.set_element((uint8_t *)fb->data).set_shape({fb->height, fb->width, 3}).set_auto_free(false);
248-
249-
int enrolled_count = recognizer.get_enrolled_id_num();
250-
251-
if (enrolled_count < FACE_ID_SAVE_NUMBER && is_enrolling) {
252-
id = recognizer.enroll_id(tensor, landmarks, "", true);
253-
log_i("Enrolled ID: %d", id);
254-
rgb_printf(fb, FACE_COLOR_CYAN, "ID[%u]", id);
255-
}
256-
257-
face_info_t recognize = recognizer.recognize(tensor, landmarks);
258-
if (recognize.id >= 0) {
259-
rgb_printf(fb, FACE_COLOR_GREEN, "ID[%u]: %.2f", recognize.id, recognize.similarity);
260-
} else {
261-
rgb_print(fb, FACE_COLOR_RED, "Intruder Alert!");
262-
}
263-
return recognize.id;
264-
}
265-
#endif
266-
#endif
267-
26894
#if CONFIG_LED_ILLUMINATOR_ENABLED
26995
void enable_led(bool en) { // Turn LED On or Off
27096
int duty = en ? led_duty : 0;
@@ -359,134 +185,28 @@ static esp_err_t capture_handler(httpd_req_t *req) {
359185
snprintf(ts, 32, "%lld.%06ld", fb->timestamp.tv_sec, fb->timestamp.tv_usec);
360186
httpd_resp_set_hdr(req, "X-Timestamp", (const char *)ts);
361187

362-
#if CONFIG_ESP_FACE_DETECT_ENABLED
363-
size_t out_len, out_width, out_height;
364-
uint8_t *out_buf;
365-
bool s;
366-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
367-
bool detected = false;
368-
#endif
369-
int face_id = 0;
370-
if (!detection_enabled || fb->width > 400) {
371-
#endif
372188
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
373-
size_t fb_len = 0;
189+
size_t fb_len = 0;
374190
#endif
375-
if (fb->format == PIXFORMAT_JPEG) {
191+
if (fb->format == PIXFORMAT_JPEG) {
376192
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
377-
fb_len = fb->len;
193+
fb_len = fb->len;
378194
#endif
379-
res = httpd_resp_send(req, (const char *)fb->buf, fb->len);
380-
} else {
381-
jpg_chunking_t jchunk = {req, 0};
382-
res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk) ? ESP_OK : ESP_FAIL;
383-
httpd_resp_send_chunk(req, NULL, 0);
384-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
385-
fb_len = jchunk.len;
386-
#endif
387-
}
388-
esp_camera_fb_return(fb);
389-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
390-
int64_t fr_end = esp_timer_get_time();
391-
#endif
392-
log_i("JPG: %uB %ums", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start) / 1000));
393-
return res;
394-
#if CONFIG_ESP_FACE_DETECT_ENABLED
395-
}
396-
397-
jpg_chunking_t jchunk = {req, 0};
398-
399-
if (fb->format == PIXFORMAT_RGB565
400-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
401-
&& !recognition_enabled
402-
#endif
403-
) {
404-
#if TWO_STAGE
405-
HumanFaceDetectMSR01 s1(0.1F, 0.5F, 10, 0.2F);
406-
HumanFaceDetectMNP01 s2(0.5F, 0.3F, 5);
407-
std::list<dl::detect::result_t> &candidates = s1.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3});
408-
std::list<dl::detect::result_t> &results = s2.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3}, candidates);
409-
#else
410-
HumanFaceDetectMSR01 s1(0.3F, 0.5F, 10, 0.2F);
411-
std::list<dl::detect::result_t> &results = s1.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3});
412-
#endif
413-
if (results.size() > 0) {
414-
fb_data_t rfb;
415-
rfb.width = fb->width;
416-
rfb.height = fb->height;
417-
rfb.data = fb->buf;
418-
rfb.bytes_per_pixel = 2;
419-
rfb.format = FB_RGB565;
420-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
421-
detected = true;
422-
#endif
423-
draw_face_boxes(&rfb, &results, face_id);
424-
}
425-
s = fmt2jpg_cb(fb->buf, fb->len, fb->width, fb->height, PIXFORMAT_RGB565, 90, jpg_encode_stream, &jchunk);
426-
esp_camera_fb_return(fb);
195+
res = httpd_resp_send(req, (const char *)fb->buf, fb->len);
427196
} else {
428-
out_len = fb->width * fb->height * 3;
429-
out_width = fb->width;
430-
out_height = fb->height;
431-
out_buf = (uint8_t *)malloc(out_len);
432-
if (!out_buf) {
433-
log_e("out_buf malloc failed");
434-
httpd_resp_send_500(req);
435-
return ESP_FAIL;
436-
}
437-
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
438-
esp_camera_fb_return(fb);
439-
if (!s) {
440-
free(out_buf);
441-
log_e("To rgb888 failed");
442-
httpd_resp_send_500(req);
443-
return ESP_FAIL;
444-
}
445-
446-
fb_data_t rfb;
447-
rfb.width = out_width;
448-
rfb.height = out_height;
449-
rfb.data = out_buf;
450-
rfb.bytes_per_pixel = 3;
451-
rfb.format = FB_BGR888;
452-
453-
#if TWO_STAGE
454-
HumanFaceDetectMSR01 s1(0.1F, 0.5F, 10, 0.2F);
455-
HumanFaceDetectMNP01 s2(0.5F, 0.3F, 5);
456-
std::list<dl::detect::result_t> &candidates = s1.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3});
457-
std::list<dl::detect::result_t> &results = s2.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3}, candidates);
458-
#else
459-
HumanFaceDetectMSR01 s1(0.3F, 0.5F, 10, 0.2F);
460-
std::list<dl::detect::result_t> &results = s1.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3});
461-
#endif
462-
463-
if (results.size() > 0) {
197+
jpg_chunking_t jchunk = {req, 0};
198+
res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk) ? ESP_OK : ESP_FAIL;
199+
httpd_resp_send_chunk(req, NULL, 0);
464200
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
465-
detected = true;
201+
fb_len = jchunk.len;
466202
#endif
467-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
468-
if (recognition_enabled) {
469-
face_id = run_face_recognition(&rfb, &results);
470-
}
471-
#endif
472-
draw_face_boxes(&rfb, &results, face_id);
473-
}
474-
475-
s = fmt2jpg_cb(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, jpg_encode_stream, &jchunk);
476-
free(out_buf);
477-
}
478-
479-
if (!s) {
480-
log_e("JPEG compression failed");
481-
httpd_resp_send_500(req);
482-
return ESP_FAIL;
483203
}
204+
esp_camera_fb_return(fb);
484205
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
485206
int64_t fr_end = esp_timer_get_time();
486207
#endif
487-
log_i("FACE: %uB %ums %s%d", (uint32_t)(jchunk.len), (uint32_t)((fr_end - fr_start) / 1000), detected ? "DETECTED " : "", face_id);
208+
log_i("JPG: %uB %ums", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start) / 1000));
488209
return res;
489-
#endif
490210
}
491211

492212
static esp_err_t stream_handler(httpd_req_t *req) {
@@ -496,26 +216,6 @@ static esp_err_t stream_handler(httpd_req_t *req) {
496216
size_t _jpg_buf_len = 0;
497217
uint8_t *_jpg_buf = NULL;
498218
char *part_buf[128];
499-
#if CONFIG_ESP_FACE_DETECT_ENABLED
500-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
501-
bool detected = false;
502-
int64_t fr_ready = 0;
503-
int64_t fr_recognize = 0;
504-
int64_t fr_encode = 0;
505-
int64_t fr_face = 0;
506-
int64_t fr_start = 0;
507-
#endif
508-
int face_id = 0;
509-
size_t out_len = 0, out_width = 0, out_height = 0;
510-
uint8_t *out_buf = NULL;
511-
bool s = false;
512-
#if TWO_STAGE
513-
HumanFaceDetectMSR01 s1(0.1F, 0.5F, 10, 0.2F);
514-
HumanFaceDetectMNP01 s2(0.5F, 0.3F, 5);
515-
#else
516-
HumanFaceDetectMSR01 s1(0.3F, 0.5F, 10, 0.2F);
517-
#endif
518-
#endif
519219

520220
static int64_t last_frame = 0;
521221
if (!last_frame) {
@@ -536,152 +236,25 @@ static esp_err_t stream_handler(httpd_req_t *req) {
536236
#endif
537237

538238
while (true) {
539-
#if CONFIG_ESP_FACE_DETECT_ENABLED
540-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
541-
detected = false;
542-
#endif
543-
face_id = 0;
544-
#endif
545-
546239
fb = esp_camera_fb_get();
547240
if (!fb) {
548241
log_e("Camera capture failed");
549242
res = ESP_FAIL;
550243
} else {
551244
_timestamp.tv_sec = fb->timestamp.tv_sec;
552245
_timestamp.tv_usec = fb->timestamp.tv_usec;
553-
#if CONFIG_ESP_FACE_DETECT_ENABLED
554-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
555-
fr_start = esp_timer_get_time();
556-
fr_ready = fr_start;
557-
fr_encode = fr_start;
558-
fr_recognize = fr_start;
559-
fr_face = fr_start;
560-
#endif
561-
if (!detection_enabled || fb->width > 400) {
562-
#endif
563-
if (fb->format != PIXFORMAT_JPEG) {
564-
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
565-
esp_camera_fb_return(fb);
566-
fb = NULL;
567-
if (!jpeg_converted) {
568-
log_e("JPEG compression failed");
569-
res = ESP_FAIL;
570-
}
571-
} else {
572-
_jpg_buf_len = fb->len;
573-
_jpg_buf = fb->buf;
246+
if (fb->format != PIXFORMAT_JPEG) {
247+
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
248+
esp_camera_fb_return(fb);
249+
fb = NULL;
250+
if (!jpeg_converted) {
251+
log_e("JPEG compression failed");
252+
res = ESP_FAIL;
574253
}
575-
#if CONFIG_ESP_FACE_DETECT_ENABLED
576254
} else {
577-
if (fb->format == PIXFORMAT_RGB565
578-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
579-
&& !recognition_enabled
580-
#endif
581-
) {
582-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
583-
fr_ready = esp_timer_get_time();
584-
#endif
585-
#if TWO_STAGE
586-
std::list<dl::detect::result_t> &candidates = s1.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3});
587-
std::list<dl::detect::result_t> &results = s2.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3}, candidates);
588-
#else
589-
std::list<dl::detect::result_t> &results = s1.infer((uint16_t *)fb->buf, {(int)fb->height, (int)fb->width, 3});
590-
#endif
591-
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
592-
fr_face = esp_timer_get_time();
593-
fr_recognize = fr_face;
594-
#endif
595-
if (results.size() > 0) {
596-
fb_data_t rfb;
597-
rfb.width = fb->width;
598-
rfb.height = fb->height;
599-
rfb.data = fb->buf;
600-
rfb.bytes_per_pixel = 2;
601-
rfb.format = FB_RGB565;
602-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
603-
detected = true;
604-
#endif
605-
draw_face_boxes(&rfb, &results, face_id);
606-
}
607-
s = fmt2jpg(fb->buf, fb->len, fb->width, fb->height, PIXFORMAT_RGB565, 80, &_jpg_buf, &_jpg_buf_len);
608-
esp_camera_fb_return(fb);
609-
fb = NULL;
610-
if (!s) {
611-
log_e("fmt2jpg failed");
612-
res = ESP_FAIL;
613-
}
614-
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
615-
fr_encode = esp_timer_get_time();
616-
#endif
617-
} else {
618-
out_len = fb->width * fb->height * 3;
619-
out_width = fb->width;
620-
out_height = fb->height;
621-
out_buf = (uint8_t *)malloc(out_len);
622-
if (!out_buf) {
623-
log_e("out_buf malloc failed");
624-
res = ESP_FAIL;
625-
} else {
626-
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
627-
esp_camera_fb_return(fb);
628-
fb = NULL;
629-
if (!s) {
630-
free(out_buf);
631-
log_e("To rgb888 failed");
632-
res = ESP_FAIL;
633-
} else {
634-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
635-
fr_ready = esp_timer_get_time();
636-
#endif
637-
638-
fb_data_t rfb;
639-
rfb.width = out_width;
640-
rfb.height = out_height;
641-
rfb.data = out_buf;
642-
rfb.bytes_per_pixel = 3;
643-
rfb.format = FB_BGR888;
644-
645-
#if TWO_STAGE
646-
std::list<dl::detect::result_t> &candidates = s1.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3});
647-
std::list<dl::detect::result_t> &results = s2.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3}, candidates);
648-
#else
649-
std::list<dl::detect::result_t> &results = s1.infer((uint8_t *)out_buf, {(int)out_height, (int)out_width, 3});
650-
#endif
651-
652-
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
653-
fr_face = esp_timer_get_time();
654-
fr_recognize = fr_face;
655-
#endif
656-
657-
if (results.size() > 0) {
658-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
659-
detected = true;
660-
#endif
661-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
662-
if (recognition_enabled) {
663-
face_id = run_face_recognition(&rfb, &results);
664-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
665-
fr_recognize = esp_timer_get_time();
666-
#endif
667-
}
668-
#endif
669-
draw_face_boxes(&rfb, &results, face_id);
670-
}
671-
s = fmt2jpg(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len);
672-
free(out_buf);
673-
if (!s) {
674-
log_e("fmt2jpg failed");
675-
res = ESP_FAIL;
676-
}
677-
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
678-
fr_encode = esp_timer_get_time();
679-
#endif
680-
}
681-
}
682-
}
255+
_jpg_buf_len = fb->len;
256+
_jpg_buf = fb->buf;
683257
}
684-
#endif
685258
}
686259
if (res == ESP_OK) {
687260
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
@@ -707,30 +280,14 @@ static esp_err_t stream_handler(httpd_req_t *req) {
707280
}
708281
int64_t fr_end = esp_timer_get_time();
709282

710-
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
711-
int64_t ready_time = (fr_ready - fr_start) / 1000;
712-
int64_t face_time = (fr_face - fr_ready) / 1000;
713-
int64_t recognize_time = (fr_recognize - fr_face) / 1000;
714-
int64_t encode_time = (fr_encode - fr_recognize) / 1000;
715-
int64_t process_time = (fr_encode - fr_start) / 1000;
716-
#endif
717-
718283
int64_t frame_time = fr_end - last_frame;
719284
frame_time /= 1000;
720285
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
721286
uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time);
722287
#endif
723288
log_i(
724-
"MJPG: %uB %ums (%.1ffps), AVG: %ums (%.1ffps)"
725-
#if CONFIG_ESP_FACE_DETECT_ENABLED
726-
", %u+%u+%u+%u=%u %s%d"
727-
#endif
728-
,
729-
(uint32_t)(_jpg_buf_len), (uint32_t)frame_time, 1000.0 / (uint32_t)frame_time, avg_frame_time, 1000.0 / avg_frame_time
730-
#if CONFIG_ESP_FACE_DETECT_ENABLED
731-
,
732-
(uint32_t)ready_time, (uint32_t)face_time, (uint32_t)recognize_time, (uint32_t)encode_time, (uint32_t)process_time, (detected) ? "DETECTED " : "", face_id
733-
#endif
289+
"MJPG: %uB %ums (%.1ffps), AVG: %ums (%.1ffps)", (uint32_t)(_jpg_buf_len), (uint32_t)frame_time, 1000.0 / (uint32_t)frame_time, avg_frame_time,
290+
1000.0 / avg_frame_time
734291
);
735292
}
736293

@@ -841,28 +398,6 @@ static esp_err_t cmd_handler(httpd_req_t *req) {
841398
enable_led(true);
842399
}
843400
}
844-
#endif
845-
846-
#if CONFIG_ESP_FACE_DETECT_ENABLED
847-
else if (!strcmp(variable, "face_detect")) {
848-
detection_enabled = val;
849-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
850-
if (!detection_enabled) {
851-
recognition_enabled = 0;
852-
}
853-
#endif
854-
}
855-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
856-
else if (!strcmp(variable, "face_enroll")) {
857-
is_enrolling = !is_enrolling;
858-
log_i("Enrolling: %s", is_enrolling ? "true" : "false");
859-
} else if (!strcmp(variable, "face_recognize")) {
860-
recognition_enabled = val;
861-
if (recognition_enabled) {
862-
detection_enabled = val;
863-
}
864-
}
865-
#endif
866401
#endif
867402
else {
868403
log_i("Unknown command: %s", variable);
@@ -947,13 +482,6 @@ static esp_err_t status_handler(httpd_req_t *req) {
947482
p += sprintf(p, ",\"led_intensity\":%u", led_duty);
948483
#else
949484
p += sprintf(p, ",\"led_intensity\":%d", -1);
950-
#endif
951-
#if CONFIG_ESP_FACE_DETECT_ENABLED
952-
p += sprintf(p, ",\"face_detect\":%u", detection_enabled);
953-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
954-
p += sprintf(p, ",\"face_enroll\":%u,", is_enrolling);
955-
p += sprintf(p, "\"face_recognize\":%u", recognition_enabled);
956-
#endif
957485
#endif
958486
*p++ = '}';
959487
*p++ = 0;
@@ -1289,12 +817,6 @@ void startCameraServer() {
1289817

1290818
ra_filter_init(&ra_filter, 20);
1291819

1292-
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
1293-
recognizer.set_partition(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "fr");
1294-
1295-
// load ids from flash partition
1296-
recognizer.set_ids_from_flash();
1297-
#endif
1298820
log_i("Starting web server on port: '%d'", config.server_port);
1299821
if (httpd_start(&camera_httpd, &config) == ESP_OK) {
1300822
httpd_register_uri_handler(camera_httpd, &index_uri);

‎package/package_esp32_index.template.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,57 +101,57 @@
101101
"host": "i686-mingw32",
102102
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
103103
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
104-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
105-
"size": "399729605"
104+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
105+
"size": "351074410"
106106
},
107107
{
108108
"host": "x86_64-mingw32",
109109
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
110110
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
111-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
112-
"size": "399729605"
111+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
112+
"size": "351074410"
113113
},
114114
{
115115
"host": "arm64-apple-darwin",
116116
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
117117
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
118-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
119-
"size": "399729605"
118+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
119+
"size": "351074410"
120120
},
121121
{
122122
"host": "x86_64-apple-darwin",
123123
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
124124
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
125-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
126-
"size": "399729605"
125+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
126+
"size": "351074410"
127127
},
128128
{
129129
"host": "x86_64-pc-linux-gnu",
130130
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
131131
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
132-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
133-
"size": "399729605"
132+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
133+
"size": "351074410"
134134
},
135135
{
136136
"host": "i686-pc-linux-gnu",
137137
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
138138
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
139-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
140-
"size": "399729605"
139+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
140+
"size": "351074410"
141141
},
142142
{
143143
"host": "aarch64-linux-gnu",
144144
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
145145
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
146-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
147-
"size": "399729605"
146+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
147+
"size": "351074410"
148148
},
149149
{
150150
"host": "arm-linux-gnueabihf",
151151
"url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
152152
"archiveFileName": "esp32-arduino-libs-idf-release_v5.3-707d097b.zip",
153-
"checksum": "SHA-256:f8624bf7eab91e0a3bb3be4cc385fef5a05a725bc6ff978f3d4e2562f2805b1e",
154-
"size": "399729605"
153+
"checksum": "SHA-256:b4d431c8e6e9eb26c78cb187b9082055544956a4dac8e224ff884f770e5f0e5a",
154+
"size": "351074410"
155155
}
156156
]
157157
},

0 commit comments

Comments
 (0)
Please sign in to comment.