|
|
|
|
@ -3,12 +3,14 @@
|
|
|
|
|
## CameraWebServer_ESP32-CAM.ino
|
|
|
|
|
|
|
|
|
|
* Configure WiFi SSID
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
const char* ssid = "Your SSID";
|
|
|
|
|
const char* password = "Your Password";
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Setup Camera CSI pin assignment
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
camera_config_t config;
|
|
|
|
|
config.ledc_channel = LEDC_CHANNEL_0;
|
|
|
|
|
@ -31,10 +33,10 @@ const char* password = "Your Password";
|
|
|
|
|
config.pin_reset = RESET_GPIO_NUM;
|
|
|
|
|
config.xclk_freq_hz = 20000000;
|
|
|
|
|
config.pixel_format = PIXFORMAT_JPEG;
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Connect WiFi network
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
WiFi.begin(ssid, password);
|
|
|
|
|
|
|
|
|
|
@ -45,6 +47,7 @@ const char* password = "Your Password";
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Start httpd Web Camera Server
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
startCameraServer();
|
|
|
|
|
|
|
|
|
|
@ -52,6 +55,7 @@ const char* password = "Your Password";
|
|
|
|
|
|
|
|
|
|
## app_httpd.cpp
|
|
|
|
|
* Setup Web Server endpoint
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
if (httpd_start(&camera_httpd, &config) == ESP_OK) {
|
|
|
|
|
httpd_register_uri_handler(camera_httpd, &index_uri);
|
|
|
|
|
@ -62,6 +66,7 @@ const char* password = "Your Password";
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* index landing page callback to read camera source and publish camera image
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t index_handler(httpd_req_t *req){
|
|
|
|
|
httpd_resp_set_type(req, "text/html");
|
|
|
|
|
@ -75,6 +80,7 @@ static esp_err_t index_handler(httpd_req_t *req){
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* streaming of camera source
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t stream_handler(httpd_req_t *req){
|
|
|
|
|
camera_fb_t * fb = NULL;
|
|
|
|
|
|