tracks
sleap.gui.overlays.tracks
¶
Track trail and track list overlays.
Classes:
| Name | Description |
|---|---|
TrackListOverlay |
Class to show track number and names in overlay. |
TrackTrailOverlay |
Class to show track trails as overlay on video frame. |
TrackListOverlay
¶
Bases: BaseOverlay
Class to show track number and names in overlay.
Methods:
| Name | Description |
|---|---|
add_to_scene |
Adds track list as overlay on video. |
Attributes:
| Name | Type | Description |
|---|---|---|
visible |
Gets or set whether overlay is visible. |
Source code in sleap/gui/overlays/tracks.py
visible
property
writable
¶
Gets or set whether overlay is visible.
add_to_scene(video, frame_idx)
¶
Adds track list as overlay on video.
Source code in sleap/gui/overlays/tracks.py
TrackTrailOverlay
¶
Bases: BaseOverlay
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.
Trails follow the same vocabulary as sleap-io's render_video/
render_image trail options: a single named node (or the instance
centroid), a global opacity, and an oldest-to-newest alpha fade. Trails
also work without tracks -- when the project has no tracks at all,
instances are keyed by their position within each frame instead (matching
sleap-io's index-keyed fallback), so single-instance / untracked data
still gets a live trail.
Attributes:
| Name | Type | Description |
|---|---|---|
labels |
Labels | None
|
The :class: |
player |
QtVideoPlayer | None
|
The video player in which to show overlay. |
trail_length |
int
|
The maximum number of frames to include in trail. |
trail_node |
str
|
Name of the skeleton node the trail follows, or
|
trail_alpha |
float
|
Global opacity multiplier for trails (0.0-1.0). |
trail_alpha_fade |
bool
|
If |
Usage
After class is instantiated, call :meth:add_to_scene(frame_idx)
to plot the trails in scene.
Methods:
| Name | Description |
|---|---|
add_to_scene |
Plot the trail on a given frame. |
get_frame_selection |
Return |
get_node_options |
Return trail-node choices: |
get_track_trails |
Get data needed to draw track trails. |
get_tracks_in_frame |
Returns list of tracks that have instance in specified frame. |
map_to_qt_path |
Converts a list of (x, y)-tuples to a |
Source code in sleap/gui/overlays/tracks.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
add_to_scene(video, frame_idx)
¶
Plot the trail on a given frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
current video |
required |
frame_idx
|
int
|
index of the frame to which the trail is attached |
required |
Source code in sleap/gui/overlays/tracks.py
get_frame_selection(video, frame_idx)
¶
Return LabeledFrame objects to include in trail for specified frame.
Source code in sleap/gui/overlays/tracks.py
get_node_options(labels)
classmethod
¶
Return trail-node choices: "centroid" + each primary-skeleton node.
Source code in sleap/gui/overlays/tracks.py
get_track_trails(frame_selection)
¶
Get data needed to draw track trails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_selection
|
Iterable[LabeledFrame]
|
an iterable with the :class: |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[Union[Track, int], List[Tuple[float, float]]]]
|
Dictionary keyed by |
Source code in sleap/gui/overlays/tracks.py
get_tracks_in_frame(video, frame_idx, include_trails=False)
¶
Returns list of tracks that have instance in specified frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
Video for which we want tracks. |
required |
frame_idx
|
int
|
Frame index for which we want tracks. |
required |
include_trails
|
bool
|
Whether to include tracks which aren't in current frame but would be included in trail (i.e., previous frames within trail_length). |
False
|
Source code in sleap/gui/overlays/tracks.py
map_to_qt_path(point_list)
staticmethod
¶
Converts a list of (x, y)-tuples to a QPainterPath.