Webcam fix (#17840)

* Update xdrv_81_esp32_webcam.ino

* fix single picture fetch

* delay not needed
This commit is contained in:
gemu 2023-01-31 22:22:28 +01:00 committed by GitHub
parent b8677ce0d6
commit ae8041140f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -192,7 +192,7 @@ bool WcPinUsed(void) {
if (!PinUsed(GPIO_WEBCAM_XCLK) || !PinUsed(GPIO_WEBCAM_PCLK) ||
!PinUsed(GPIO_WEBCAM_VSYNC) || !PinUsed(GPIO_WEBCAM_HREF) ||
((!PinUsed(GPIO_WEBCAM_SIOD) || !PinUsed(GPIO_WEBCAM_SIOC)) && !TasmotaGlobal.i2c_enabled_2) // preferred option is to reuse and share I2Cbus 2
) {
) {
pin_used = false;
}
return pin_used;
@ -432,7 +432,10 @@ uint32_t WcSetup(int32_t fsiz) {
WcApplySettings();
AddLog(LOG_LEVEL_INFO, PSTR("CAM: Initialized"));
camera_sensor_info_t *info = esp_camera_sensor_get_info(&wc_s->id);
AddLog(LOG_LEVEL_INFO, PSTR("CAM: %s Initialized"), info->name);
Wc.up = 1;
if (psram) { Wc.up = 2; }
@ -756,6 +759,13 @@ void HandleImage(void) {
camera_fb_t *wc_fb = 0;
wc_fb = esp_camera_fb_get();
if (!wc_fb) { return; }
if (Wc.stream_active < 2) {
// fetch some more frames
esp_camera_fb_return(wc_fb);
wc_fb = esp_camera_fb_get();
esp_camera_fb_return(wc_fb);
wc_fb = esp_camera_fb_get();
}
if (wc_fb->format != PIXFORMAT_JPEG) {
bool jpeg_converted = frame2jpg(wc_fb, 80, &_jpg_buf, &_jpg_buf_len);
if (!jpeg_converted) {