feat: Add detection count tracking and display in the UI

This commit is contained in:
2026-05-13 22:08:13 +02:00
parent 3b8f7eb3d4
commit 83346dc985
3 changed files with 40 additions and 7 deletions

View File

@@ -105,7 +105,11 @@ class MainWindow(QMainWindow):
self._status_bar = QStatusBar(self)
self.setStatusBar(self._status_bar)
self._status_label = QLabel("Initialising\u2026")
self._status_bar.addWidget(self._status_label)
self._status_bar.addWidget(self._status_label, stretch=1)
# Detection counter — right-aligned permanent widget
self._detection_label = QLabel("")
self._detection_label.setVisible(False)
self._status_bar.addPermanentWidget(self._detection_label)
# --- Wire signals ---
self._wire_signals()
@@ -179,6 +183,7 @@ class MainWindow(QMainWindow):
# ---- InferenceManager ----
self._inference.detections_ready.connect(self._bbox_overlay.on_detections)
self._inference.detection_count_updated.connect(self._on_detection_count_updated)
self._inference.inference_started.connect(self._on_inference_started)
self._inference.inference_stopped.connect(self._on_inference_stopped)
self._inference.inference_error.connect(self._on_inference_error)
@@ -259,6 +264,9 @@ class MainWindow(QMainWindow):
self._status_label.setText("Inference running")
self._menu.set_inference_checked(True)
def _on_detection_count_updated(self, count: int) -> None:
self._detection_label.setText(f"Detections: {count} frames")
def _on_inference_stopped(self) -> None:
self._bbox_overlay.clear()
@@ -267,6 +275,7 @@ class MainWindow(QMainWindow):
self._menu.set_inference_available(False)
self._menu.set_inference_checked(False)
self._bbox_overlay.visible = False
self._detection_label.setVisible(False)
QMessageBox.critical(self, "Inference Error", message)
# ------------------------------------------------------------------
@@ -331,6 +340,8 @@ class MainWindow(QMainWindow):
self._inference.submit_frame, drop_if_busy=True
)
self._bbox_overlay.visible = True
self._detection_label.setText("Detections: 0 frames")
self._detection_label.setVisible(True)
self._status_label.setText("Inference enabled")
logger.info("Inference enabled")
else:
@@ -338,6 +349,7 @@ class MainWindow(QMainWindow):
self._dispatcher.unsubscribe(self._inference.submit_frame)
self._bbox_overlay.clear()
self._bbox_overlay.visible = False
self._detection_label.setVisible(False)
self._status_label.setText("Inference disabled")
logger.info("Inference disabled")