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));
53 " Data Pins: D0:%d D1:%d D2:%d D3:%d D4:%d D5:%d D6:%d D7:%d\n"
56 " Pixel Clock Pin: %d\n"
57 " External Clock: Pin:%d Frequency:%u\n"
58 " I2C Pins: SDA:%d SCL:%d\n"
61 conf.pin_d4, conf.pin_d5, conf.pin_d6, conf.pin_d7, conf.pin_vsync, conf.pin_href, conf.pin_pclk,
62 conf.pin_xclk, conf.xclk_freq_hz, conf.pin_sccb_sda, conf.pin_sccb_scl, conf.pin_reset);
63 switch (this->
config_.frame_size) {
65 ESP_LOGCONFIG(TAG,
" Resolution: 160x120 (QQVGA)");
68 ESP_LOGCONFIG(TAG,
" Resolution: 176x155 (QCIF)");
71 ESP_LOGCONFIG(TAG,
" Resolution: 240x176 (HQVGA)");
74 ESP_LOGCONFIG(TAG,
" Resolution: 320x240 (QVGA)");
77 ESP_LOGCONFIG(TAG,
" Resolution: 400x296 (CIF)");
80 ESP_LOGCONFIG(TAG,
" Resolution: 640x480 (VGA)");
83 ESP_LOGCONFIG(TAG,
" Resolution: 800x600 (SVGA)");
86 ESP_LOGCONFIG(TAG,
" Resolution: 1024x768 (XGA)");
89 ESP_LOGCONFIG(TAG,
" Resolution: 1280x1024 (SXGA)");
92 ESP_LOGCONFIG(TAG,
" Resolution: 1600x1200 (UXGA)");
95 ESP_LOGCONFIG(TAG,
" Resolution: 1920x1080 (FHD)");
98 ESP_LOGCONFIG(TAG,
" Resolution: 720x1280 (P_HD)");
100 case FRAMESIZE_P_3MP:
101 ESP_LOGCONFIG(TAG,
" Resolution: 864x1536 (P_3MP)");
104 ESP_LOGCONFIG(TAG,
" Resolution: 2048x1536 (QXGA)");
107 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1440 (QHD)");
109 case FRAMESIZE_WQXGA:
110 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1600 (WQXGA)");
112 case FRAMESIZE_P_FHD:
113 ESP_LOGCONFIG(TAG,
" Resolution: 1080x1920 (P_FHD)");
115 case FRAMESIZE_QSXGA:
116 ESP_LOGCONFIG(TAG,
" Resolution: 2560x1920 (QSXGA)");
123 ESP_LOGE(TAG,
" Setup Failed: %s", esp_err_to_name(this->
init_error_));
127 sensor_t *s = esp_camera_sensor_get();
130 " JPEG Quality: %u\n"
131 " Framebuffer Count: %u\n"
135 " Vertical Flip: %s\n"
136 " Horizontal Mirror: %s\n"
137 " Special Effect: %u\n"
138 " White Balance Mode: %u",
139 st.quality, conf.fb_count, st.contrast, st.brightness, st.saturation, ONOFF(st.vflip),
140 ONOFF(st.hmirror), st.special_effect, st.wb_mode);
144 " Auto Exposure Control: %u\n"
145 " Auto Exposure Control 2: %u\n"
146 " Auto Exposure Level: %d\n"
147 " Auto Exposure Value: %u\n"
151 st.aec, st.aec2, st.ae_level, st.aec_value, st.agc, st.agc_gain, st.gainceiling);
157 ESP_LOGCONFIG(TAG,
" Test Pattern: %s", YESNO(st.colorbar));
190 ESP_LOGVV(TAG,
"No frame ready");
195 ESP_LOGW(TAG,
"Got invalid frame from camera!");
201 ESP_LOGD(TAG,
"Got Image: len=%u", fb->len);
214 this->
config_.ledc_timer = LEDC_TIMER_0;
215 this->
config_.ledc_channel = LEDC_CHANNEL_0;
216 this->
config_.pixel_format = PIXFORMAT_JPEG;
217 this->
config_.frame_size = FRAMESIZE_VGA;
218 this->
config_.jpeg_quality = 10;
220 this->
config_.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
221 this->
config_.fb_location = CAMERA_FB_IN_PSRAM;
229 this->
config_.pin_d0 = pins[0];
230 this->
config_.pin_d1 = pins[1];
231 this->
config_.pin_d2 = pins[2];
232 this->
config_.pin_d3 = pins[3];
233 this->
config_.pin_d4 = pins[4];
234 this->
config_.pin_d5 = pins[5];
235 this->
config_.pin_d6 = pins[6];
236 this->
config_.pin_d7 = pins[7];
246 this->
config_.pin_sccb_sda = sda;
247 this->
config_.pin_sccb_scl = scl;
256 this->
config_.frame_size = FRAMESIZE_QQVGA;
259 this->
config_.frame_size = FRAMESIZE_QCIF;
262 this->
config_.frame_size = FRAMESIZE_HQVGA;
265 this->
config_.frame_size = FRAMESIZE_QVGA;
268 this->
config_.frame_size = FRAMESIZE_CIF;
271 this->
config_.frame_size = FRAMESIZE_VGA;
274 this->
config_.frame_size = FRAMESIZE_SVGA;
277 this->
config_.frame_size = FRAMESIZE_XGA;
280 this->
config_.frame_size = FRAMESIZE_SXGA;
283 this->
config_.frame_size = FRAMESIZE_UXGA;
286 this->
config_.frame_size = FRAMESIZE_FHD;
289 this->
config_.frame_size = FRAMESIZE_P_HD;
292 this->
config_.frame_size = FRAMESIZE_P_3MP;
295 this->
config_.frame_size = FRAMESIZE_QXGA;
298 this->
config_.frame_size = FRAMESIZE_QHD;
301 this->
config_.frame_size = FRAMESIZE_WQXGA;
304 this->
config_.frame_size = FRAMESIZE_P_FHD;
307 this->
config_.frame_size = FRAMESIZE_QSXGA;
341 this->
config_.fb_count = fb_count;
365 sensor_t *s = esp_camera_sensor_get();
374 s->set_exposure_ctrl(s, (
bool) this->
aec_mode_);
375 s->set_aec2(s, this->
aec2_);
379 s->set_gain_ctrl(s, (
bool) this->
agc_mode_);
383 s->set_wb_mode(s, (
int) this->
wb_mode_);
393 camera_fb_t *framebuffer = esp_camera_fb_get();
397 esp_camera_fb_return(framebuffer);
405 this->
image_ = std::move(image);
425 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.