From 043d20ec5578ecd5e5b258ef361446cd64daae07 Mon Sep 17 00:00:00 2001 From: Chizkiyahu Raful <37312901+Chizkiyahu@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:16:41 +0200 Subject: [PATCH] devices: imx500: Fix IMX500.get_kpi_info() Pull the KPI values directly from the tuple instead of decoding a byte array. Signed-off-by: Chizkiyahu Raful --- picamera2/devices/imx500/imx500.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/picamera2/devices/imx500/imx500.py b/picamera2/devices/imx500/imx500.py index ef9518c7..ee944e78 100644 --- a/picamera2/devices/imx500/imx500.py +++ b/picamera2/devices/imx500/imx500.py @@ -581,14 +581,11 @@ def __get_input_tensor_info(self, tensor_info) -> tuple[str, int, int, int]: @staticmethod def get_kpi_info(metadata: dict) -> Optional[tuple[float, float]]: - """Return the KPI parameters in the form (dnn_runtime, dsp_runtime).""" + """Return the KPI parameters in the form (dnn_runtime, dsp_runtime) in milliseconds.""" kpi_info = metadata.get('CnnKpiInfo') if kpi_info is None: return None - if type(kpi_info) not in [bytes, bytearray]: - kpi_info = bytes(kpi_info) - - dnn_runtime, dsp_runtime = struct.unpack('II', kpi_info) + dnn_runtime, dsp_runtime = kpi_info[0], kpi_info[1] return dnn_runtime / 1000, dsp_runtime / 1000 def __set_network_firmware(self, network_filename: str):