§
    l¬¸j¨  ã                   óJ   — d Z ddlmZ  G d„ d¦  «        Z G d„ d¦  «        ZdS )zKModule defines the base classes and structures for object tracking in YOLO.é    )ÚAnyc                   ó"   — e Zd ZdZdZdZdZdZdS )Ú
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© ó    ún/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/trackers/basetrack.pyr   r      s.   € € € € € ðð ð €CØ€GØ€DØ€G€G€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dS )Ú	BaseTrackaí  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.
        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.

    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                 ón   — d| _         d| _        t          j        | _        d| _        d| _        d| _        dS )zMInitialize a new track with a unique ID and foundational tracking attributes.r   FN)Útrack_idÚis_activatedr   r   ÚstateÚscoreÚstart_frameÚframe_id©Úselfs    r   Ú__init__zBaseTrack.__init__;   s4   € àˆŒØ!ˆÔÝ”^ˆŒ
ØˆŒ
ØˆÔØˆŒˆˆ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_frameD   s   € ð Œ}Ðr   c                  óD   — 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_idI   s!   € õ 	ÐÔ˜AÑÐÔÝÔÐr   ÚargsNc                 ó   — t           ‚)z[Activate the track with provided arguments, initializing necessary attributes for tracking.©ÚNotImplementedError)r   r'   s     r   ÚactivatezBaseTrack.activateO   ó   € å!Ð!r   c                 ó   — t           ‚)zRPredict the next state of the track based on the current state and tracking model.r)   r   s    r   ÚpredictzBaseTrack.predictS   r,   r   Úkwargsc                 ó   — t           ‚)z`Update the track with new observations and data, modifying its state and attributes accordingly.r)   )r   r'   r/   s      r   ÚupdatezBaseTrack.updateW   r,   r   c                 ó(   — t           j        | _        dS )z@Mark the track as lost by updating its state to TrackState.Lost.N)r   r   r   r   s    r   Ú	mark_lostzBaseTrack.mark_lost[   s   € å”_ˆŒ
ˆ
ˆ
r   c                 ó(   — t           j        | _        dS )zEMark the track as removed by setting its state to TrackState.Removed.N)r   r   r   r   s    r   Úmark_removedzBaseTrack.mark_removed_   s   € åÔ'ˆŒ
ˆ
ˆ
r   c                  ó   — dt           _        dS )z7Reset the global track ID counter to its initial value.r   Nr$   r   r   r   Úreset_idzBaseTrack.reset_idc   s   € ð �	ÔÐÐr   )r    N)r	   r
   r   r   r%   r   ÚpropertyÚintr"   Ústaticmethodr&   r   r+   r.   r1   r3   r5   r7   r   r   r   r   r      s)  € € € € € ðð ð8 €Fðð ð ð ð˜3ð ð ð ñ „Xðð ð �Sð  ð  ð  ñ „\ð ð
"˜cð " dð "ð "ð "ð "ð"ð "ð "ð "ð"˜Cð "¨3ð "°4ð "ð "ð "ð "ð%ð %ð %ð %ð(ð (ð (ð (ð ðð ð ñ „\ðð ð r   r   N)r   Útypingr   r   r   r   r   r   ú<module>r<      s�   ðà QÐ Qà Ð Ð Ð Ð Ð ðð ð ð ð ñ ô ð ð*Jð Jð Jð Jð Jñ Jô Jð Jð Jð Jr   