Updated camera example (#7533)
This commit is contained in:
parent
dbeae9480d
commit
ba68f318f4
3 changed files with 74 additions and 51 deletions
|
|
@ -14,14 +14,14 @@
|
||||||
// Select camera model
|
// Select camera model
|
||||||
// ===================
|
// ===================
|
||||||
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
||||||
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
#define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
|
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
|
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
|
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
|
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
|
||||||
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
||||||
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
||||||
// ** Espressif Internal Boards **
|
// ** Espressif Internal Boards **
|
||||||
//#define CAMERA_MODEL_ESP32_CAM_BOARD
|
//#define CAMERA_MODEL_ESP32_CAM_BOARD
|
||||||
|
|
@ -37,6 +37,7 @@ const char* ssid = "**********";
|
||||||
const char* password = "**********";
|
const char* password = "**********";
|
||||||
|
|
||||||
void startCameraServer();
|
void startCameraServer();
|
||||||
|
void setupLedFlash(int pin);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -124,6 +125,11 @@ void setup() {
|
||||||
s->set_vflip(s, 1);
|
s->set_vflip(s, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Setup LED FLash if LED pin is defined in camera_pins.h
|
||||||
|
#if defined(LED_GPIO_NUM)
|
||||||
|
setupLedFlash(LED_GPIO_NUM);
|
||||||
|
#endif
|
||||||
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
WiFi.setSleep(false);
|
WiFi.setSleep(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,12 @@
|
||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include "img_converters.h"
|
#include "img_converters.h"
|
||||||
#include "fb_gfx.h"
|
#include "fb_gfx.h"
|
||||||
#include "driver/ledc.h"
|
#include "esp32-hal-ledc.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "camera_index.h"
|
#include "camera_index.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#define TAG ""
|
|
||||||
#else
|
|
||||||
#include "esp_log.h"
|
|
||||||
static const char *TAG = "camera_httpd";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Face Detection will not work on boards without (or with disabled) PSRAM
|
// Face Detection will not work on boards without (or with disabled) PSRAM
|
||||||
|
|
@ -72,14 +68,18 @@ static const char *TAG = "camera_httpd";
|
||||||
#define FACE_COLOR_PURPLE (FACE_COLOR_BLUE | FACE_COLOR_RED)
|
#define FACE_COLOR_PURPLE (FACE_COLOR_BLUE | FACE_COLOR_RED)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
// Enable LED FLASH setting
|
||||||
|
#define CONFIG_LED_ILLUMINATOR_ENABLED 1
|
||||||
|
|
||||||
|
// LED FLASH setup
|
||||||
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
|
|
||||||
|
#define LED_LEDC_CHANNEL 2 //Using different ledc channel/timer than camera
|
||||||
|
#define CONFIG_LED_MAX_INTENSITY 255
|
||||||
|
|
||||||
int led_duty = 0;
|
int led_duty = 0;
|
||||||
bool isStreaming = false;
|
bool isStreaming = false;
|
||||||
#ifdef CONFIG_LED_LEDC_LOW_SPEED_MODE
|
|
||||||
#define CONFIG_LED_LEDC_SPEED_MODE LEDC_LOW_SPEED_MODE
|
|
||||||
#else
|
|
||||||
#define CONFIG_LED_LEDC_SPEED_MODE LEDC_HIGH_SPEED_MODE
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
@ -263,7 +263,7 @@ static int run_face_recognition(fb_data_t *fb, std::list<dl::detect::result_t> *
|
||||||
|
|
||||||
if (enrolled_count < FACE_ID_SAVE_NUMBER && is_enrolling){
|
if (enrolled_count < FACE_ID_SAVE_NUMBER && is_enrolling){
|
||||||
id = recognizer.enroll_id(tensor, landmarks, "", true);
|
id = recognizer.enroll_id(tensor, landmarks, "", true);
|
||||||
ESP_LOGI(TAG, "Enrolled ID: %d", id);
|
log_i("Enrolled ID: %d", id);
|
||||||
rgb_printf(fb, FACE_COLOR_CYAN, "ID[%u]", id);
|
rgb_printf(fb, FACE_COLOR_CYAN, "ID[%u]", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ static int run_face_recognition(fb_data_t *fb, std::list<dl::detect::result_t> *
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
void enable_led(bool en)
|
void enable_led(bool en)
|
||||||
{ // Turn LED On or Off
|
{ // Turn LED On or Off
|
||||||
int duty = en ? led_duty : 0;
|
int duty = en ? led_duty : 0;
|
||||||
|
|
@ -286,9 +286,10 @@ void enable_led(bool en)
|
||||||
{
|
{
|
||||||
duty = CONFIG_LED_MAX_INTENSITY;
|
duty = CONFIG_LED_MAX_INTENSITY;
|
||||||
}
|
}
|
||||||
ledc_set_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL, duty);
|
ledcWrite(LED_LEDC_CHANNEL, duty);
|
||||||
ledc_update_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL);
|
//ledc_set_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL, duty);
|
||||||
ESP_LOGI(TAG, "Set LED intensity to %d", duty);
|
//ledc_update_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL);
|
||||||
|
log_i("Set LED intensity to %d", duty);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -302,7 +303,7 @@ static esp_err_t bmp_handler(httpd_req_t *req)
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
if (!fb)
|
if (!fb)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Camera capture failed");
|
log_e("Camera capture failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +322,7 @@ static esp_err_t bmp_handler(httpd_req_t *req)
|
||||||
bool converted = frame2bmp(fb, &buf, &buf_len);
|
bool converted = frame2bmp(fb, &buf, &buf_len);
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
if(!converted){
|
if(!converted){
|
||||||
ESP_LOGE(TAG, "BMP Conversion failed");
|
log_e("BMP Conversion failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
@ -330,7 +331,7 @@ static esp_err_t bmp_handler(httpd_req_t *req)
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
uint64_t fr_end = esp_timer_get_time();
|
uint64_t fr_end = esp_timer_get_time();
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "BMP: %llums, %uB", (uint64_t)((fr_end - fr_start) / 1000), buf_len);
|
log_i("BMP: %llums, %uB", (uint64_t)((fr_end - fr_start) / 1000), buf_len);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +358,7 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
int64_t fr_start = esp_timer_get_time();
|
int64_t fr_start = esp_timer_get_time();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
enable_led(true);
|
enable_led(true);
|
||||||
vTaskDelay(150 / portTICK_PERIOD_MS); // The LED needs to be turned on ~150ms before the call to esp_camera_fb_get()
|
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.
|
fb = esp_camera_fb_get(); // or it won't be visible in the frame. A better way to do this is needed.
|
||||||
|
|
@ -368,7 +369,7 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
|
|
||||||
if (!fb)
|
if (!fb)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Camera capture failed");
|
log_e("Camera capture failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
@ -415,7 +416,7 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
int64_t fr_end = esp_timer_get_time();
|
int64_t fr_end = esp_timer_get_time();
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "JPG: %uB %ums", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start) / 1000));
|
log_i("JPG: %uB %ums", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start) / 1000));
|
||||||
return res;
|
return res;
|
||||||
#if CONFIG_ESP_FACE_DETECT_ENABLED
|
#if CONFIG_ESP_FACE_DETECT_ENABLED
|
||||||
}
|
}
|
||||||
|
|
@ -457,7 +458,7 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
out_height = fb->height;
|
out_height = fb->height;
|
||||||
out_buf = (uint8_t*)malloc(out_len);
|
out_buf = (uint8_t*)malloc(out_len);
|
||||||
if (!out_buf) {
|
if (!out_buf) {
|
||||||
ESP_LOGE(TAG, "out_buf malloc failed");
|
log_e("out_buf malloc failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
@ -465,7 +466,7 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
free(out_buf);
|
free(out_buf);
|
||||||
ESP_LOGE(TAG, "to rgb888 failed");
|
log_e("To rgb888 failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
@ -504,14 +505,14 @@ static esp_err_t capture_handler(httpd_req_t *req)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
ESP_LOGE(TAG, "JPEG compression failed");
|
log_e("JPEG compression failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
int64_t fr_end = esp_timer_get_time();
|
int64_t fr_end = esp_timer_get_time();
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "FACE: %uB %ums %s%d", (uint32_t)(jchunk.len), (uint32_t)((fr_end - fr_start) / 1000), detected ? "DETECTED " : "", face_id);
|
log_i("FACE: %uB %ums %s%d", (uint32_t)(jchunk.len), (uint32_t)((fr_end - fr_start) / 1000), detected ? "DETECTED " : "", face_id);
|
||||||
return res;
|
return res;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -560,7 +561,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_set_hdr(req, "X-Framerate", "60");
|
httpd_resp_set_hdr(req, "X-Framerate", "60");
|
||||||
|
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
enable_led(true);
|
enable_led(true);
|
||||||
isStreaming = true;
|
isStreaming = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -577,7 +578,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
if (!fb)
|
if (!fb)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Camera capture failed");
|
log_e("Camera capture failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -602,7 +603,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
if (!jpeg_converted)
|
if (!jpeg_converted)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "JPEG compression failed");
|
log_e("JPEG compression failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -649,7 +650,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
ESP_LOGE(TAG, "fmt2jpg failed");
|
log_e("fmt2jpg failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
}
|
}
|
||||||
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
|
|
@ -662,7 +663,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
out_height = fb->height;
|
out_height = fb->height;
|
||||||
out_buf = (uint8_t*)malloc(out_len);
|
out_buf = (uint8_t*)malloc(out_len);
|
||||||
if (!out_buf) {
|
if (!out_buf) {
|
||||||
ESP_LOGE(TAG, "out_buf malloc failed");
|
log_e("out_buf malloc failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
} else {
|
} else {
|
||||||
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
|
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
|
||||||
|
|
@ -670,7 +671,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
free(out_buf);
|
free(out_buf);
|
||||||
ESP_LOGE(TAG, "to rgb888 failed");
|
log_e("To rgb888 failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
} else {
|
} else {
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
|
|
@ -713,7 +714,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
s = fmt2jpg(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len);
|
s = fmt2jpg(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len);
|
||||||
free(out_buf);
|
free(out_buf);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
ESP_LOGE(TAG, "fmt2jpg failed");
|
log_e("fmt2jpg failed");
|
||||||
res = ESP_FAIL;
|
res = ESP_FAIL;
|
||||||
}
|
}
|
||||||
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if CONFIG_ESP_FACE_DETECT_ENABLED && ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
|
|
@ -751,7 +752,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
}
|
}
|
||||||
if (res != ESP_OK)
|
if (res != ESP_OK)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "send frame failed failed");
|
log_e("Send frame failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int64_t fr_end = esp_timer_get_time();
|
int64_t fr_end = esp_timer_get_time();
|
||||||
|
|
@ -769,7 +770,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||||
uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time);
|
uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time);
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "MJPG: %uB %ums (%.1ffps), AVG: %ums (%.1ffps)"
|
log_i("MJPG: %uB %ums (%.1ffps), AVG: %ums (%.1ffps)"
|
||||||
#if CONFIG_ESP_FACE_DETECT_ENABLED
|
#if CONFIG_ESP_FACE_DETECT_ENABLED
|
||||||
", %u+%u+%u+%u=%u %s%d"
|
", %u+%u+%u+%u=%u %s%d"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -785,7 +786,7 @@ static esp_err_t stream_handler(httpd_req_t *req)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
isStreaming = false;
|
isStreaming = false;
|
||||||
enable_led(false);
|
enable_led(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -833,7 +834,7 @@ static esp_err_t cmd_handler(httpd_req_t *req)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
int val = atoi(value);
|
int val = atoi(value);
|
||||||
ESP_LOGI(TAG, "%s = %d", variable, val);
|
log_i("%s = %d", variable, val);
|
||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
|
@ -888,7 +889,7 @@ static esp_err_t cmd_handler(httpd_req_t *req)
|
||||||
res = s->set_wb_mode(s, val);
|
res = s->set_wb_mode(s, val);
|
||||||
else if (!strcmp(variable, "ae_level"))
|
else if (!strcmp(variable, "ae_level"))
|
||||||
res = s->set_ae_level(s, val);
|
res = s->set_ae_level(s, val);
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
else if (!strcmp(variable, "led_intensity")) {
|
else if (!strcmp(variable, "led_intensity")) {
|
||||||
led_duty = val;
|
led_duty = val;
|
||||||
if (isStreaming)
|
if (isStreaming)
|
||||||
|
|
@ -908,7 +909,7 @@ static esp_err_t cmd_handler(httpd_req_t *req)
|
||||||
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
|
#if CONFIG_ESP_FACE_RECOGNITION_ENABLED
|
||||||
else if (!strcmp(variable, "face_enroll")){
|
else if (!strcmp(variable, "face_enroll")){
|
||||||
is_enrolling = !is_enrolling;
|
is_enrolling = !is_enrolling;
|
||||||
ESP_LOGI(TAG, "Enrolling: %s", is_enrolling?"true":"false");
|
log_i("Enrolling: %s", is_enrolling?"true":"false");
|
||||||
}
|
}
|
||||||
else if (!strcmp(variable, "face_recognize")) {
|
else if (!strcmp(variable, "face_recognize")) {
|
||||||
recognition_enabled = val;
|
recognition_enabled = val;
|
||||||
|
|
@ -919,7 +920,7 @@ static esp_err_t cmd_handler(httpd_req_t *req)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
ESP_LOGI(TAG, "Unknown command: %s", variable);
|
log_i("Unknown command: %s", variable);
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -998,7 +999,7 @@ static esp_err_t status_handler(httpd_req_t *req)
|
||||||
p += sprintf(p, "\"hmirror\":%u,", s->status.hmirror);
|
p += sprintf(p, "\"hmirror\":%u,", s->status.hmirror);
|
||||||
p += sprintf(p, "\"dcw\":%u,", s->status.dcw);
|
p += sprintf(p, "\"dcw\":%u,", s->status.dcw);
|
||||||
p += sprintf(p, "\"colorbar\":%u", s->status.colorbar);
|
p += sprintf(p, "\"colorbar\":%u", s->status.colorbar);
|
||||||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
p += sprintf(p, ",\"led_intensity\":%u", led_duty);
|
p += sprintf(p, ",\"led_intensity\":%u", led_duty);
|
||||||
#else
|
#else
|
||||||
p += sprintf(p, ",\"led_intensity\":%d", -1);
|
p += sprintf(p, ",\"led_intensity\":%d", -1);
|
||||||
|
|
@ -1033,7 +1034,7 @@ static esp_err_t xclk_handler(httpd_req_t *req)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
int xclk = atoi(_xclk);
|
int xclk = atoi(_xclk);
|
||||||
ESP_LOGI(TAG, "Set XCLK: %d MHz", xclk);
|
log_i("Set XCLK: %d MHz", xclk);
|
||||||
|
|
||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
int res = s->set_xclk(s, LEDC_TIMER_0, xclk);
|
int res = s->set_xclk(s, LEDC_TIMER_0, xclk);
|
||||||
|
|
@ -1067,7 +1068,7 @@ static esp_err_t reg_handler(httpd_req_t *req)
|
||||||
int reg = atoi(_reg);
|
int reg = atoi(_reg);
|
||||||
int mask = atoi(_mask);
|
int mask = atoi(_mask);
|
||||||
int val = atoi(_val);
|
int val = atoi(_val);
|
||||||
ESP_LOGI(TAG, "Set Register: reg: 0x%02x, mask: 0x%02x, value: 0x%02x", reg, mask, val);
|
log_i("Set Register: reg: 0x%02x, mask: 0x%02x, value: 0x%02x", reg, mask, val);
|
||||||
|
|
||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
int res = s->set_reg(s, reg, mask, val);
|
int res = s->set_reg(s, reg, mask, val);
|
||||||
|
|
@ -1103,7 +1104,7 @@ static esp_err_t greg_handler(httpd_req_t *req)
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return httpd_resp_send_500(req);
|
return httpd_resp_send_500(req);
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Get Register: reg: 0x%02x, mask: 0x%02x, value: 0x%02x", reg, mask, res);
|
log_i("Get Register: reg: 0x%02x, mask: 0x%02x, value: 0x%02x", reg, mask, res);
|
||||||
|
|
||||||
char buffer[20];
|
char buffer[20];
|
||||||
const char * val = itoa(res, buffer, 10);
|
const char * val = itoa(res, buffer, 10);
|
||||||
|
|
@ -1138,7 +1139,7 @@ static esp_err_t pll_handler(httpd_req_t *req)
|
||||||
int pclk = parse_get_var(buf, "pclk", 0);
|
int pclk = parse_get_var(buf, "pclk", 0);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Set Pll: bypass: %d, mul: %d, sys: %d, root: %d, pre: %d, seld5: %d, pclken: %d, pclk: %d", bypass, mul, sys, root, pre, seld5, pclken, pclk);
|
log_i("Set Pll: bypass: %d, mul: %d, sys: %d, root: %d, pre: %d, seld5: %d, pclken: %d, pclk: %d", bypass, mul, sys, root, pre, seld5, pclken, pclk);
|
||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
int res = s->set_pll(s, bypass, mul, sys, root, pre, seld5, pclken, pclk);
|
int res = s->set_pll(s, bypass, mul, sys, root, pre, seld5, pclken, pclk);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
@ -1171,7 +1172,7 @@ static esp_err_t win_handler(httpd_req_t *req)
|
||||||
bool binning = parse_get_var(buf, "binning", 0) == 1;
|
bool binning = parse_get_var(buf, "binning", 0) == 1;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Set Window: Start: %d %d, End: %d %d, Offset: %d %d, Total: %d %d, Output: %d %d, Scale: %u, Binning: %u", startX, startY, endX, endY, offsetX, offsetY, totalX, totalY, outputX, outputY, scale, binning);
|
log_i("Set Window: Start: %d %d, End: %d %d, Offset: %d %d, Total: %d %d, Output: %d %d, Scale: %u, Binning: %u", startX, startY, endX, endY, offsetX, offsetY, totalX, totalY, outputX, outputY, scale, binning);
|
||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
int res = s->set_res_raw(s, startX, startY, endX, endY, offsetX, offsetY, totalX, totalY, outputX, outputY, scale, binning);
|
int res = s->set_res_raw(s, startX, startY, endX, endY, offsetX, offsetY, totalX, totalY, outputX, outputY, scale, binning);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
@ -1196,7 +1197,7 @@ static esp_err_t index_handler(httpd_req_t *req)
|
||||||
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len);
|
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAG, "Camera sensor not found");
|
log_e("Camera sensor not found");
|
||||||
return httpd_resp_send_500(req);
|
return httpd_resp_send_500(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1357,7 +1358,7 @@ void startCameraServer()
|
||||||
// load ids from flash partition
|
// load ids from flash partition
|
||||||
recognizer.set_ids_from_flash();
|
recognizer.set_ids_from_flash();
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG, "Starting web server on port: '%d'", config.server_port);
|
log_i("Starting web server on port: '%d'", config.server_port);
|
||||||
if (httpd_start(&camera_httpd, &config) == ESP_OK)
|
if (httpd_start(&camera_httpd, &config) == ESP_OK)
|
||||||
{
|
{
|
||||||
httpd_register_uri_handler(camera_httpd, &index_uri);
|
httpd_register_uri_handler(camera_httpd, &index_uri);
|
||||||
|
|
@ -1375,9 +1376,19 @@ void startCameraServer()
|
||||||
|
|
||||||
config.server_port += 1;
|
config.server_port += 1;
|
||||||
config.ctrl_port += 1;
|
config.ctrl_port += 1;
|
||||||
ESP_LOGI(TAG, "Starting stream server on port: '%d'", config.server_port);
|
log_i("Starting stream server on port: '%d'", config.server_port);
|
||||||
if (httpd_start(&stream_httpd, &config) == ESP_OK)
|
if (httpd_start(&stream_httpd, &config) == ESP_OK)
|
||||||
{
|
{
|
||||||
httpd_register_uri_handler(stream_httpd, &stream_uri);
|
httpd_register_uri_handler(stream_httpd, &stream_uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupLedFlash(int pin)
|
||||||
|
{
|
||||||
|
#if CONFIG_LED_ILLUMINATOR_ENABLED
|
||||||
|
ledcSetup(LED_LEDC_CHANNEL, 5000, 8);
|
||||||
|
ledcAttachPin(pin, LED_LEDC_CHANNEL);
|
||||||
|
#else
|
||||||
|
log_i("LED flash is disabled -> CONFIG_LED_ILLUMINATOR_ENABLED = 0");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@
|
||||||
#define HREF_GPIO_NUM 27
|
#define HREF_GPIO_NUM 27
|
||||||
#define PCLK_GPIO_NUM 25
|
#define PCLK_GPIO_NUM 25
|
||||||
|
|
||||||
|
#define LED_GPIO_NUM 22
|
||||||
|
|
||||||
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
|
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
|
||||||
#define PWDN_GPIO_NUM -1
|
#define PWDN_GPIO_NUM -1
|
||||||
#define RESET_GPIO_NUM 15
|
#define RESET_GPIO_NUM 15
|
||||||
|
|
@ -94,6 +96,8 @@
|
||||||
#define HREF_GPIO_NUM 26
|
#define HREF_GPIO_NUM 26
|
||||||
#define PCLK_GPIO_NUM 21
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#define LED_GPIO_NUM 2
|
||||||
|
|
||||||
#elif defined(CAMERA_MODEL_M5STACK_ESP32CAM)
|
#elif defined(CAMERA_MODEL_M5STACK_ESP32CAM)
|
||||||
#define PWDN_GPIO_NUM -1
|
#define PWDN_GPIO_NUM -1
|
||||||
#define RESET_GPIO_NUM 15
|
#define RESET_GPIO_NUM 15
|
||||||
|
|
@ -151,6 +155,8 @@
|
||||||
#define HREF_GPIO_NUM 23
|
#define HREF_GPIO_NUM 23
|
||||||
#define PCLK_GPIO_NUM 22
|
#define PCLK_GPIO_NUM 22
|
||||||
|
|
||||||
|
#define LED_GPIO_NUM 33
|
||||||
|
|
||||||
#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL)
|
#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL)
|
||||||
#define PWDN_GPIO_NUM 0
|
#define PWDN_GPIO_NUM 0
|
||||||
#define RESET_GPIO_NUM 15
|
#define RESET_GPIO_NUM 15
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue