From 7f70220d63600f25af80208384025263303399b2 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Fri, 19 Jun 2026 08:40:12 +0100 Subject: [PATCH] Don't override ScalerCrop(s) if the user configuration sets them Also pre-emptively fix tests for 'OutputWindows' control. Signed-off-by: David Plowman --- apps/app_full.py | 1 + picamera2/picamera2.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/app_full.py b/apps/app_full.py index 4159cdcc..409cb455 100755 --- a/apps/app_full.py +++ b/apps/app_full.py @@ -1196,6 +1196,7 @@ def toggle_hidden_controls(): "AfPause", "AfMetering", "ScalerCrops", + "OutputWindows", } # Main widgets diff --git a/picamera2/picamera2.py b/picamera2/picamera2.py index 90d047c1..b9e73e72 100644 --- a/picamera2/picamera2.py +++ b/picamera2/picamera2.py @@ -1272,10 +1272,14 @@ def configure_(self, camera_config): self.preview_configuration.update(camera_config) # Set the controls directly so as to overwrite whatever is there. - self.controls = Controls(self, controls=self.camera_config['controls']) + controls = self.camera_config['controls'] + self.controls = Controls(self, controls=controls) + if isinstance(controls, Controls): + controls = controls.make_dict() self.configure_count += 1 - if "ScalerCrops" in self.camera_controls: + # We will supply reasonable default crops unless the user has done so themselves. + if "ScalerCrops" in self.camera_controls and "ScalerCrops" not in controls and "ScalerCrop" not in controls: par_crop = self.camera_controls["ScalerCrops"] full_fov = self.camera_controls["ScalerCrop"][1] scaler_crops = [par_crop[0] if camera_config["main"]["preserve_ar"] else full_fov]