ByoTrack ViZ
We add some visualization tools. They rely on matplotlib and opencv-python.
Note
We developed these tools under linux using opencv + gtk backend. It seems that the zoom/drag/quit operations are not automatically supported on other platforms.
- byotrack.visualize.display_lifetime(tracks: Collection[Track])
Display the lifetime of tracks
Active tracks are in white. (Tracks on x-axis, Frames on y-axis)
- Parameters:
tracks (Collection[byotrack.Track]) – Tracks
- byotrack.visualize.temporal_projection(tracks_tensor: Tensor, colors: Sequence[Tuple[int, int, int]] = ((255, 255, 255),), background: ndarray | None = None, color_by_time=False) ndarray
Project all given tracks into a single image
A track is displayed as the line of its consecutive positions. Track’s undefined positions are not displayed.
- Parameters:
tracks_tensor (torch.Tensor) – Tracks tensor (See byotrack.Track.tensorize) Positions of each track at each frame. (NaN if not defined). Shape: (T, N, 2)
colors (Sequence[Tuple[int, int, int]]) – Color sequence. When we color each track independently, each track is associated with a color (ith track with ith color, it loops if more tracks than colors). For time coloring, each frame has its own color (same across all tracks). Default: ((255, 255, 255),) (Everything is white)
background (Optional[np.ndarray]) – Optional frame to display behind the tracks. If not given, we set the background as 0, with the smallest size to contain all tracks. Default: None Shape: (H, W[, C])
color_by_time (bool) – If set to True, each frame has its own color. Otherwise, each track has its own color. Color by time is much slower (cv2 do not allow complex multilines draw) Default: False
- Returns:
- Projection image
Shape: (H, W, 3), dtype: np.uint8
- Return type:
np.ndarray
- class byotrack.visualize.InteractiveVisualizer(video: Sequence[ndarray] | None = None, detections_sequence: Collection[Detections] = (), tracks: Collection[Track] = ())
Bases:
objectInteractive visualization with opencv
- Keys:
space: Pause/Unpause the video
w/x: Move backward/forward in the video (when paused)
d: Switch detections display mode (Not displayed, Mask, Segmentation) if available
t: Switch on/off the display of tracks if available
v: Switch on/off the display of the video
- video
Optional video to display. Should be normalized in [0, 1] Default: None
- Type:
Optional[Sequence[np.ndarray]]
- detections_sequence
Optional detections to display Default: () (no detections)
- Type:
Collection[byotrack.Detections]
- tracks
Optional tracks to display Default: () (no tracks)
- Type:
Collection[byotrack.Tracks]