66// Ensure ESP32 Wrover Module or other board with PSRAM is selected
77// Partial images will be transmitted if image exceeds buffer size
88//
9+ // You must select partition scheme from the board menu that has at least 3MB APP space.
10+ // Face Recognition is DISABLED for ESP32 and ESP32-S2, because it takes up from 15
11+ // seconds to process single frame. Face Detection is ENABLED if PSRAM is enabled as well
912
13+ // ===================
1014// Select camera model
11- #define CAMERA_MODEL_WROVER_KIT // Has PSRAM
15+ // ===================
16+ // #define CAMERA_MODEL_WROVER_KIT // Has PSRAM
1217// #define CAMERA_MODEL_ESP_EYE // Has PSRAM
18+ // #define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
1319// #define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
1420// #define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
1521// #define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
1622// #define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
1723// #define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
18- // #define CAMERA_MODEL_AI_THINKER // Has PSRAM
24+ #define CAMERA_MODEL_AI_THINKER // Has PSRAM
1925// #define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
26+ // ** Espressif Internal Boards **
27+ // #define CAMERA_MODEL_ESP32_CAM_BOARD
28+ // #define CAMERA_MODEL_ESP32S2_CAM_BOARD
29+ // #define CAMERA_MODEL_ESP32S3_CAM_LCD
2030
2131#include " camera_pins.h"
2232
23- const char * ssid = " *********" ;
24- const char * password = " *********" ;
33+ // ===========================
34+ // Enter your WiFi credentials
35+ // ===========================
36+ const char * ssid = " **********" ;
37+ const char * password = " **********" ;
2538
2639void startCameraServer ();
2740
@@ -50,19 +63,32 @@ void setup() {
5063 config.pin_pwdn = PWDN_GPIO_NUM;
5164 config.pin_reset = RESET_GPIO_NUM;
5265 config.xclk_freq_hz = 20000000 ;
53- config.pixel_format = PIXFORMAT_JPEG;
66+ config.frame_size = FRAMESIZE_UXGA;
67+ config.pixel_format = PIXFORMAT_JPEG; // for streaming
68+ // config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
69+ config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
70+ config.fb_location = CAMERA_FB_IN_PSRAM;
71+ config.jpeg_quality = 12 ;
72+ config.fb_count = 1 ;
5473
5574 // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
5675 // for larger pre-allocated frame buffer.
57- if (psramFound ()){
58- config.frame_size = FRAMESIZE_UXGA;
59- config.jpeg_quality = 10 ;
60- config.fb_count = 2 ;
76+ if (config.pixel_format == PIXFORMAT_JPEG){
77+ if (psramFound ()){
78+ config.jpeg_quality = 10 ;
79+ config.fb_count = 2 ;
80+ config.grab_mode = CAMERA_GRAB_LATEST;
81+ } else {
82+ // Limit the frame size when PSRAM is not available
83+ config.frame_size = FRAMESIZE_SVGA;
84+ config.fb_location = CAMERA_FB_IN_DRAM;
85+ }
6186 } else {
62- config.frame_size = FRAMESIZE_SVGA;
63- config.jpeg_quality = 12 ;
64- config.fb_count = 1 ;
65- config.fb_location = CAMERA_FB_IN_DRAM;
87+ // Best option for face detection/recognition
88+ config.frame_size = FRAMESIZE_240X240;
89+ #if CONFIG_IDF_TARGET_ESP32S3
90+ config.fb_count = 2 ;
91+ #endif
6692 }
6793
6894#if defined(CAMERA_MODEL_ESP_EYE)
@@ -85,14 +111,21 @@ void setup() {
85111 s->set_saturation (s, -2 ); // lower the saturation
86112 }
87113 // drop down frame size for higher initial frame rate
88- s->set_framesize (s, FRAMESIZE_QVGA);
114+ if (config.pixel_format == PIXFORMAT_JPEG){
115+ s->set_framesize (s, FRAMESIZE_QVGA);
116+ }
89117
90118#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
91119 s->set_vflip (s, 1 );
92120 s->set_hmirror (s, 1 );
93121#endif
94122
123+ #if defined(CAMERA_MODEL_ESP32S3_EYE)
124+ s->set_vflip (s, 1 );
125+ #endif
126+
95127 WiFi.begin (ssid, password);
128+ WiFi.setSleep (false );
96129
97130 while (WiFi.status () != WL_CONNECTED) {
98131 delay (500 );
@@ -109,6 +142,6 @@ void setup() {
109142}
110143
111144void loop () {
112- // put your main code here, to run repeatedly:
145+ // Do nothing. Everything is done in another task by the web server
113146 delay (10000 );
114147}
0 commit comments