Ë
    Fêñi  ã                   óP   — d Z ddlmZ ddlmZ ddlZ G d„ d«      Z G d„ d«      Zy)	zKModule defines the base classes and structures for object tracking in YOLO.é    )ÚOrderedDict)ÚAnyNc                   ó    — e Zd ZdZdZdZdZdZy)Ú
TrackStatea  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.

    Examples:
        >>> state = TrackState.New
        >>> if state == TrackState.New:
        ...     print("Object is newly detected.")
    r   é   é   é   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚNewÚTrackedÚLostÚRemoved© ó    ú`/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/trackers/basetrack.pyr   r   
   s   „ ñð €CØ€GØ€DØ�Gr   r   c                   ó”   — e Zd ZdZdZd„ Zedefd„«       Ze	defd„«       Z
deddfd	„Zdd
„Zdededdfd„Zdd„Zdd„Ze	dd„«       Zy)Ú	BaseTrackav  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.

    Examples:
        Initialize a new track and mark it as lost:
        >>> track = BaseTrack()
        >>> track.mark_lost()
        >>> print(track.state)  # Output: 2 (TrackState.Lost)
    r   c                 ó  — d| _         d| _        t        j                  | _        t        «       | _        g | _        d| _        d| _	        d| _
        d| _        d| _        t        j                  t        j                  f| _        y)zMInitialize a new track with a unique ID and foundational tracking attributes.r   FN)Útrack_idÚis_activatedr   r   Ústater   ÚhistoryÚfeaturesÚcurr_featureÚscoreÚstart_frameÚframe_idÚtime_since_updateÚnpÚinfÚlocation©Úselfs    r   Ú__init__zBaseTrack.__init__C   sf   € àˆŒØ!ˆÔÜ—^‘^ˆŒ
Ü"“}ˆŒØˆŒØ ˆÔØˆŒ
ØˆÔØˆŒØ!"ˆÔÜŸ™¤§¡Ð(ˆ�r   Úreturnc                 ó   — | j                   S )zDReturn the ID of the most recent frame where the object was tracked.)r    r%   s    r   Ú	end_framezBaseTrack.end_frameQ   s   € ð �}‰}Ðr   c                  óT   — t         xj                  dz  c_        t         j                  S )zIIncrement and return the next unique global track ID for object tracking.r   ©r   Ú_countr   r   r   Únext_idzBaseTrack.next_idV   s!   € ô 	×Ò˜AÑÕÜ×ÑÐr   ÚargsNc                 ó   — t         ‚)z[Activate the track with provided arguments, initializing necessary attributes for tracking.©ÚNotImplementedError)r&   r/   s     r   ÚactivatezBaseTrack.activate\   ó   € ä!Ð!r   c                 ó   — t         ‚)zRPredict the next state of the track based on the current state and tracking model.r1   r%   s    r   ÚpredictzBaseTrack.predict`   r4   r   Úkwargsc                 ó   — t         ‚)z`Update the track with new observations and data, modifying its state and attributes accordingly.r1   )r&   r/   r7   s      r   ÚupdatezBaseTrack.updated   r4   r   c                 ó.   — t         j                  | _        y)z@Mark the track as lost by updating its state to TrackState.Lost.N)r   r   r   r%   s    r   Ú	mark_lostzBaseTrack.mark_losth   s   € ä—_‘_ˆ�
r   c                 ó.   — t         j                  | _        y)zEMark the track as removed by setting its state to TrackState.Removed.N)r   r   r   r%   s    r   Úmark_removedzBaseTrack.mark_removedl   s   € ä×'Ñ'ˆ�
r   c                  ó   — dt         _        y)z7Reset the global track ID counter to its initial value.r   Nr,   r   r   r   Úreset_idzBaseTrack.reset_idp   s   € ð Œ	Õr   )r(   N)r
   r   r   r   r-   r'   ÚpropertyÚintr*   Ústaticmethodr.   r   r3   r6   r9   r;   r=   r?   r   r   r   r   r      sš   „ ñðB €Fò)ð ð˜3ò ó ðð ð �Sò  ó ð ð
"˜cð " dó "ó"ð"˜Cð "¨3ð "°4ó "ó%ó(ð òó ñr   r   )	r   Úcollectionsr   Útypingr   Únumpyr"   r   r   r   r   r   ú<module>rF      s'   ðá Qå #Ý ã ÷ñ ÷*Tò Tr   