mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
Add support for ESP32 CAM resolutions for 3MP and 5MP sensors (OV5640 for example). Also support (almost) arbitrary camera clock, some cameras/ESP chips need slightly lower clock than 20MHz to avoid image corruption. (#4580)
This commit is contained in:
parent
7196fb8e82
commit
5207ca1d52
3 changed files with 73 additions and 1 deletions
|
@ -55,6 +55,22 @@ FRAME_SIZES = {
|
||||||
"SXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1280X1024,
|
"SXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1280X1024,
|
||||||
"1600X1200": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
|
"1600X1200": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
|
||||||
"UXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
|
"UXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
|
||||||
|
"1920X1080": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1920X1080,
|
||||||
|
"FHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1920X1080,
|
||||||
|
"720X1280": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_720X1280,
|
||||||
|
"PHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_720X1280,
|
||||||
|
"864X1536": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_864X1536,
|
||||||
|
"P3MP": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_864X1536,
|
||||||
|
"2048X1536": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2048X1536,
|
||||||
|
"QXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2048X1536,
|
||||||
|
"2560X1440": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1440,
|
||||||
|
"QHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1440,
|
||||||
|
"2560X1600": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1600,
|
||||||
|
"WQXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1600,
|
||||||
|
"1080X1920": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1080X1920,
|
||||||
|
"PFHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1080X1920,
|
||||||
|
"2560X1920": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1920,
|
||||||
|
"QSXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1920,
|
||||||
}
|
}
|
||||||
ESP32GainControlMode = esp32_camera_ns.enum("ESP32GainControlMode")
|
ESP32GainControlMode = esp32_camera_ns.enum("ESP32GainControlMode")
|
||||||
ENUM_GAIN_CONTROL_MODE = {
|
ENUM_GAIN_CONTROL_MODE = {
|
||||||
|
@ -140,7 +156,7 @@ CONFIG_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
cv.Required(CONF_PIN): pins.internal_gpio_input_pin_number,
|
cv.Required(CONF_PIN): pins.internal_gpio_input_pin_number,
|
||||||
cv.Optional(CONF_FREQUENCY, default="20MHz"): cv.All(
|
cv.Optional(CONF_FREQUENCY, default="20MHz"): cv.All(
|
||||||
cv.frequency, cv.one_of(20e6, 10e6)
|
cv.frequency, cv.Range(min=10e6, max=20e6)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
|
@ -91,6 +91,30 @@ void ESP32Camera::dump_config() {
|
||||||
case FRAMESIZE_UXGA:
|
case FRAMESIZE_UXGA:
|
||||||
ESP_LOGCONFIG(TAG, " Resolution: 1600x1200 (UXGA)");
|
ESP_LOGCONFIG(TAG, " Resolution: 1600x1200 (UXGA)");
|
||||||
break;
|
break;
|
||||||
|
case FRAMESIZE_FHD:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 1920x1080 (FHD)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_P_HD:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 720x1280 (P_HD)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_P_3MP:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 864x1536 (P_3MP)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_QXGA:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 2048x1536 (QXGA)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_QHD:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 2560x1440 (QHD)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_WQXGA:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 2560x1600 (WQXGA)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_P_FHD:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 1080x1920 (P_FHD)");
|
||||||
|
break;
|
||||||
|
case FRAMESIZE_QSXGA:
|
||||||
|
ESP_LOGCONFIG(TAG, " Resolution: 2560x1920 (QSXGA)");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -257,6 +281,30 @@ void ESP32Camera::set_frame_size(ESP32CameraFrameSize size) {
|
||||||
case ESP32_CAMERA_SIZE_1600X1200:
|
case ESP32_CAMERA_SIZE_1600X1200:
|
||||||
this->config_.frame_size = FRAMESIZE_UXGA;
|
this->config_.frame_size = FRAMESIZE_UXGA;
|
||||||
break;
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_1920X1080:
|
||||||
|
this->config_.frame_size = FRAMESIZE_FHD;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_720X1280:
|
||||||
|
this->config_.frame_size = FRAMESIZE_P_HD;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_864X1536:
|
||||||
|
this->config_.frame_size = FRAMESIZE_P_3MP;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_2048X1536:
|
||||||
|
this->config_.frame_size = FRAMESIZE_QXGA;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_2560X1440:
|
||||||
|
this->config_.frame_size = FRAMESIZE_QHD;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_2560X1600:
|
||||||
|
this->config_.frame_size = FRAMESIZE_WQXGA;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_1080X1920:
|
||||||
|
this->config_.frame_size = FRAMESIZE_P_FHD;
|
||||||
|
break;
|
||||||
|
case ESP32_CAMERA_SIZE_2560X1920:
|
||||||
|
this->config_.frame_size = FRAMESIZE_QSXGA;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ESP32Camera::set_jpeg_quality(uint8_t quality) { this->config_.jpeg_quality = quality; }
|
void ESP32Camera::set_jpeg_quality(uint8_t quality) { this->config_.jpeg_quality = quality; }
|
||||||
|
|
|
@ -29,6 +29,14 @@ enum ESP32CameraFrameSize {
|
||||||
ESP32_CAMERA_SIZE_1024X768, // XGA
|
ESP32_CAMERA_SIZE_1024X768, // XGA
|
||||||
ESP32_CAMERA_SIZE_1280X1024, // SXGA
|
ESP32_CAMERA_SIZE_1280X1024, // SXGA
|
||||||
ESP32_CAMERA_SIZE_1600X1200, // UXGA
|
ESP32_CAMERA_SIZE_1600X1200, // UXGA
|
||||||
|
ESP32_CAMERA_SIZE_1920X1080, // FHD
|
||||||
|
ESP32_CAMERA_SIZE_720X1280, // PHD
|
||||||
|
ESP32_CAMERA_SIZE_864X1536, // P3MP
|
||||||
|
ESP32_CAMERA_SIZE_2048X1536, // QXGA
|
||||||
|
ESP32_CAMERA_SIZE_2560X1440, // QHD
|
||||||
|
ESP32_CAMERA_SIZE_2560X1600, // WQXGA
|
||||||
|
ESP32_CAMERA_SIZE_1080X1920, // PFHD
|
||||||
|
ESP32_CAMERA_SIZE_2560X1920, // QSXGA
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ESP32AgcGainCeiling {
|
enum ESP32AgcGainCeiling {
|
||||||
|
|
Loading…
Reference in a new issue