8#include <freertos/task.h>
11namespace esp32_camera {
13static const char *
const TAG =
"esp32_camera";
23 esp_err_t err = esp_camera_init(&this->
config_);
25 ESP_LOGE(TAG,
"esp_camera_init failed: %s", esp_err_to_name(err));
49 ESP_LOGCONFIG(TAG,
"ESP32 Camera:");
50 ESP_LOGCONFIG(TAG,
" Name: %s", this->
name_.
c_str());
51 ESP_LOGCONFIG(TAG,
" Internal: %s", YESNO(this->
internal_));
52 ESP_LOGCONFIG(TAG,
" Data Pins: D0:%d D1:%d D2:%d D3:%d D4:%d D5:%d D6:%d D7:%d", conf.pin_d0, conf.pin_d1,
53 conf.pin_d2, conf.pin_d3, conf.pin_d4, conf.pin_d5, conf.pin_d6, conf.pin_d7);
54 ESP_LOGCONFIG(TAG,
" VSYNC Pin: %d", conf.pin_vsync);
55 ESP_LOGCONFIG(TAG,
" HREF Pin: %d", conf.pin_href);
56 ESP_LOGCONFIG(TAG,
" Pixel Clock Pin: %d", conf.pin_pclk);
57 ESP_LOGCONFIG(TAG,
" External Clock: Pin:%d Frequency:%u", conf.pin_xclk, conf.xclk_freq_hz);
58 ESP_LOGCONFIG(TAG,
" I2C Pins: SDA:%d SCL:%d", conf.pin_sccb_sda, conf.pin_sccb_scl);
59 ESP_LOGCONFIG(TAG,
" Reset Pin: %d", conf.pin_reset);
60 switch (this->
config_.frame_size) {
62 ESP_LOGCONFIG(TAG,
" Resolution: 160x120 (QQVGA)");
65 ESP_LOGCONFIG(TAG,
" Resolution: 176x155 (QCIF)");
68 ESP_LOGCONFIG(TAG,
" Resolution: 240x176 (HQVGA)");
71 ESP_LOGCONFIG(TAG,
" Resolution: 320x240 (QVGA)");
74 ESP_LOGCONFIG(TAG,
" Resolution: 400x296 (CIF)");
77 ESP_LOGCONFIG(TAG,
" Resolution: 640x480 (VGA)");
80 ESP_LOGCONFIG(TAG,
" Resolution: 800x600 (SVGA)");
83 ESP_LOGCONFIG(TAG,
" Resolution: 1024x768 (XGA)");
86 ESP_LOGCONFIG(TAG,
" Resolution: 1280x1024 (SXGA)");
89 ESP_LOGCONFIG(TAG,
" Resolution: 1600x1200 (UXGA)");
92 ESP_LOGCONFIG(TAG,
" Resolution: 1920x1080 (FHD)");
95 ESP_LOGCONFIG(TAG,
" Resolution: 720x1280 (P_HD)");
98 ESP_LOGCONFIG(TAG,
" Resolution: 864x1536 (P_3MP)");
101 ESP_LOGCONFIG(TAG,
" Resolution: 2048x1536 (QXGA)");
104 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1440 (QHD)");
106 case FRAMESIZE_WQXGA:
107 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1600 (WQXGA)");
109 case FRAMESIZE_P_FHD:
110 ESP_LOGCONFIG(TAG,
" Resolution: 1080x1920 (P_FHD)");
112 case FRAMESIZE_QSXGA:
113 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1920 (QSXGA)");
120 ESP_LOGE(TAG,
" Setup Failed: %s", esp_err_to_name(this->
init_error_));
124 sensor_t *s = esp_camera_sensor_get();
126 ESP_LOGCONFIG(TAG,
" JPEG Quality: %u", st.quality);
127 ESP_LOGCONFIG(TAG,
" Framebuffer Count: %u", conf.fb_count);
128 ESP_LOGCONFIG(TAG,
" Contrast: %d", st.contrast);
129 ESP_LOGCONFIG(TAG,
" Brightness: %d", st.brightness);
130 ESP_LOGCONFIG(TAG,
" Saturation: %d", st.saturation);
131 ESP_LOGCONFIG(TAG,
" Vertical Flip: %s", ONOFF(st.vflip));
132 ESP_LOGCONFIG(TAG,
" Horizontal Mirror: %s", ONOFF(st.hmirror));
133 ESP_LOGCONFIG(TAG,
" Special Effect: %u", st.special_effect);
134 ESP_LOGCONFIG(TAG,
" White Balance Mode: %u", st.wb_mode);
137 ESP_LOGCONFIG(TAG,
" Auto Exposure Control: %u", st.aec);
138 ESP_LOGCONFIG(TAG,
" Auto Exposure Control 2: %u", st.aec2);
139 ESP_LOGCONFIG(TAG,
" Auto Exposure Level: %d", st.ae_level);
140 ESP_LOGCONFIG(TAG,
" Auto Exposure Value: %u", st.aec_value);
141 ESP_LOGCONFIG(TAG,
" AGC: %u", st.agc);
142 ESP_LOGCONFIG(TAG,
" AGC Gain: %u", st.agc_gain);
143 ESP_LOGCONFIG(TAG,
" Gain Ceiling: %u", st.gainceiling);
149 ESP_LOGCONFIG(TAG,
" Test Pattern: %s", YESNO(st.colorbar));
182 ESP_LOGVV(TAG,
"No frame ready");
187 ESP_LOGW(TAG,
"Got invalid frame from camera!");
193 ESP_LOGD(TAG,
"Got Image: len=%u", fb->len);
206 this->
config_.ledc_timer = LEDC_TIMER_0;
207 this->
config_.ledc_channel = LEDC_CHANNEL_0;
208 this->
config_.pixel_format = PIXFORMAT_JPEG;
209 this->
config_.frame_size = FRAMESIZE_VGA;
210 this->
config_.jpeg_quality = 10;
212 this->
config_.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
213 this->
config_.fb_location = CAMERA_FB_IN_PSRAM;
221 this->
config_.pin_d0 = pins[0];
222 this->
config_.pin_d1 = pins[1];
223 this->
config_.pin_d2 = pins[2];
224 this->
config_.pin_d3 = pins[3];
225 this->
config_.pin_d4 = pins[4];
226 this->
config_.pin_d5 = pins[5];
227 this->
config_.pin_d6 = pins[6];
228 this->
config_.pin_d7 = pins[7];
238 this->
config_.pin_sccb_sda = sda;
239 this->
config_.pin_sccb_scl = scl;
248 this->
config_.frame_size = FRAMESIZE_QQVGA;
251 this->
config_.frame_size = FRAMESIZE_QCIF;
254 this->
config_.frame_size = FRAMESIZE_HQVGA;
257 this->
config_.frame_size = FRAMESIZE_QVGA;
260 this->
config_.frame_size = FRAMESIZE_CIF;
263 this->
config_.frame_size = FRAMESIZE_VGA;
266 this->
config_.frame_size = FRAMESIZE_SVGA;
269 this->
config_.frame_size = FRAMESIZE_XGA;
272 this->
config_.frame_size = FRAMESIZE_SXGA;
275 this->
config_.frame_size = FRAMESIZE_UXGA;
278 this->
config_.frame_size = FRAMESIZE_FHD;
281 this->
config_.frame_size = FRAMESIZE_P_HD;
284 this->
config_.frame_size = FRAMESIZE_P_3MP;
287 this->
config_.frame_size = FRAMESIZE_QXGA;
290 this->
config_.frame_size = FRAMESIZE_QHD;
293 this->
config_.frame_size = FRAMESIZE_WQXGA;
296 this->
config_.frame_size = FRAMESIZE_P_FHD;
299 this->
config_.frame_size = FRAMESIZE_QSXGA;
333 this->
config_.fb_count = fb_count;
357 sensor_t *s = esp_camera_sensor_get();
366 s->set_exposure_ctrl(s, (
bool) this->
aec_mode_);
367 s->set_aec2(s, this->
aec2_);
371 s->set_gain_ctrl(s, (
bool) this->
agc_mode_);
375 s->set_wb_mode(s, (
int) this->
wb_mode_);
385 camera_fb_t *framebuffer = esp_camera_fb_get();
389 esp_camera_fb_return(framebuffer);
397 this->
image_ = std::move(image);
417 return (this->
requesters_ & (1 << requester)) != 0;
BedjetMode mode
BedJet operating mode.
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
virtual void mark_failed()
Mark this component as failed.
constexpr const char * c_str() const
camera_fb_t * get_raw_buffer()
bool was_requested_by(CameraRequester requester) const
CameraImage(camera_fb_t *buffer, uint8_t requester)
uint8_t * get_data_buffer()
std::shared_ptr< CameraImage > image_
uint8_t * peek_data_buffer()
void consume_data(size_t consumed)
void set_image(std::shared_ptr< CameraImage > image)
void set_i2c_pins(uint8_t sda, uint8_t scl)
void set_agc_value(uint8_t agc_value)
void set_test_pattern(bool test_pattern)
std::shared_ptr< CameraImage > current_image_
void set_jpeg_quality(uint8_t quality)
CallbackManager< void(std::shared_ptr< CameraImage >)> new_image_callback_
void set_wb_mode(ESP32WhiteBalanceMode mode)
ESP32AgcGainCeiling agc_gain_ceiling_
void add_image_callback(std::function< void(std::shared_ptr< CameraImage >)> &&callback)
void set_vertical_flip(bool vertical_flip)
void set_aec_value(uint32_t aec_value)
QueueHandle_t framebuffer_return_queue_
void request_image(CameraRequester requester)
void set_contrast(int contrast)
void set_special_effect(ESP32SpecialEffect effect)
void set_aec_mode(ESP32GainControlMode mode)
QueueHandle_t framebuffer_get_queue_
uint32_t last_idle_request_
CallbackManager< void()> stream_stop_callback_
float get_setup_priority() const override
uint8_t stream_requesters_
void set_data_pins(std::array< uint8_t, 8 > pins)
void add_stream_start_callback(std::function< void()> &&callback)
ESP32GainControlMode agc_mode_
ESP32WhiteBalanceMode wb_mode_
void set_pixel_clock_pin(uint8_t pin)
void set_frame_size(ESP32CameraFrameSize size)
void set_brightness(int brightness)
void set_external_clock(uint8_t pin, uint32_t frequency)
uint32_t idle_update_interval_
bool has_requested_image_() const
bool can_return_image_() const
void set_vsync_pin(uint8_t pin)
void set_ae_level(int ae_level)
void set_max_update_interval(uint32_t max_update_interval)
void add_stream_stop_callback(std::function< void()> &&callback)
uint32_t max_update_interval_
ESP32GainControlMode aec_mode_
void stop_stream(CameraRequester requester)
void set_horizontal_mirror(bool horizontal_mirror)
void dump_config() override
void set_frame_buffer_count(uint8_t fb_count)
ESP32SpecialEffect special_effect_
uint8_t single_requesters_
void set_agc_gain_ceiling(ESP32AgcGainCeiling gain_ceiling)
void set_saturation(int saturation)
void set_href_pin(uint8_t pin)
void set_agc_mode(ESP32GainControlMode mode)
void set_frame_buffer_mode(camera_grab_mode_t mode)
void set_idle_update_interval(uint32_t idle_update_interval)
CallbackManager< void()> stream_start_callback_
void set_reset_pin(uint8_t pin)
void update_camera_parameters()
void start_stream(CameraRequester requester)
void set_power_down_pin(uint8_t pin)
static void framebuffer_task(void *pv)
@ ESP32_CAMERA_SIZE_240X176
@ ESP32_CAMERA_SIZE_640X480
@ ESP32_CAMERA_SIZE_1600X1200
@ ESP32_CAMERA_SIZE_2560X1600
@ ESP32_CAMERA_SIZE_160X120
@ ESP32_CAMERA_SIZE_400X296
@ ESP32_CAMERA_SIZE_176X144
@ ESP32_CAMERA_SIZE_1280X1024
@ ESP32_CAMERA_SIZE_320X240
@ ESP32_CAMERA_SIZE_2560X1440
@ ESP32_CAMERA_SIZE_720X1280
@ ESP32_CAMERA_SIZE_2048X1536
@ ESP32_CAMERA_SIZE_2560X1920
@ ESP32_CAMERA_SIZE_800X600
@ ESP32_CAMERA_SIZE_1080X1920
@ ESP32_CAMERA_SIZE_1920X1080
@ ESP32_CAMERA_SIZE_1024X768
@ ESP32_CAMERA_SIZE_864X1536
ESP32Camera * global_esp32_camera
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.