added check for failed photo capture
parent
68e26390ac
commit
e6b20283ca
|
|
@ -31,6 +31,7 @@ Camera::Camera(Configuration* i_conf, Logs* i_log, uint8_t i_FlashPin) {
|
||||||
PhotoExifData.len = 0;
|
PhotoExifData.len = 0;
|
||||||
PhotoExifData.offset = 0;
|
PhotoExifData.offset = 0;
|
||||||
PhotoSending = false;
|
PhotoSending = false;
|
||||||
|
CameraCaptureFailedCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -310,7 +311,8 @@ void Camera::CapturePhoto() {
|
||||||
delay(5); // delay for camera stabilization. test it
|
delay(5); // delay for camera stabilization. test it
|
||||||
FrameBuffer = esp_camera_fb_get();
|
FrameBuffer = esp_camera_fb_get();
|
||||||
if (!FrameBuffer) {
|
if (!FrameBuffer) {
|
||||||
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo"));
|
CameraCaptureFailedCounter++;
|
||||||
|
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo. Attempt: "), String(CameraCaptureFailedCounter));
|
||||||
xSemaphoreGive(frameBufferSemaphore); // Release semaphore before returning
|
xSemaphoreGive(frameBufferSemaphore); // Release semaphore before returning
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -321,11 +323,12 @@ void Camera::CapturePhoto() {
|
||||||
log->AddEvent(LogLevel_Info, buf);
|
log->AddEvent(LogLevel_Info, buf);
|
||||||
|
|
||||||
if (ControlFlag != 0x00) {
|
if (ControlFlag != 0x00) {
|
||||||
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo "), String(ControlFlag, HEX));
|
log->AddEvent(LogLevel_Error, "Camera capture failed! flag: " + String(ControlFlag, HEX));
|
||||||
FrameBuffer->len = 0;
|
FrameBuffer->len = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log->AddEvent(LogLevel_Info, F("Photo OK! "), String(ControlFlag, HEX));
|
log->AddEvent(LogLevel_Info, F("Photo OK! "), String(ControlFlag, HEX));
|
||||||
|
CameraCaptureFailedCounter = 0;
|
||||||
|
|
||||||
/* generate exif header */
|
/* generate exif header */
|
||||||
update_exif_from_cfg(imageExifRotation);
|
update_exif_from_cfg(imageExifRotation);
|
||||||
|
|
@ -354,6 +357,13 @@ void Camera::CapturePhoto() {
|
||||||
}
|
}
|
||||||
xSemaphoreGive(frameBufferSemaphore);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ private:
|
||||||
float StreamAverageFps; ///< stream average fps
|
float StreamAverageFps; ///< stream average fps
|
||||||
uint16_t StreamAverageSize; ///< stream average size
|
uint16_t StreamAverageSize; ///< stream average size
|
||||||
PhotoExifData_t PhotoExifData; ///< photo exif data
|
PhotoExifData_t PhotoExifData; ///< photo exif data
|
||||||
|
uint8_t CameraCaptureFailedCounter; ///< camera capture failed counter
|
||||||
|
|
||||||
Configuration *config; ///< pointer to Configuration object
|
Configuration *config; ///< pointer to Configuration object
|
||||||
Logs *log; ///< pointer to Logs object
|
Logs *log; ///< pointer to Logs object
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#define SW_BUILD __DATE__ " " __TIME__ ///< build number
|
#define SW_BUILD __DATE__ " " __TIME__ ///< build number
|
||||||
#define CONSOLE_VERBOSE_DEBUG false ///< enable/disable verbose debug log level for console
|
#define CONSOLE_VERBOSE_DEBUG false ///< enable/disable verbose debug log level for console
|
||||||
#define DEVICE_HOSTNAME "Prusa-ESP32cam" ///< device hostname
|
#define DEVICE_HOSTNAME "Prusa-ESP32cam" ///< device hostname
|
||||||
|
#define CAMERA_MAX_FAIL_CAPTURE 10 ///< maximum count for failed capture
|
||||||
|
|
||||||
/* ------------ PRUSA BACKEND CFG --------------*/
|
/* ------------ PRUSA BACKEND CFG --------------*/
|
||||||
#define HOST_URL_CAM_PATH "/c/snapshot" ///< path for sending photo to prusa connect
|
#define HOST_URL_CAM_PATH "/c/snapshot" ///< path for sending photo to prusa connect
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue