Enhance HVideoTool's detection and restoration capabilities: introduced per-model overlay threshold settings and cross-model non-maximum suppression (NMS) to improve detection accuracy. Updated configuration management to support these features, and refined the UI for better user experience. Documentation in CLAUDE.md has been updated to reflect these changes.
This commit is contained in:
@@ -27,6 +27,7 @@ class ImageView(QWidget):
|
||||
self._qimage: QImage | None = None
|
||||
self._dets: list[Detection] = []
|
||||
self._threshold = 0.0
|
||||
self._model_thresholds: dict[str, float] = {} # model stem -> override threshold
|
||||
self._highlight: int | None = None
|
||||
self.setMinimumSize(480, 360)
|
||||
|
||||
@@ -47,6 +48,15 @@ class ImageView(QWidget):
|
||||
self._threshold = threshold
|
||||
self.update()
|
||||
|
||||
def set_model_thresholds(self, thresholds: dict[str, float]) -> None:
|
||||
"""Per-model overlay threshold overrides (keyed by model stem). Empty = none."""
|
||||
self._model_thresholds = dict(thresholds)
|
||||
self.update()
|
||||
|
||||
def _eff_threshold(self, d: Detection) -> float:
|
||||
"""The threshold this detection must clear — its model's override, else global."""
|
||||
return self._model_thresholds.get(d.model, self._threshold)
|
||||
|
||||
def set_highlight(self, index: int | None) -> None:
|
||||
self._highlight = index
|
||||
self.update()
|
||||
@@ -82,8 +92,9 @@ class ImageView(QWidget):
|
||||
painter.setRenderHint(QPainter.Antialiasing, True)
|
||||
for i, d in enumerate(self._dets):
|
||||
highlighted = i == self._highlight
|
||||
# A highlighted detection is always drawn; others respect the threshold.
|
||||
if not highlighted and d.score < self._threshold:
|
||||
# A highlighted detection is always drawn; others respect the threshold
|
||||
# (per-model override if any, else the global one).
|
||||
if not highlighted and d.score < self._eff_threshold(d):
|
||||
continue
|
||||
dim = self._highlight is not None and not highlighted
|
||||
self._draw_detection(painter, d, ox, oy, scale, highlighted, dim)
|
||||
|
||||
Reference in New Issue
Block a user