I need to refresh board specific values(board's S-out value) on web page every time get-still button clicked.
So I'd change code app_httpd.c and index_ov5640.html but it has no changes.
What am i missing?
Code: Select all
static esp_err_t capture_handler(httpd_req_t *req)
{
camera_fb_t *fb = NULL;
esp_err_t res = ESP_OK;
int64_t fr_start = esp_timer_get_time();
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
enable_led(true);
vTaskDelay(150 / portTICK_PERIOD_MS); // The LED needs to be turned on ~150ms before the call to esp_camera_fb_get()
fb = esp_camera_fb_get(); // or it won't be visible in the frame. A better way to do this is needed.
enable_led(false);
#else
fb = esp_camera_fb_get();
#endif
if (!fb)
{
ESP_LOGE(TAG, "Camera capture failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
httpd_resp_set_type(req, "image/jpeg");
httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
char ts[32];
snprintf(ts, 32, "%ld.%06ld", fb->timestamp.tv_sec, fb->timestamp.tv_usec);
httpd_resp_set_hdr(req, "X-Timestamp", (const char *)ts);
#if CONFIG_ESP_FACE_DETECT_ENABLED
size_t out_len, out_width, out_height;
uint8_t *out_buf;
bool s;
bool detected = false;
int face_id = 0;
if (!detection_enabled || fb->width > 400)
{
#endif
size_t fb_len = 0;
if (fb->format == PIXFORMAT_JPEG)
{
fb_len = fb->len;
res = httpd_resp_send(req, (const char *)fb->buf, fb->len);
#if 1 //20210218 Refresh S-out value on web page
static char json_response[17];
char * p = json_response;
*p++ = '{';
p+=sprintf(p, "\"s-out\":%u,", 654321);
*p++ = '}';
*p++ = 0;
httpd_resp_set_type(req, "application/json");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, json_response, strlen(json_response));
#endif
}
else
{
jpg_chunking_t jchunk = {req, 0};
res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk) ? ESP_OK : ESP_FAIL;
httpd_resp_send_chunk(req, NULL, 0);
fb_len = jchunk.len;
}
esp_camera_fb_return(fb);
int64_t fr_end = esp_timer_get_time();
ESP_LOGI(TAG, "JPG: %uB %ums", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start) / 1000));
return res;
#if CONFIG_ESP_FACE_DETECT_ENABLED
}
dl_matrix3du_t *image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
if (!image_matrix)
{
esp_camera_fb_return(fb);
ESP_LOGE(TAG, "dl_matrix3du_alloc failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
out_buf = image_matrix->item;
out_len = fb->width * fb->height * 3;
out_width = fb->width;
out_height = fb->height;
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
esp_camera_fb_return(fb);
if (!s)
{
dl_matrix3du_free(image_matrix);
ESP_LOGE(TAG, "to rgb888 failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
box_array_t *net_boxes = face_detect(image_matrix, &mtmn_config);
if (net_boxes)
{
detected = true;
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
if (recognition_enabled)
{
face_id = run_face_recognition(image_matrix, net_boxes);
}
#endif
draw_face_boxes(image_matrix, net_boxes, face_id);
dl_lib_free(net_boxes->score);
dl_lib_free(net_boxes->box);
if (net_boxes->landmark != NULL)
dl_lib_free(net_boxes->landmark);
dl_lib_free(net_boxes);
}
jpg_chunking_t jchunk = {req, 0};
s = fmt2jpg_cb(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, jpg_encode_stream, &jchunk);
dl_matrix3du_free(image_matrix);
if (!s)
{
ESP_LOGE(TAG, "JPEG compression failed");
return ESP_FAIL;
}
int64_t fr_end = esp_timer_get_time();
ESP_LOGI(TAG, "FACE: %uB %ums %s%d", (uint32_t)(jchunk.len), (uint32_t)((fr_end - fr_start) / 1000), detected ? "DETECTED " : "", face_id);
return res;
#endif
}
Code: Select all
<section id="buttons">
<button id="get-still">Get Still</button>
<div class="input-group">
<label for="s-out">S-out Value:</label>
<div class="text">
<span id="s-out">123456</span>
</div>
</div>
<button id="toggle-stream">Start Stream</button>
<button id="face_enroll" class="hidden" disabled="disabled">Enroll Face</button>
</section>