dgs.utils.track.Tracks

class dgs.utils.track.Tracks(N: int, thresh: int | None = None, start_frame: int = 0)[source]

Multiple Track objects stored as a dictionary, where the Track is the value and the key is this tracks’ unique ID.

Methods

__init__(N: int, thresh: int | None = None, start_frame: int = 0) None[source]
add(tracks: dict[int, State], new: list[State]) list[int][source]

Given tracks with existing Track-IDs update those and create new Tracks for States without Track-IDs. Additionally, mark Track-IDs that are not in either of the inputs as unseen and therefore as inactive for one more step.

Returns:

The Track-IDs of the new_tracks in the same order as provided.

add_empty_tracks(n: int = 1) list[int][source]

Given a Track, compute the next track-ID, and save this track in data using this ID.

Parameters:

n – The number of new Tracks to add.

Returns:

The track-IDs of the added tracks.

Return type:

tids

clear() None.  Remove all items from D.
copy() Tracks[source]

Return a (deep) copy of this object.

classmethod fromkeys(iterable, value=None)
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
get_active_states() list[State][source]

Get the last state of every active track in this object as a State.

get_states() tuple[list[State], list[int]][source]

Get the last state of every track in this object as a State.

is_active(tid: int) bool[source]

Return whether the given Track-ID is active.

is_inactive(tid: int) bool[source]

Return whether the given Track-ID is inactive.

is_removed(tid: int) bool[source]

Return whether the given Track-ID has been removed.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

reactivate_track(tid: int) None[source]

Given the track-ID of a previously removed track, reactivate it.

remove_tid(tid: int) None[source]

Given a Track-ID, remove the track associated with it from this object.

remove_tids(tids: list[int]) None[source]
reset() None[source]

Reset this object.

reset_deleted() None[source]

Fully remove the deleted Tracks.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
to(*args, **kwargs) Tracks[source]

Create function similar to torch.Tensor.to() .

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values

Attributes

N

age

ages

Get the age of all the tracks (in frames).

ids

Get all the track-IDs in this object.

ids_active

Get all the track-IDs currently active.

ids_inactive

Get all the track-IDs currently inactive.

ids_removed

Get all the track-IDs that have been deleted.

nof_active

Get the number of active Tracks.

nof_inactive

Get the number of inactive Tracks.

nof_removed

Get the number of Tracks that have been removed.

data

All the Tracks that are currently tracked, including inactive Tracks as mapping 'Track-ID -> Track'.

inactive

All the inactive Tracks as 'Track-ID -> number of inactive frames / steps'.

inactivity_threshold

The number of steps a Track can be inactive before deleting it.

removed

All the Tracks that have been removed, to be able to reactivate them.