Linker

class byotrack.api.linker.Linker

Bases: ABC

Base class for linkers in videos.

Link detections through time to build tracks.

Each linker can define a set of parameters (See ParametrizedObjectMixin)

abstractmethod run(video: Sequence[np.ndarray] | np.ndarray, detections_sequence: Sequence[byotrack.Detections]) Collection[byotrack.Track]

Run the linker on a whole video.

Parameters:
  • video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)

  • detections_sequence (Sequence[byotrack.Detections]) – Detections for each frame Detections is expected for each frame of the video, in the same order. (Note that for a given frame, the Detections can be empty)

Returns:

Tracks of particles

Return type:

Collection[byotrack.Track]

class byotrack.api.linker.OnlineLinker

Bases: Linker

Online linker, it tracks particles 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 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, 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) – 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, detections_sequence: Sequence[byotrack.Detections]) Collection[byotrack.Track]

Run the linker on a whole video.

Parameters:
  • video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)

  • detections_sequence (Sequence[byotrack.Detections]) – Detections for each frame Detections is expected for each frame of the video, in the same order. (Note that for a given frame, the Detections can be empty)

Returns:

Tracks of particles

Return type:

Collection[byotrack.Track]