Compare commits

...

4 Commits

4 changed files with 25 additions and 6 deletions

View File

@ -23,6 +23,7 @@ class DetectionSceneSignals(QObject):
class DetectionTimelineSignals(QObject):
windowMoved = Signal()
manualMove = Signal()
moveRequest = Signal(float)
class DetectionSignals(QObject):
hover = Signal((int, QPointF))

View File

@ -65,6 +65,7 @@ class Window(QGraphicsRectItem):
def mousePressEvent(self, event):
self.setCursor(Qt.ClosedHandCursor)
# print(event.pos())
super().mousePressEvent(event)
def mouseReleaseEvent(self, event):
@ -121,6 +122,7 @@ class DetectionTimeline(QWidget):
self._scene = QGraphicsScene(QRectF(0, 0, self._total_width, 85.))
self._scene.setBackgroundBrush(self._bg_brush)
self._scene.addItem(self._window)
self._scene.mousePressEvent = self.on_sceneMousePress
self._view = QGraphicsView()
# self._view.setRenderHints(QPainter.RenderHint.Antialiasing | QPainter.RenderHint.SmoothPixmapTransform)
@ -159,6 +161,14 @@ class DetectionTimeline(QWidget):
# self.setMaximumHeight(100)
# self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
def on_sceneMousePress(self, event):
scene_pos = event.scenePos()
relpos = scene_pos.x() / self._total_width
relpos = 0 if relpos < 0.0 else relpos
relpos = 2000/self._total_width if scene_pos.x() > self._total_width else relpos
self.signals.moveRequest.emit(relpos)
logging.debug("Timeline: Scene clicked at position: %.2f, %.2f --> rel x-pos %.3f", scene_pos.x(), scene_pos.y(), relpos)
def clear(self):
for i in self._scene.items():
if isinstance(i, (QGraphicsLineItem, QGraphicsEllipseItem)):

View File

@ -142,9 +142,10 @@ class DetectionView(QWidget):
scores = self._data.selectedData("confidence")
image_rect = self._pixmapitem.boundingRect() if self._pixmapitem is not None else QRectF(0,0,0,0)
num_detections = len(frames)
for i, (id, f, t, l, s) in enumerate(zip(ids, frames, tracks, userlabeled, scores)):
c = Tracks.fromValue(t).toColor()
c.setAlpha(int(i * 255 / num_detections))
if keypoint >= 0:
x = coordinates[i, keypoint, 0]
y = coordinates[i, keypoint, 1]

View File

@ -45,6 +45,7 @@ class FixTracks(QWidget):
self._timeline = DetectionTimeline()
self._timeline.signals.windowMoved.connect(self.on_windowChanged)
self._timeline.signals.moveRequest.connect(self.on_moveRequest)
self._windowspinner = QSpinBox()
self._windowspinner.setRange(10, 10000)
@ -343,6 +344,11 @@ class FixTracks(QWidget):
self.update()
self._manualmove = False
def on_moveRequest(self, pos):
new_pos = int(np.round(pos * self._maxframes))
self._currentWindowPos = new_pos
self.update()
def on_windowSizeChanged(self, value):
"""Reacts on the user window-width selection. Selection is done in the unit of frames.
@ -353,11 +359,12 @@ class FixTracks(QWidget):
"""
self._currentWindowWidth = value
logging.debug("Tracks:OnWindowSizeChanged %i franes", value)
if self._maxframes == 0:
self._timeline.setWindowWidth(self._currentWindowWidth / 2000)
else:
self._timeline.setWindowWidth(self._currentWindowWidth / self._maxframes)
self._controls_widget.setSelectedTracks(None)
# if self._maxframes == 0:
# self._timeline.setWindowWidth(self._currentWindowWidth / 2000)
# else:
# self._timeline.setWindowWidth(self._currentWindowWidth / self._maxframes)
# self._controls_widget.setSelectedTracks(None)
self.update()
def on_goto(self):
target = self._goto_spinner.value()