added check for failed photo capture

pull/32/head
Miroslav Pivovarsky 2024-05-27 18:26:28 +02:00
parent 68e26390ac
commit 31c461ddc0
3 changed files with 12 additions and 0 deletions

View File

@ -31,6 +31,7 @@ Camera::Camera(Configuration* i_conf, Logs* i_log, uint8_t i_FlashPin) {
PhotoExifData.len = 0;
PhotoExifData.offset = 0;
PhotoSending = false;
CameraCaptureFailedCounter = 0;
}
/**
@ -312,6 +313,7 @@ void Camera::CapturePhoto() {
if (!FrameBuffer) {
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo"));
xSemaphoreGive(frameBufferSemaphore); // Release semaphore before returning
CameraCaptureFailedCounter++;
return;
}
@ -326,6 +328,7 @@ void Camera::CapturePhoto() {
} else {
log->AddEvent(LogLevel_Info, F("Photo OK! "), String(ControlFlag, HEX));
CameraCaptureFailedCounter = 0;
/* generate exif header */
update_exif_from_cfg(imageExifRotation);
@ -354,6 +357,13 @@ void Camera::CapturePhoto() {
}
xSemaphoreGive(frameBufferSemaphore);
}
/* Reinit camera module if photo capture failed */
if (CameraCaptureFailedCounter > CAMERA_MAX_FAIL_CAPTURE) {
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo max attempts"));
CameraCaptureFailedCounter = 0;
ReinitCameraModule();
}
}
/**

View File

@ -75,6 +75,7 @@ private:
float StreamAverageFps; ///< stream average fps
uint16_t StreamAverageSize; ///< stream average size
PhotoExifData_t PhotoExifData; ///< photo exif data
uint8_t CameraCaptureFailedCounter; ///< camera capture failed counter
Configuration *config; ///< pointer to Configuration object
Logs *log; ///< pointer to Logs object

View File

@ -18,6 +18,7 @@
#define SW_BUILD __DATE__ " " __TIME__ ///< build number
#define CONSOLE_VERBOSE_DEBUG false ///< enable/disable verbose debug log level for console
#define DEVICE_HOSTNAME "Prusa-ESP32cam" ///< device hostname
#define CAMERA_MAX_FAIL_CAPTURE 10 ///< maximum count for failed capture
/* ------------ PRUSA BACKEND CFG --------------*/
#define HOST_URL_CAM_PATH "/c/snapshot" ///< path for sending photo to prusa connect