From ac08462405a8dce44823a1128f3b560a2986aeb5 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 16 Oct 2025 18:46:21 +0100 Subject: [PATCH] Attempt to load custom tuning file first Most likely want to be in try except --- .../things/camera/picamera_tuning_file_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openflexure_microscope_server/things/camera/picamera_tuning_file_utils.py b/src/openflexure_microscope_server/things/camera/picamera_tuning_file_utils.py index e68b7681..b6f12450 100644 --- a/src/openflexure_microscope_server/things/camera/picamera_tuning_file_utils.py +++ b/src/openflexure_microscope_server/things/camera/picamera_tuning_file_utils.py @@ -9,7 +9,9 @@ from copy import deepcopy from picamera2 import Picamera2 import numpy as np +import os +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) def load_default_tuning(sensor_model: str) -> dict: """Load the default tuning file for the camera. @@ -17,6 +19,11 @@ def load_default_tuning(sensor_model: str) -> dict: This will load the tuning file based on the specified sensor model. """ fname = f"{sensor_model}.json" + custom_path = os.path.join(THIS_DIR, 'tuning_files', fname) + + # Attempt to load custom tuning file from OpenFlexure settings + if os.path.isfile(custom_path): + return Picamera2.load_tuning_file(fname, dir=os.path.join(THIS_DIR, 'tuning_files')) try: return Picamera2.load_tuning_file(fname) except RuntimeError: