ListOfGlobalFragments#

Warning

The code reference is a work in progress and may contain inconsistencies.

class idtrackerai.ListOfGlobalFragments(global_fragments: Iterable[GlobalFragment])[source]#

Contains all the instances of the class GlobalFragment.

It contains methods to retrieve information from these global fragments and to update their attributes. These methods are mainly used during the cascade of training and identification protocols.

Parameters:

global_fragments (list) – List of instances of GlobalFragment.

__init__(global_fragments: Iterable[GlobalFragment])[source]#
global_fragments: list[GlobalFragment]#

List of global fragments which are candidate for accumulation

non_accumulable_global_fragments: list[GlobalFragment]#

List of global fragments which are NOT candidate for accumulation

classmethod from_fragments(blobs_in_video: list[list[Blob]], fragments: list[Fragment], num_animals: int) ListOfGlobalFragments[source]#

Creates the list of instances of the class GlobalFragment.

Parameters:
  • blobs_in_video (list[list[Blob]]) – All blobs in video

  • fragments (list[Fragment]) – All Fragments in video

  • num_animals (int) – Number of animals to be tracked as indicated by the user.

Returns:

The list of all Global Fragments

Return type:

ListOfGlobalFragments

sort_by_distance_to_the_frame(frame_number: int)[source]#

Sorts the global fragments with respect to their distance from the first global fragment chose for accumulation.

save(path: Path | str)[source]#

Saves an instance of the class.

Before saving the instances of fragments associated to every global fragment are removed and reset them after saving. This prevents problems when pickling objects inside of objects.

Parameters:

path (Path | str) – Path where the object will be stored

classmethod load(path: Path | str, fragments: list[Fragment] | None = None) ListOfGlobalFragments[source]#

Loads an instance of the class saved with save()

Parameters:
  • path (str) – Path where the object to be loaded is stored.

  • fragments (list) – List of all the instances of the class Fragment in the video.

single_global_fragment() bool[source]#

Returns True if there is only one global fragment in the list.

Deprecated since version 6.0.0: Use len(ListOfGlobalFragments.global_fragments) == 1 instead

no_global_fragment() bool[source]#

Returns True if there are no global fragments in the list.

Deprecated since version 6.0.0: Use len(ListOfGlobalFragments.global_fragments) == 0 instead