Fix typing for gamma_curve

This commit is contained in:
jaknapper 2026-03-03 14:21:28 +00:00
parent b716013ef2
commit 3020ab59f4
3 changed files with 8 additions and 8 deletions

View file

@ -719,8 +719,8 @@ class StreamingPiCamera2(BaseCamera):
)
@lt.property
def gamma_correction(self) -> float:
"""Return the gamma correction from the tuning file."""
def gamma_correction(self) -> list[int]:
"""Return the gamma correction curve from the tuning file."""
return tf_utils.get_gamma_curve(self.tuning)
@lt.action

View file

@ -186,24 +186,24 @@ def get_lst(tuning: dict) -> LensShadingModel:
)
def get_gamma_curve(tuning: dict) -> dict[int, float]:
def get_gamma_curve(tuning: dict) -> list[int]:
"""Return the gamma curve from the rpi.contrast section of the tuning file.
Returns a dictionary mapping input levels to output levels.
Defaults to {} if gamma curve is missing.
Returns a list where each two elements are the input and output level.
Defaults to [] if gamma curve is missing.
"""
contrast = find_tuning_algo(tuning, "rpi.contrast")
return contrast.get("gamma_curve", {})
return contrast.get("gamma_curve", [])
def set_gamma_curve(tuning: dict, gamma_curve: dict[int, float]) -> dict:
def set_gamma_curve(tuning: dict, gamma_curve: list[int]) -> dict:
"""Set the gamma curve in the rpi.contrast section of the tuning file.
Returns a new tuning dictionary with the updated gamma curve.
"""
output_tuning = deepcopy(tuning)
contrast = find_tuning_algo(output_tuning, "rpi.contrast")
contrast["gamma_curve"] = {int(k): float(v) for k, v in gamma_curve.items()}
contrast["gamma_curve"] = gamma_curve
return output_tuning