Tracks

class byotrack.api.tracks.Track(start: int, points: Tensor, identifier: int | None = None)

Bases: object

Track for a given particle

A track is defined by an (non-unique) identifier, a starting frame and a succession of positions.

identifier

Identifier of the track (non-unique)

Type:

int

start

Starting frame of the track

Type:

int

points

Positions (i, j) of the particle (from starting frame to ending frame) Shape: (T, D), dtype: float32

Type:

torch.Tensor

overlaps_with(other: Track, tolerance=0) bool

Test if this track overlaps with another one in time.

Parameters:
  • other (Track) – The other track

  • tolerance (int) – Time tolerance before detecting an overlap. Default: 0 (no tolerance)

static tensorize(tracks: Collection[Track], frame_range: Tuple[int, int] | None = None) Tensor

Convert a collection of tracks into a tensor on a given frame_range

Useful view of the data to speedup some mathematical operations

Parameters:
  • tracks (Collection[Track]) – A collection of tracks (usually from the same video)

  • frame_range (Optional[Tuple[int, int]]) – Frame range (start included, end excluded) If None, the minimal range to hold all points is computed

Returns:

Tracks data in a single tensor

Shape: (T, N, D), dtype: float32

Return type:

torch.Tensor

static save(tracks: Collection[Track], path: str | PathLike) None

Save a collection of tracks to path

Parameters:
static load(path: str | PathLike) Collection[Track]

Load a collection of tracks from path

Parameters:

path (str | os.PathLike) – Input path