Cleaner

class byotrack.implementation.refiner.cleaner.Cleaner(min_length: int, max_dist: float)

Bases: Refiner

Cleaner refiner

Split tracklet when the distance between two consecutive points is greater than max_dist. And delete tracks that are shorter than min_length.

Warning

It will not split when the position of the track is NaN.

Warning

merge_id is only set on the last splitted track, which may be deleted (if too short).

min_length

Minimum length of tracks kept

Type:

int

max_dist

Maximum distance between two consecutive points in a track

Type:

float

run(video, tracks: Collection[Track]) List[Track]

Run the refiner 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)

  • tracks (Collection[byotrack.Track]) – Tracks of particles

Returns:

Refined tracks of particles

Return type:

Collection[byotrack.Track]

static clean_tracks(tracks: Collection[Track], min_length: int, max_dist: float) List[Track]

Clean tracks

Split tracklet when the distance between two consecutive points is greater than max_dist. And delete tracks that are shorter than min_length.

Warning

It will not split when the position of the track is NaN.

Warning

parent_id is only set on the first splitted track, which may be deleted (if too short). merge_id is only set on the last splitted track, which may be deleted (if too short).

Parameters:
  • tracks (Collection[Track]) – Tracks to clean

  • min_length (int) – Minimum length of tracks kept

  • max_dist (float) – Maximum distance between two consecutive points in a track If max_dist <= 0, splitting is not done

Returns:

Cleaned tracks

Return type:

List[Tracklet]