Add limits to noise level, sample density and downsample

This commit is contained in:
Joe Knapper 2026-03-02 19:55:21 +00:00 committed by Julian Stirling
parent 06f12973f4
commit 99b9b0f3d6
2 changed files with 4 additions and 2 deletions

View file

@ -274,7 +274,7 @@ class BaseCamera(lt.Thing):
"CameraThings must define their own capture_array method" "CameraThings must define their own capture_array method"
) )
downsampled_array_factor: int = lt.property(default=2) downsampled_array_factor: int = lt.property(default=2, ge=1)
"""The downsampling factor when calling capture_downsampled_array.""" """The downsampling factor when calling capture_downsampled_array."""
@lt.action @lt.action

View file

@ -172,6 +172,8 @@ class SimulatedCamera(BaseCamera):
@blob_density.setter @blob_density.setter
def _set_blob_density(self, value: int) -> None: def _set_blob_density(self, value: int) -> None:
if value < 0:
self.logger.warning("Sample density must be >= 0")
self._blob_density = value self._blob_density = value
if self._capture_enabled: if self._capture_enabled:
self.generate_canvas() self.generate_canvas()
@ -457,7 +459,7 @@ class SimulatedCamera(BaseCamera):
return self._capture_thread.is_alive() return self._capture_thread.is_alive()
return False return False
noise_level: float = lt.property(default=2.0) noise_level: float = lt.property(default=2.0, ge=0)
def _capture_frames(self) -> None: def _capture_frames(self) -> None:
last_frame_t = time.time() last_frame_t = time.time()