camera settings
This commit is contained in:
parent
61ee8e9423
commit
75c2fbde55
20
src/main.cpp
20
src/main.cpp
@ -10,6 +10,7 @@ static const char *STREAM_BOUNDARY = "\r\n--frame\r\n";
|
|||||||
static const char *STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
static const char *STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
||||||
|
|
||||||
static httpd_handle_t httpd = nullptr;
|
static httpd_handle_t httpd = nullptr;
|
||||||
|
static httpd_handle_t httpd_stream = nullptr;
|
||||||
|
|
||||||
static bool cameraPinsOk() {
|
static bool cameraPinsOk() {
|
||||||
return CAM_PIN_XCLK != -1 &&
|
return CAM_PIN_XCLK != -1 &&
|
||||||
@ -51,7 +52,7 @@ static esp_err_t handleRoot(httpd_req_t *req) {
|
|||||||
"label{display:block;margin-top:10px;}"
|
"label{display:block;margin-top:10px;}"
|
||||||
"</style></head><body>"
|
"</style></head><body>"
|
||||||
"<h2>ESP32 Camera</h2>"
|
"<h2>ESP32 Camera</h2>"
|
||||||
"<img id='stream' src='/stream' />"
|
"<img id='stream' />"
|
||||||
"<label>Frame size:"
|
"<label>Frame size:"
|
||||||
"<select id='fs'>"
|
"<select id='fs'>"
|
||||||
"<option value='10'>QVGA</option>"
|
"<option value='10'>QVGA</option>"
|
||||||
@ -63,7 +64,9 @@ static esp_err_t handleRoot(httpd_req_t *req) {
|
|||||||
"<label>Contrast: <input id='c' type='range' min='-2' max='2' value='0'></label>"
|
"<label>Contrast: <input id='c' type='range' min='-2' max='2' value='0'></label>"
|
||||||
"<label>Saturation: <input id='s' type='range' min='-2' max='2' value='0'></label>"
|
"<label>Saturation: <input id='s' type='range' min='-2' max='2' value='0'></label>"
|
||||||
"<script>"
|
"<script>"
|
||||||
"const set=(v,val)=>fetch(`/control?var=${v}&val=${val}`);"
|
"const host=location.hostname;"
|
||||||
|
"stream.src=`http://${host}:81/stream`;"
|
||||||
|
"const set=(v,val)=>fetch(`http://${host}/control?var=${v}&val=${val}`);"
|
||||||
"fs.onchange=()=>set('framesize',fs.value);"
|
"fs.onchange=()=>set('framesize',fs.value);"
|
||||||
"q.oninput=()=>set('quality',q.value);"
|
"q.oninput=()=>set('quality',q.value);"
|
||||||
"b.oninput=()=>set('brightness',b.value);"
|
"b.oninput=()=>set('brightness',b.value);"
|
||||||
@ -190,13 +193,20 @@ static void startWebServer() {
|
|||||||
httpd_uri_t status = { .uri = "/status", .method = HTTP_GET, .handler = handleStatus, .user_ctx = nullptr };
|
httpd_uri_t status = { .uri = "/status", .method = HTTP_GET, .handler = handleStatus, .user_ctx = nullptr };
|
||||||
httpd_uri_t control = { .uri = "/control", .method = HTTP_GET, .handler = handleControl, .user_ctx = nullptr };
|
httpd_uri_t control = { .uri = "/control", .method = HTTP_GET, .handler = handleControl, .user_ctx = nullptr };
|
||||||
httpd_uri_t capture = { .uri = "/capture", .method = HTTP_GET, .handler = handleCapture, .user_ctx = nullptr };
|
httpd_uri_t capture = { .uri = "/capture", .method = HTTP_GET, .handler = handleCapture, .user_ctx = nullptr };
|
||||||
httpd_uri_t stream = { .uri = "/stream", .method = HTTP_GET, .handler = handleStream, .user_ctx = nullptr };
|
|
||||||
|
|
||||||
httpd_register_uri_handler(httpd, &root);
|
httpd_register_uri_handler(httpd, &root);
|
||||||
httpd_register_uri_handler(httpd, &status);
|
httpd_register_uri_handler(httpd, &status);
|
||||||
httpd_register_uri_handler(httpd, &control);
|
httpd_register_uri_handler(httpd, &control);
|
||||||
httpd_register_uri_handler(httpd, &capture);
|
httpd_register_uri_handler(httpd, &capture);
|
||||||
httpd_register_uri_handler(httpd, &stream);
|
|
||||||
|
config.server_port += 1;
|
||||||
|
config.ctrl_port += 1;
|
||||||
|
if (httpd_start(&httpd_stream, &config) != ESP_OK) {
|
||||||
|
Serial.println("Stream server start failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
httpd_uri_t stream = { .uri = "/stream", .method = HTTP_GET, .handler = handleStream, .user_ctx = nullptr };
|
||||||
|
httpd_register_uri_handler(httpd_stream, &stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user