Skip to content

Commit 1522b55

Browse files
authored
Merge pull request #1279 from roflcoopter/feature/hailo-reload
feat(hailo): support config reload
2 parents 09ebe51 + 59364b7 commit 1522b55

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

viseron/components/hailo/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup(vis: Viseron, config: dict[str, Any]) -> bool:
101101
try:
102102
vis.data[COMPONENT] = Hailo8Detector(vis, config)
103103
except Exception as error:
104-
LOGGER.error("Failed to start Hailo 8 detector: %s", error, exc_info=True)
104+
LOGGER.exception("Failed to start Hailo 8 detector")
105105
raise ComponentNotReady from error
106106

107107
return True
@@ -112,7 +112,7 @@ def setup_domains(vis: Viseron, config: dict[str, Any]) -> None:
112112
config = config[COMPONENT]
113113

114114
if config.get(CONFIG_OBJECT_DETECTOR, None):
115-
for camera_identifier in config[CONFIG_OBJECT_DETECTOR][CONFIG_CAMERAS].keys():
115+
for camera_identifier in config[CONFIG_OBJECT_DETECTOR][CONFIG_CAMERAS]:
116116
setup_domain(
117117
vis,
118118
COMPONENT,
@@ -128,14 +128,21 @@ def setup_domains(vis: Viseron, config: dict[str, Any]) -> None:
128128
)
129129

130130

131+
def unload(vis: Viseron) -> None:
132+
"""Unload hailo component."""
133+
if COMPONENT in vis.data:
134+
vis.data[COMPONENT].stop()
135+
del vis.data[COMPONENT]
136+
137+
131138
class LoadHailo8Error(ViseronError):
132139
"""Error raised on all failures to load Hailo8."""
133140

134141

135142
class Hailo8Detector(ChildProcessWorker):
136143
"""Hailo 8 object detector."""
137144

138-
def __init__(self, vis: Viseron, config: dict[str, Any]):
145+
def __init__(self, vis: Viseron, config: dict[str, Any]) -> None:
139146
self._config = config
140147
hailo_arch = get_hailo_arch()
141148
LOGGER.debug(f"Detected Hailo architecture: {hailo_arch}")

0 commit comments

Comments
 (0)