|
|
|
|
@ -3,13 +3,15 @@
|
|
|
|
|
## CameraWebServer_ESP32-CAM.ino
|
|
|
|
|
|
|
|
|
|
* Configure WiFi SSID
|
|
|
|
|
```
|
|
|
|
|
const char* ssid = "Your SSID";
|
|
|
|
|
const char* password = "Your Password";
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
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;
|
|
|
|
|
config.ledc_timer = LEDC_TIMER_0;
|
|
|
|
|
@ -31,39 +33,42 @@ 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);
|
|
|
|
|
|
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
|
delay(500);
|
|
|
|
|
Serial.print(".");
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Start httpd Web Camera Server
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
startCameraServer();
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## app_httpd.cpp
|
|
|
|
|
* Setup Web Server endpoint
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
if (httpd_start(&camera_httpd, &config) == ESP_OK) {
|
|
|
|
|
httpd_register_uri_handler(camera_httpd, &index_uri);
|
|
|
|
|
httpd_register_uri_handler(camera_httpd, &cmd_uri);
|
|
|
|
|
httpd_register_uri_handler(camera_httpd, &status_uri);
|
|
|
|
|
httpd_register_uri_handler(camera_httpd, &capture_uri);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* index landing page callback to read camera source and publish camera image
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t index_handler(httpd_req_t *req){
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t index_handler(httpd_req_t *req){
|
|
|
|
|
httpd_resp_set_type(req, "text/html");
|
|
|
|
|
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
|
|
|
|
|
sensor_t * s = esp_camera_sensor_get();
|
|
|
|
|
@ -71,14 +76,15 @@ static esp_err_t index_handler(httpd_req_t *req){
|
|
|
|
|
return httpd_resp_send(req, (const char *)index_ov3660_html_gz, index_ov3660_html_gz_len);
|
|
|
|
|
}
|
|
|
|
|
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* streaming of camera source
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t stream_handler(httpd_req_t *req){
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
static esp_err_t stream_handler(httpd_req_t *req){
|
|
|
|
|
camera_fb_t * fb = NULL;
|
|
|
|
|
esp_err_t res = ESP_OK;
|
|
|
|
|
size_t _jpg_buf_len = 0;
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```
|