Skip to content

Commit

Permalink
devices: imx500: Fix IMX500.get_kpi_info()
Browse files Browse the repository at this point in the history
Pull the KPI values directly from the tuple instead of decoding a byte
array.

Signed-off-by: Chizkiyahu Raful
  • Loading branch information
Chizkiyahu authored and naushir committed Nov 12, 2024
1 parent 98a0d46 commit 043d20e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions picamera2/devices/imx500/imx500.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 043d20e

Please sign in to comment.