Add local network camera monitor (#138)

This feature is located at `http://[camera-ip]/monitor` and gives quick access to up to 5  cameras running the web server example.
Features:
- Finds up to 5 cameras in the local network through mDNS
- Grabs periodicaly and image from each camera (period can be set or turned off)
- Cycles the cameras at given period (off when camera is selected manually)
- Shows basic info for each camera (model, sensor, resolution)
- Allows for easy access to each camer's control panel
- Allows change of resolution and XCLK
- Can save current snapshot
idfv3.3.1
Me No Dev 2020-03-31 05:51:25 +03:00 committed by GitHub
parent 3a734c0d69
commit 0ba76f0a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1054 additions and 8 deletions

View File

@ -13,6 +13,7 @@ set(COMPONENT_REQUIRES
set(COMPONENT_EMBED_FILES
"www/index_ov2640.html.gz"
"www/index_ov3660.html.gz"
"www/index_ov5640.html.gz")
"www/index_ov5640.html.gz"
"www/monitor.html.gz")
register_component()

View File

@ -1,6 +1,12 @@
menu "Camera Web Server"
menu "WiFi Settings"
config ESP_HOST_NAME
string "Camera Host Name"
default ""
help
Hostname that the camera will advertise over mDNS.
config ESP_WIFI_SSID
string "WiFi STA SSID"
default ""

View File

@ -21,6 +21,7 @@
//#include "camera_index.h"
#include "sdkconfig.h"
#include "app_mdns.h"
#include "app_camera.h"
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
#include "esp32-hal-log.h"
@ -840,6 +841,9 @@ static esp_err_t status_handler(httpd_req_t *req)
p+=print_reg(p, s, 0x132, 0xFF);
}
p += sprintf(p, "\"board\":\"%s\",", CAM_BOARD);
p += sprintf(p, "\"xclk\":%u,", s->xclk_freq_hz / 1000000);
p += sprintf(p, "\"pixformat\":%u,", s->pixformat);
p += sprintf(p, "\"framesize\":%u,", s->status.framesize);
p += sprintf(p, "\"quality\":%u,", s->status.quality);
p += sprintf(p, "\"brightness\":%d,", s->status.brightness);
@ -1086,10 +1090,20 @@ static esp_err_t index_handler(httpd_req_t *req)
}
}
static esp_err_t monitor_handler(httpd_req_t *req)
{
extern const unsigned char monitor_html_gz_start[] asm("_binary_monitor_html_gz_start");
extern const unsigned char monitor_html_gz_end[] asm("_binary_monitor_html_gz_end");
size_t monitor_html_gz_len = monitor_html_gz_end - monitor_html_gz_start;
httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
return httpd_resp_send(req, (const char *)monitor_html_gz_start, monitor_html_gz_len);
}
void app_httpd_main()
{
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.max_uri_handlers = 10;
config.max_uri_handlers = 12;
httpd_uri_t index_uri = {
.uri = "/",
@ -1157,6 +1171,12 @@ void app_httpd_main()
.handler = mdns_handler,
.user_ctx = NULL};
httpd_uri_t monitor_uri = {
.uri = "/monitor",
.method = HTTP_GET,
.handler = monitor_handler,
.user_ctx = NULL};
ra_filter_init(&ra_filter, 20);
#if CONFIG_ESP_FACE_DETECT_ENABLED
@ -1201,6 +1221,7 @@ void app_httpd_main()
httpd_register_uri_handler(camera_httpd, &win_uri);
httpd_register_uri_handler(camera_httpd, &mdns_uri);
httpd_register_uri_handler(camera_httpd, &monitor_uri);
}
config.server_port += 1;

View File

@ -177,11 +177,6 @@ void app_mdns_main()
}
xSemaphoreGive(query_lock);
if (esp_read_mac(mac, ESP_MAC_WIFI_STA) != ESP_OK) {
ESP_LOGE(TAG, "esp_read_mac() Failed");
return;
}
sensor_t * s = esp_camera_sensor_get();
switch(s->id.PID){
case OV2640_PID: model = "OV2640"; break;
@ -190,7 +185,17 @@ void app_mdns_main()
case OV7725_PID: model = "OV7725"; break;
default: model = "UNKNOWN"; break;
}
snprintf(iname, 64, "%s-%s-%02X%02X%02X", CAM_BOARD, model, mac[3], mac[4], mac[5]);
if (strlen(CONFIG_ESP_HOST_NAME) > 0) {
snprintf(iname, 64, "%s", CONFIG_ESP_HOST_NAME);
} else {
if (esp_read_mac(mac, ESP_MAC_WIFI_STA) != ESP_OK) {
ESP_LOGE(TAG, "esp_read_mac() Failed");
return;
}
snprintf(iname, 64, "%s-%s-%02X%02X%02X", CAM_BOARD, model, mac[3], mac[4], mac[5]);
}
snprintf(framesize, 4, "%d", s->status.framesize);
snprintf(pixformat, 4, "%d", s->pixformat);

View File

@ -9,3 +9,4 @@
COMPONENT_EMBED_FILES := www/index_ov2640.html.gz
COMPONENT_EMBED_FILES += www/index_ov3660.html.gz
COMPONENT_EMBED_FILES += www/index_ov5640.html.gz
COMPONENT_EMBED_FILES += www/monitor.html.gz

File diff suppressed because one or more lines are too long