Refactor HVideoTool's configuration and project management: updated project handling in core/project.py, streamlined restoration settings in config.py, and improved documentation in CLAUDE.md. Removed unused parameters and enhanced type hints for better clarity.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""Widget that renders an image and draws detection overlays.
|
||||
|
||||
Overlay visibility and the confidence threshold are applied at paint time, so
|
||||
toggling them is instant. One detection can be *highlighted* (selected in the
|
||||
detail table) — it is drawn boldly even if below the threshold, while the others
|
||||
dim, so the user can inspect exactly what the detector found.
|
||||
The confidence threshold is applied at paint time, so changing it is instant. One
|
||||
detection can be *highlighted* (selected in the detail table) — it is drawn boldly
|
||||
even if below the threshold, while the others dim, so the user can inspect exactly
|
||||
what the detector found.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -24,7 +24,6 @@ class ImageView(QWidget):
|
||||
self._cfg = overlay_cfg
|
||||
self._qimage: QImage | None = None
|
||||
self._dets: list[Detection] = []
|
||||
self._overlay_enabled = True
|
||||
self._threshold = 0.0
|
||||
self._highlight: int | None = None
|
||||
self.setMinimumSize(480, 360)
|
||||
@@ -42,10 +41,6 @@ class ImageView(QWidget):
|
||||
self._highlight = None
|
||||
self.update()
|
||||
|
||||
def set_overlay_enabled(self, enabled: bool) -> None:
|
||||
self._overlay_enabled = enabled
|
||||
self.update()
|
||||
|
||||
def set_threshold(self, threshold: float) -> None:
|
||||
self._threshold = threshold
|
||||
self.update()
|
||||
@@ -59,13 +54,13 @@ class ImageView(QWidget):
|
||||
r, g, b = self._cfg.colors.get(ctype.value, (255, 0, 0))
|
||||
return QColor(r, g, b)
|
||||
|
||||
def paintEvent(self, event) -> None: # noqa: N802 - Qt signature
|
||||
def paintEvent(self, event) -> None:
|
||||
painter = QPainter(self)
|
||||
painter.fillRect(self.rect(), QColor(18, 18, 18))
|
||||
|
||||
if self._qimage is None:
|
||||
painter.setPen(QColor(160, 160, 160))
|
||||
painter.drawText(self.rect(), Qt.AlignCenter, "Откройте папку с картинками (Файл → Открыть папку…)")
|
||||
painter.drawText(self.rect(), Qt.AlignCenter, "Откройте проект (Файл → Открыть проект…)")
|
||||
painter.end()
|
||||
return
|
||||
|
||||
@@ -77,7 +72,7 @@ class ImageView(QWidget):
|
||||
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
|
||||
painter.drawImage(QRectF(ox, oy, dw, dh), self._qimage)
|
||||
|
||||
if self._overlay_enabled and self._dets:
|
||||
if self._dets:
|
||||
painter.setRenderHint(QPainter.Antialiasing, True)
|
||||
for i, d in enumerate(self._dets):
|
||||
highlighted = i == self._highlight
|
||||
|
||||
Reference in New Issue
Block a user