Zum Inhalt springen

Referenz fĂŒr ultralytics/trackers/basetrack.py

Hinweis

Diese Datei ist verfĂŒgbar unter https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/trackers/basetrack .py. Wenn du ein Problem entdeckst, hilf bitte mit, es zu beheben, indem du einen Pull Request đŸ› ïž einreichst. Vielen Dank 🙏!



ultralytics.trackers.basetrack.TrackState

AufzÀhlungsklasse, die die möglichen ZustÀnde eines verfolgten Objekts darstellt.

Attribute:

Name Typ Beschreibung
New int

Zustand, wenn das Objekt neu erkannt wird.

Tracked int

Status, wenn das Objekt in den folgenden Frames erfolgreich verfolgt wird.

Lost int

Zustand, wenn das Objekt nicht mehr verfolgt wird.

Removed int

Zustand, wenn das Objekt aus dem Tracking entfernt wird.

Quellcode in ultralytics/trackers/basetrack.py
class TrackState:
    """
    Enumeration class representing the possible states of an object being tracked.

    Attributes:
        New (int): State when the object is newly detected.
        Tracked (int): State when the object is successfully tracked in subsequent frames.
        Lost (int): State when the object is no longer tracked.
        Removed (int): State when the object is removed from tracking.
    """

    New = 0
    Tracked = 1
    Lost = 2
    Removed = 3



ultralytics.trackers.basetrack.BaseTrack

Basisklasse fĂŒr die Objektverfolgung, die grundlegende Attribute und Methoden bereitstellt.

Attribute:

Name Typ Beschreibung
_count int

ZĂ€hler auf Klassenebene fĂŒr eindeutige Track-IDs.

track_id int

Eindeutiger Bezeichner fĂŒr den Track.

is_activated bool

Flagge, die anzeigt, ob der Track gerade aktiv ist.

state TrackState

Aktueller Stand der Strecke.

history OrderedDict

Geordnete Geschichte der ZustÀnde des Tracks.

features list

Liste der Merkmale, die fĂŒr das Tracking aus dem Objekt extrahiert wurden.

curr_feature any

Das aktuelle Merkmal des verfolgten Objekts.

score float

Der Konfidenzwert des Trackings.

start_frame int

Die Rahmennummer, bei der die Verfolgung begann.

frame_id int

Die letzte Frame-ID, die vom Track verarbeitet wurde.

time_since_update int

Frames, die seit der letzten Aktualisierung vergangen sind.

location tuple

Der Standort des Objekts im Rahmen des Multi-Kamera-Trackings.

Methoden:

Name Beschreibung
end_frame

Gibt die ID des letzten Frames zurĂŒck, auf dem das Objekt verfolgt wurde.

next_id

Erhöht die nĂ€chste globale Track-ID und gibt sie zurĂŒck.

activate

Abstrakte Methode zur Aktivierung des Tracks.

predict

Abstrakte Methode zur Vorhersage des nÀchsten Zustands der Strecke.

update

Abstrakte Methode zur Aktualisierung des Tracks mit neuen Daten.

mark_lost

Markiert den Track als verloren.

mark_removed

Markiert den Track als entfernt.

reset_id

Setzt den globalen Track-ID-ZĂ€hler zurĂŒck.

