6
6
// Ensure ESP32 Wrover Module or other board with PSRAM is selected
7
7
// Partial images will be transmitted if image exceeds buffer size
8
8
//
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
9
12
13
+ // ===================
10
14
// Select camera model
11
- #define CAMERA_MODEL_WROVER_KIT // Has PSRAM
15
+ // ===================
16
+ // #define CAMERA_MODEL_WROVER_KIT // Has PSRAM
12
17
// #define CAMERA_MODEL_ESP_EYE // Has PSRAM
18
+ // #define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
13
19
// #define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
14
20
// #define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
15
21
// #define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
16
22
// #define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
17
23
// #define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
18
- // #define CAMERA_MODEL_AI_THINKER // Has PSRAM
24
+ #define CAMERA_MODEL_AI_THINKER // Has PSRAM
19
25
// #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
20
30
21
31
#include " camera_pins.h"
22
32
23
- const char * ssid = " *********" ;
24
- const char * password = " *********" ;
33
+ // ===========================
34
+ // Enter your WiFi credentials
35
+ // ===========================
36
+ const char * ssid = " **********" ;
37
+ const char * password = " **********" ;
25
38
26
39
void startCameraServer ();
27
40
@@ -50,19 +63,32 @@ void setup() {
50
63
config.pin_pwdn = PWDN_GPIO_NUM;
51
64
config.pin_reset = RESET_GPIO_NUM;
52
65
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 ;
54
73
55
74
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
56
75
// 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
+ }
61
86
} 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
66
92
}
67
93
68
94
#if defined(CAMERA_MODEL_ESP_EYE)
@@ -85,14 +111,21 @@ void setup() {
85
111
s->set_saturation (s, -2 ); // lower the saturation
86
112
}
87
113
// 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
+ }
89
117
90
118
#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
91
119
s->set_vflip (s, 1 );
92
120
s->set_hmirror (s, 1 );
93
121
#endif
94
122
123
+ #if defined(CAMERA_MODEL_ESP32S3_EYE)
124
+ s->set_vflip (s, 1 );
125
+ #endif
126
+
95
127
WiFi.begin (ssid, password);
128
+ WiFi.setSleep (false );
96
129
97
130
while (WiFi.status () != WL_CONNECTED) {
98
131
delay (500 );
@@ -109,6 +142,6 @@ void setup() {
109
142
}
110
143
111
144
void loop () {
112
- // put your main code here, to run repeatedly:
145
+ // Do nothing. Everything is done in another task by the web server
113
146
delay (10000 );
114
147
}
0 commit comments