mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
ESP32 CAM add Automatic Exposure Control option (#2892)
Co-authored-by: Peter <psv@tsat.net> Co-authored-by: Carlos Garcia Saura <CarlosGS@users.noreply.github.com>
This commit is contained in:
parent
5d70ff702b
commit
192eb49589
3 changed files with 24 additions and 3 deletions
|
@ -57,6 +57,9 @@ CONF_IDLE_FRAMERATE = "idle_framerate"
|
|||
CONF_JPEG_QUALITY = "jpeg_quality"
|
||||
CONF_VERTICAL_FLIP = "vertical_flip"
|
||||
CONF_HORIZONTAL_MIRROR = "horizontal_mirror"
|
||||
CONF_AEC2 = "aec2"
|
||||
CONF_AE_LEVEL = "ae_level"
|
||||
CONF_AEC_VALUE = "aec_value"
|
||||
CONF_SATURATION = "saturation"
|
||||
CONF_TEST_PATTERN = "test_pattern"
|
||||
|
||||
|
@ -102,6 +105,9 @@ CONFIG_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
|
|||
cv.Optional(CONF_SATURATION, default=0): camera_range_param,
|
||||
cv.Optional(CONF_VERTICAL_FLIP, default=True): cv.boolean,
|
||||
cv.Optional(CONF_HORIZONTAL_MIRROR, default=True): cv.boolean,
|
||||
cv.Optional(CONF_AEC2, default=False): cv.boolean,
|
||||
cv.Optional(CONF_AE_LEVEL, default=0): camera_range_param,
|
||||
cv.Optional(CONF_AEC_VALUE, default=300): cv.int_range(min=0, max=1200),
|
||||
cv.Optional(CONF_TEST_PATTERN, default=False): cv.boolean,
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
@ -116,6 +122,9 @@ SETTERS = {
|
|||
CONF_JPEG_QUALITY: "set_jpeg_quality",
|
||||
CONF_VERTICAL_FLIP: "set_vertical_flip",
|
||||
CONF_HORIZONTAL_MIRROR: "set_horizontal_mirror",
|
||||
CONF_AEC2: "set_aec2",
|
||||
CONF_AE_LEVEL: "set_ae_level",
|
||||
CONF_AEC_VALUE: "set_aec_value",
|
||||
CONF_CONTRAST: "set_contrast",
|
||||
CONF_BRIGHTNESS: "set_brightness",
|
||||
CONF_SATURATION: "set_saturation",
|
||||
|
|
|
@ -26,6 +26,9 @@ void ESP32Camera::setup() {
|
|||
sensor_t *s = esp_camera_sensor_get();
|
||||
s->set_vflip(s, this->vertical_flip_);
|
||||
s->set_hmirror(s, this->horizontal_mirror_);
|
||||
s->set_aec2(s, this->aec2_); // 0 = disable , 1 = enable
|
||||
s->set_ae_level(s, this->ae_level_); // -2 to 2
|
||||
s->set_aec_value(s, this->aec_value_); // 0 to 1200
|
||||
s->set_contrast(s, this->contrast_);
|
||||
s->set_brightness(s, this->brightness_);
|
||||
s->set_saturation(s, this->saturation_);
|
||||
|
@ -111,9 +114,9 @@ void ESP32Camera::dump_config() {
|
|||
// ESP_LOGCONFIG(TAG, " Auto White Balance: %u", st.awb);
|
||||
// ESP_LOGCONFIG(TAG, " Auto White Balance Gain: %u", st.awb_gain);
|
||||
// ESP_LOGCONFIG(TAG, " Auto Exposure Control: %u", st.aec);
|
||||
// ESP_LOGCONFIG(TAG, " Auto Exposure Control 2: %u", st.aec2);
|
||||
// ESP_LOGCONFIG(TAG, " Auto Exposure Level: %d", st.ae_level);
|
||||
// ESP_LOGCONFIG(TAG, " Auto Exposure Value: %u", st.aec_value);
|
||||
ESP_LOGCONFIG(TAG, " Auto Exposure Control 2: %u", st.aec2);
|
||||
ESP_LOGCONFIG(TAG, " Auto Exposure Level: %d", st.ae_level);
|
||||
ESP_LOGCONFIG(TAG, " Auto Exposure Value: %u", st.aec_value);
|
||||
// ESP_LOGCONFIG(TAG, " AGC: %u", st.agc);
|
||||
// ESP_LOGCONFIG(TAG, " AGC Gain: %u", st.agc_gain);
|
||||
// ESP_LOGCONFIG(TAG, " Gain Ceiling: %u", st.gainceiling);
|
||||
|
@ -250,6 +253,9 @@ void ESP32Camera::add_image_callback(std::function<void(std::shared_ptr<CameraIm
|
|||
}
|
||||
void ESP32Camera::set_vertical_flip(bool vertical_flip) { this->vertical_flip_ = vertical_flip; }
|
||||
void ESP32Camera::set_horizontal_mirror(bool horizontal_mirror) { this->horizontal_mirror_ = horizontal_mirror; }
|
||||
void ESP32Camera::set_aec2(bool aec2) { this->aec2_ = aec2; }
|
||||
void ESP32Camera::set_ae_level(int ae_level) { this->ae_level_ = ae_level; }
|
||||
void ESP32Camera::set_aec_value(uint32_t aec_value) { this->aec_value_ = aec_value; }
|
||||
void ESP32Camera::set_contrast(int contrast) { this->contrast_ = contrast; }
|
||||
void ESP32Camera::set_brightness(int brightness) { this->brightness_ = brightness; }
|
||||
void ESP32Camera::set_saturation(int saturation) { this->saturation_ = saturation; }
|
||||
|
|
|
@ -67,6 +67,9 @@ class ESP32Camera : public Component, public EntityBase {
|
|||
void set_power_down_pin(uint8_t pin);
|
||||
void set_vertical_flip(bool vertical_flip);
|
||||
void set_horizontal_mirror(bool horizontal_mirror);
|
||||
void set_aec2(bool aec2);
|
||||
void set_ae_level(int ae_level);
|
||||
void set_aec_value(uint32_t aec_value);
|
||||
void set_contrast(int contrast);
|
||||
void set_brightness(int brightness);
|
||||
void set_saturation(int saturation);
|
||||
|
@ -91,6 +94,9 @@ class ESP32Camera : public Component, public EntityBase {
|
|||
camera_config_t config_{};
|
||||
bool vertical_flip_{true};
|
||||
bool horizontal_mirror_{true};
|
||||
bool aec2_{false};
|
||||
int ae_level_{0};
|
||||
uint32_t aec_value_{300};
|
||||
int contrast_{0};
|
||||
int brightness_{0};
|
||||
int saturation_{0};
|
||||
|
|
Loading…
Reference in a new issue