Skip to content

Commit 36a1996

Browse files
naushirdavidplowman
authored andcommitted
devices: hailo: Add a helper to determine the Hailo device architecture
This will be needed in a future commit to auto-select the correct model HEF files for the detect and pose examples. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 6674fe5 commit 36a1996

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

picamera2/devices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
try:
22
# Hailo requires hailo_platform package, which may not be installed on non-Hailo platforms.
3-
from .hailo import Hailo
3+
from .hailo import Hailo, hailo_architecture
44
except ModuleNotFoundError:
55
pass
66
from .imx500 import IMX500
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .hailo import Hailo
1+
from .hailo import Hailo, hailo_architecture

picamera2/devices/hailo/hailo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
import subprocess
12
from concurrent.futures import Future
23
from functools import partial
34

45
import numpy as np
56
from hailo_platform import HEF, FormatType, HailoSchedulingAlgorithm, VDevice
67

78

9+
def hailo_architecture():
10+
"""
11+
Executes the hailortcli command and extracts the Device Architecture.
12+
13+
Returns the architecture string if found, otherwise returns None.
14+
"""
15+
command = ["hailortcli", "fw-control", "identify"]
16+
17+
try:
18+
result = subprocess.run(command, capture_output=True, text=True, check=True).stdout
19+
for line in result.splitlines():
20+
if "Device Architecture:" in line:
21+
return line.split(":")[-1].strip()
22+
except Exception as e:
23+
print(f"Error identifying Hailo device: {e}")
24+
return None
25+
26+
return None
27+
28+
829
class Hailo:
930
TARGET = None
1031
TARGET_REF_COUNT = 0

0 commit comments

Comments
 (0)