From 75ca73f148a975e69e42727228dcc375aab31681 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Wed, 18 Feb 2026 15:09:40 +0000 Subject: [PATCH 1/4] Decrease target brightness for both cameras as its pre-gamma --- .../things/camera/picamera_recalibrate_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py index a11b6c91..71e247d3 100644 --- a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py +++ b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py @@ -85,7 +85,7 @@ IMX219_SENSOR_INFO = SensorInfo( unpacked_pixel_format="SBGGR10", bit_depth=10, blacklevel=64, - default_target_white_level=700, + default_target_white_level=300, short_pause=0.2, long_pause=0.5, ) @@ -95,7 +95,7 @@ IMX477_SENSOR_INFO = SensorInfo( unpacked_pixel_format="SBGGR12", bit_depth=12, blacklevel=256, - default_target_white_level=2800, + default_target_white_level=1200, short_pause=0.2, long_pause=1.0, ) From e324014a81d17031c5aa7f23aab1050c9cebf366 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Wed, 18 Feb 2026 16:00:38 +0000 Subject: [PATCH 2/4] Increase target exposure to 40% --- .../things/camera/picamera_recalibrate_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py index 71e247d3..77175f11 100644 --- a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py +++ b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py @@ -85,7 +85,7 @@ IMX219_SENSOR_INFO = SensorInfo( unpacked_pixel_format="SBGGR10", bit_depth=10, blacklevel=64, - default_target_white_level=300, + default_target_white_level=400, short_pause=0.2, long_pause=0.5, ) @@ -95,7 +95,7 @@ IMX477_SENSOR_INFO = SensorInfo( unpacked_pixel_format="SBGGR12", bit_depth=12, blacklevel=256, - default_target_white_level=1200, + default_target_white_level=1600, short_pause=0.2, long_pause=1.0, ) From 84f30320226226a365f0672756c914a75a24b019 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Tue, 3 Mar 2026 14:52:29 +0000 Subject: [PATCH 3/4] Update docstrings to explain lower brightness --- .../things/camera/picamera.py | 3 ++- .../things/camera/picamera_recalibrate_utils.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/openflexure_microscope_server/things/camera/picamera.py b/src/openflexure_microscope_server/things/camera/picamera.py index 40ad6bda..29afc35b 100644 --- a/src/openflexure_microscope_server/things/camera/picamera.py +++ b/src/openflexure_microscope_server/things/camera/picamera.py @@ -640,7 +640,8 @@ class StreamingPiCamera2(BaseCamera): :param target_white_level: Raw target white level, this should be an integer within the range set by the bit-depth of the camera sensor (10-bit for PiCamera v2, 12 Bit for Picamera HQ. If None the default will be used for - the current sensor. This is approximately 70% saturated. + the current sensor. This is approximately 40% saturated, but after gamma + curve is applied, the pixel values will have a value around 200. :param percentile: The percentile to use instead of maximum. Default 99.9. When calculating the brightest pixel, a percentile is used rather than the maximum in order to be robust to a small number of noisy/bright pixels. diff --git a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py index 77175f11..0a5637ab 100644 --- a/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py +++ b/src/openflexure_microscope_server/things/camera/picamera_recalibrate_utils.py @@ -120,10 +120,11 @@ def adjust_shutter_and_gain_from_raw( :param camera: A Picamera2 object. :param target_white_level: The raw value we aim for, the raw value of the brightest pixels should be approximately this bright. The value to set depends on the - sensor bit depth. We recommend values of 700 for 10-bit sensors and 2800 for - 12-bit sensors. This is about 70% of saturated once the blacklevel is + sensor bit depth. We recommend values of 400 for 10-bit sensors and 1600 for + 12-bit sensors. This is about 40% of saturated once the blacklevel is subtracted. The maximum possible value depends on the sensor bit depth, the - sensor blacklevel and the tolerance argument. + sensor blacklevel and the tolerance argument. While this only uses 40% of the + sensor range, after gamma this corresponds to pixel value ~200. :param max_iterations: We will terminate once we perform this many iterations, whether or not we converge. More than 10 shouldn't happen. :param tolerance: How close to the target value we consider "done". Expressed as a From 5fab6825e257498b37d4a5dcc7c590429d4453e3 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 4 Mar 2026 22:47:01 +0000 Subject: [PATCH 4/4] Update picamera tests --- picamera_coverage.zip | Bin 54038 -> 54038 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/picamera_coverage.zip b/picamera_coverage.zip index bd21c4667099fa1b3fb6feaff98cfd967c3581fb..4a6c18565efa1d51a3ede16982b80d3e405a658b 100644 GIT binary patch delta 311 zcmbQXjCtBJW}yIYW)=|!5D?pt64Rc|xp$+`gFa=68xM~Q%Q5gQ;Y?R&@L}L@%=g+q z)#1<5{YpLz?7EB&8{3&Di}pvVelu416Ucmkfo%=rod;|W>JKt7uz?I?U}j*DU|=g? zHu!NXe)Hu1_@;i86-Wnx;gv1w9DsKT zn44G_m{?jG86{d6f;CzCiB9IcJ)UsKaL9LBFL&SonV;{lwR*DCg^L;{28k(VNhygb<|!75DXB>*X$EE{1}P>