Better fix for exposure drift with more complete testing. Also fix return value for capture_to_memory

This commit is contained in:
Julian Stirling 2025-07-29 12:11:45 +01:00
parent 376780ea28
commit b90b02cf7d
3 changed files with 58 additions and 8 deletions

View file

@ -342,7 +342,7 @@ class BaseCamera(lt.Thing):
logger: lt.deps.InvocationLogger,
metadata_getter: lt.deps.GetThingStates,
buffer_max: int = 1,
) -> None:
) -> int:
"""Capture an image to memory. This can be saved later with ``save_from_memory``.
Note that only one image is held in memory so this will overwrite any image

View file

@ -226,7 +226,7 @@ class StreamingPiCamera2(BaseCamera):
if not self._setting_save_in_progress and self.streaming:
with self._streaming_picamera() as cam:
cam_value = cam.capture_metadata()["ExposureTime"]
if abs(cam_value - self._exposure_time) > 30:
if cam_value != self._exposure_time:
self._exposure_time = cam_value
self.save_settings()
return self._exposure_time
@ -250,7 +250,8 @@ class StreamingPiCamera2(BaseCamera):
"Brightness": 0,
"ColourGains": self.colour_gains,
"Contrast": 1,
"ExposureTime": self.exposure_time,
# Must also set plus 1 or the exposure drifts with start and stop stream.
"ExposureTime": self.exposure_time + 1,
"Saturation": 1,
"Sharpness": 1,
}