Linker
- class byotrack.api.linker.Linker
Bases:
ABCBase class for linkers in videos.
A linker solves the tracking as the optimal links of detections through time.
- abstractmethod run(video: Sequence[np.ndarray] | np.ndarray | None, detections_sequence: Sequence[byotrack.DetectionsLike]) Collection[byotrack.Track]
Run the linker on a whole sequence.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray | None) – Optional video sequence of T frames. Each frame (array) is expected to have a shape ([D, ]H, W, C). Some linkers may not require any video. In that case, you may provide explicitly None.
detections_sequence (Sequence[byotrack.DetectionsLike]) – Detections are expected for for each frame of the video (sorted in time). Note that for a given frame, the Detections can be empty (i.e. Detections.length = 0).
- Returns:
Tracks for the given detections.
- Return type:
Collection[byotrack.Track]
- class byotrack.api.linker.OnlineLinker
Bases:
LinkerOnline linker. Build tracks one frame at a time.
The linking algorithm is dividing into three steps:
reset(): Reset the algorithm.update(): Update the algorithm with a new frame and its detections.collect(): Collect the constructed tracks up to the last frame.
- reset(dim=2) None
Reset the linking algorithm.
Flush all data stored from a previous linking and prepare a new linking.
- Parameters:
dim (int) – The dimension of the data. Default: 2
- abstractmethod update(frame: np.ndarray | None, detections: byotrack.Detections) None
Progress in the linking step by one frame.
Will update the internal algorithm by a single frame and its detections.
- Parameters:
frame (np.ndarray | None) – Optional frame of the video. Shape: ([D, ]H, W, C), dtype: float
detections (byotrack.Detections) – Detections for the given frame.
- abstractmethod collect() Collection[byotrack.Track]
Collect and build all the tracks up to the last given frame.
- Returns:
Tracks from the last reset to the last given frame.
- Return type:
Collection[byotrack.Track]
- run(video: Sequence[np.ndarray] | np.ndarray | None, detections_sequence: Sequence[byotrack.DetectionsLike]) Collection[byotrack.Track]
Run the linker on a whole sequence.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray | None) – Optional video sequence of T frames. Each frame (array) is expected to have a shape ([D, ]H, W, C). Some linkers may not require any video. In that case, you may provide explicitly None.
detections_sequence (Sequence[byotrack.DetectionsLike]) – Detections are expected for for each frame of the video (sorted in time). Note that for a given frame, the Detections can be empty (i.e. Detections.length = 0).
- Returns:
Tracks for the given detections.
- Return type:
Collection[byotrack.Track]