Quellcode in ultralytics/trackers/basetrack.py
class BaseTrack:
    """
    Base class for object tracking, providing foundational attributes and methods.

    Attributes:
        _count (int): Class-level counter for unique track IDs.
        track_id (int): Unique identifier for the track.
        is_activated (bool): Flag indicating whether the track is currently active.
        state (TrackState): Current state of the track.
        history (OrderedDict): Ordered history of the track's states.
        features (list): List of features extracted from the object for tracking.
        curr_feature (any): The current feature of the object being tracked.
        score (float): The confidence score of the tracking.
        start_frame (int): The frame number where tracking started.
        frame_id (int): The most recent frame ID processed by the track.
        time_since_update (int): Frames passed since the last update.
        location (tuple): The location of the object in the context of multi-camera tracking.

    Methods:
        end_frame: Returns the ID of the last frame where the object was tracked.
        next_id: Increments and returns the next global track ID.
        activate: Abstract method to activate the track.
        predict: Abstract method to predict the next state of the track.
        update: Abstract method to update the track with new data.
        mark_lost: Marks the track as lost.
        mark_removed: Marks the track as removed.
        reset_id: Resets the global track ID counter.
    """

    _count = 0

    def __init__(self):
        """Initializes a new track with unique ID and foundational tracking attributes."""
        self.track_id = 0
        self.is_activated = False
        self.state = TrackState.New
        self.history = OrderedDict()
        self.features = []
        self.curr_feature = None
        self.score = 0
        self.start_frame = 0
        self.frame_id = 0
        self.time_since_update = 0
        self.location = (np.inf, np.inf)

    @property
    def end_frame(self):
        """Return the last frame ID of the track."""
        return self.frame_id

    @staticmethod
    def next_id():
        """Increment and return the global track ID counter."""
        BaseTrack._count += 1
        return BaseTrack._count

    def activate(self, *args):
        """Abstract method to activate the track with provided arguments."""
        raise NotImplementedError

    def predict(self):
        """Abstract method to predict the next state of the track."""
        raise NotImplementedError

    def update(self, *args, **kwargs):
        """Abstract method to update the track with new observations."""
        raise NotImplementedError

    def mark_lost(self):
        """Mark the track as lost."""
        self.state = TrackState.Lost

    def mark_removed(self):
        """Mark the track as removed."""
        self.state = TrackState.Removed

    @staticmethod
    def reset_id():
        """Reset the global track ID counter."""
        BaseTrack._count = 0

end_frame property

Gibt die letzte Frame-ID des Tracks zurĂŒck.

__init__()

Initialisiert einen neuen Track mit einer eindeutigen ID und grundlegenden Tracking-Attributen.

Quellcode in ultralytics/trackers/basetrack.py
def __init__(self):
    """Initializes a new track with unique ID and foundational tracking attributes."""
    self.track_id = 0
    self.is_activated = False
    self.state = TrackState.New
    self.history = OrderedDict()
    self.features = []
    self.curr_feature = None
    self.score = 0
    self.start_frame = 0
    self.frame_id = 0
    self.time_since_update = 0
    self.location = (np.inf, np.inf)

activate(*args)

Abstrakte Methode zur Aktivierung des Tracks mit angegebenen Argumenten.

Quellcode in ultralytics/trackers/basetrack.py
def activate(self, *args):
    """Abstract method to activate the track with provided arguments."""
    raise NotImplementedError

mark_lost()

Markiere die Spur als verloren.

Quellcode in ultralytics/trackers/basetrack.py
def mark_lost(self):
    """Mark the track as lost."""
    self.state = TrackState.Lost

mark_removed()

Markiere die Spur als entfernt.

Quellcode in ultralytics/trackers/basetrack.py
def mark_removed(self):
    """Mark the track as removed."""
    self.state = TrackState.Removed

next_id() staticmethod

Erhöht den globalen Track-ID-ZĂ€hler und gibt ihn zurĂŒck.

Quellcode in ultralytics/trackers/basetrack.py
@staticmethod
def next_id():
    """Increment and return the global track ID counter."""
    BaseTrack._count += 1
    return BaseTrack._count

predict()

Abstrakte Methode zur Vorhersage des nÀchsten Zustands der Strecke.

Quellcode in ultralytics/trackers/basetrack.py
def predict(self):
    """Abstract method to predict the next state of the track."""
    raise NotImplementedError

reset_id() staticmethod

Setzt den globalen Track-ID-ZĂ€hler zurĂŒck.

Quellcode in ultralytics/trackers/basetrack.py
@staticmethod
def reset_id():
    """Reset the global track ID counter."""
    BaseTrack._count = 0

update(*args, **kwargs)

Abstrakte Methode zur Aktualisierung des Tracks mit neuen Beobachtungen.

Quellcode in ultralytics/trackers/basetrack.py
def update(self, *args, **kwargs):
    """Abstract method to update the track with new observations."""
    raise NotImplementedError





Erstellt am 2023-11-12, Aktualisiert am 2024-05-08
Autoren: Burhan-Q (1), glenn-jocher (3)