Skip to content

Commit

Permalink
Handle case when no frame selection for trail overlay (#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys authored Jul 1, 2024
1 parent 436b177 commit c8e3cd0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sleap/gui/overlays/tracks.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
"""Track trail and track list overlays."""

from typing import Dict, Iterable, List, Optional, Tuple

import attr
from qtpy import QtCore, QtGui

from sleap.gui.overlays.base import BaseOverlay
from sleap.gui.widgets.video import QtTextWithBackground
from sleap.instance import Track
from sleap.io.dataset import Labels
from sleap.io.video import Video
from sleap.prefs import prefs
from sleap.gui.widgets.video import QtTextWithBackground

import attr

from typing import Iterable, List, Optional, Dict

from qtpy import QtCore, QtGui


@attr.s(auto_attribs=True)
Expand Down Expand Up @@ -58,7 +57,9 @@ def get_shade_options(cls):

return {"Dark": 0.6, "Normal": 1.0, "Light": 1.25}

def get_track_trails(self, frame_selection: Iterable["LabeledFrame"]):
def get_track_trails(
self, frame_selection: Iterable["LabeledFrame"]
) -> Optional[Dict[Track, List[List[Tuple[float, float]]]]]:
"""Get data needed to draw track trail.
Args:
Expand Down Expand Up @@ -154,6 +155,8 @@ def add_to_scene(self, video: Video, frame_idx: int):
frame_selection = self.get_frame_selection(video, frame_idx)

all_track_trails = self.get_track_trails(frame_selection)
if all_track_trails is None:
return

for track, trails in all_track_trails.items():
trail_color = tuple(
Expand Down

0 comments on commit c8e3cd0

Please sign in to comment.