sleap.gui.overlays.tracks

Track trail and track list overlays.

class sleap.gui.overlays.tracks.TrackListOverlay(labels: sleap.io.dataset.Labels = None, player: sleap.gui.widgets.video.QtVideoPlayer = None, text_box: Optional[sleap.gui.widgets.video.QtTextWithBackground] = None)[source]

Class to show track number and names in overlay.

add_to_scene(video: sleap.io.video.Video, frame_idx: int)[source]

Adds track list as overlay on video.

property visible

Gets or set whether overlay is visible.

class sleap.gui.overlays.tracks.TrackTrailOverlay(labels: sleap.io.dataset.Labels = None, player: sleap.gui.widgets.video.QtVideoPlayer = None, trail_length: int = 0, show: bool = True, max_node_count: Optional[int] = None)[source]

Class to show track trails as overlay on video frame.

Initialize this object with both its data source and its visual output scene, and it handles both extracting the relevant data for a given frame and plotting it in the output.

labels

The Labels dataset from which to get overlay data.

player

The video player in which to show overlay.

trail_length

The maximum number of frames to include in trail.

Usage:

After class is instantiated, call add_to_scene(frame_idx)() to plot the trails in scene.

add_to_scene(video: sleap.io.video.Video, frame_idx: int)[source]

Plot the trail on a given frame.

Parameters
  • video – current video

  • frame_idx – index of the frame to which the trail is attached

get_frame_selection(video: sleap.io.video.Video, frame_idx: int)[source]

Return LabeledFrame objects to include in trail for specified frame.

get_track_trails(frame_selection: Iterable[LabeledFrame])[source]

Get data needed to draw track trail.

Parameters

frame_selection – an iterable with the LabeledFrame objects to include in trail.

Returns

Dictionary keyed by track, value is list of lists of (x, y) tuples

i.e., for every node in instance, we get a list of positions

get_tracks_in_frame(video: sleap.io.video.Video, frame_idx: int, include_trails: bool = False) → List[sleap.instance.Track][source]

Returns list of tracks that have instance in specified frame.

Parameters
  • video – Video for which we want tracks.

  • frame_idx – Frame index for which we want tracks.

  • include_trails – Whether to include tracks which aren’t in current frame but would be included in trail (i.e., previous frames within trail_length).

Returns

List of tracks.

static map_to_qt_path(point_list)[source]

Converts a list of (x, y)-tuples to a QPainterPath.