From 2defa19f8aa612a9c672e1dc2d02e200c8eab06d 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/picamera2/devices/imx500/imx500.py b/picamera2/devices/imx500/imx500.py index ef9518c7..04bdaea6 100644 --- a/picamera2/devices/imx500/imx500.py +++ b/picamera2/devices/imx500/imx500.py @@ -581,14 +581,14 @@ 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). + the numbers are 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):