انتقل إلى المحتوى

مرجع ل ultralytics/trackers/basetrack.py

ملاحظه

هذا الملف متاح في https://github.com/ultralytics/ultralytics/ نقطة / الرئيسية /ultralytics/بتتبع/basetrack.py. إذا اكتشفت مشكلة ، فيرجى المساعدة في إصلاحها من خلال المساهمة في طلب 🛠️ سحب. شكرا لك 🙏!



ultralytics.trackers.basetrack.TrackState

فئة التعداد التي تمثل الحالات المحتملة لكائن يتم تعقبه.

سمات:

اسم نوع وصف
New int

اذكر متى تم اكتشاف الكائن حديثا.

Tracked int

اذكر متى يتم تتبع الكائن بنجاح في الإطارات اللاحقة.

Lost int

اذكر متى لم يعد يتم تعقب الكائن.

Removed int

اذكر متى تتم إزالة الكائن من التعقب.

شفرة المصدر في 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

فئة أساسية لتتبع الكائن ، وتوفير السمات والأساليب الأساسية.

سمات:

اسم نوع وصف
_count int

عداد على مستوى الفصل لمعرفات المسار الفريدة.

track_id int

معرف فريد للمسار.

is_activated bool

علامة تشير إلى ما إذا كان المسار نشطا حاليا أم لا.

state TrackState

الوضع الحالي للمسار.

history OrderedDict

التاريخ المرتب لحالات المسار.

features list

قائمة الميزات المستخرجة من الكائن للتعقب.

curr_feature any

الميزة الحالية للكائن الذي يتم تعقبه.

score float

درجة الثقة في التتبع.

start_frame int

رقم الإطار حيث بدأ التتبع.

frame_id int

أحدث معرف إطار تمت معالجته بواسطة المسار.

time_since_update int

مرت الإطارات منذ التحديث الأخير.

location tuple

موقع الكائن في سياق التتبع متعدد الكاميرات.

أساليب:

اسم وصف
end_frame

ترجع معرف الإطار الأخير حيث تم تعقب الكائن.

next_id

يزيد معرف المسار العام التالي ويقوم بإرجاعه.

activate

طريقة مجردة لتفعيل المسار.

predict

طريقة مجردة للتنبؤ بالحالة التالية للمسار.

update

طريقة مجردة لتحديث المسار ببيانات جديدة.

mark_lost

يضع علامة على المسار كمفقود.

mark_removed

يضع علامة على المسار كمحذوف.

reset_id

إعادة تعيين عداد معرف المسار العام.

شفرة المصدر في 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

إرجاع معرف الإطار الأخير للمسار.

__init__()

تهيئة مسار جديد بمعرف فريد وسمات تتبع أساسية.

شفرة المصدر في 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)

طريقة مجردة لتنشيط المسار مع الوسيطات المقدمة.

شفرة المصدر في ultralytics/trackers/basetrack.py
def activate(self, *args):
    """Abstract method to activate the track with provided arguments."""
    raise NotImplementedError

mark_lost()

ضع علامة على المسار كمفقود.

شفرة المصدر في ultralytics/trackers/basetrack.py
def mark_lost(self):
    """Mark the track as lost."""
    self.state = TrackState.Lost

mark_removed()

ضع علامة على المسار كتمت إزالته.

شفرة المصدر في ultralytics/trackers/basetrack.py
def mark_removed(self):
    """Mark the track as removed."""
    self.state = TrackState.Removed

next_id() staticmethod

زيادة وإرجاع عداد معرف المسار العام.

شفرة المصدر في ultralytics/trackers/basetrack.py
@staticmethod
def next_id():
    """Increment and return the global track ID counter."""
    BaseTrack._count += 1
    return BaseTrack._count

predict()

طريقة مجردة للتنبؤ بالحالة التالية للمسار.

شفرة المصدر في ultralytics/trackers/basetrack.py
def predict(self):
    """Abstract method to predict the next state of the track."""
    raise NotImplementedError

reset_id() staticmethod

إعادة تعيين عداد معرف المسار العام.

شفرة المصدر في ultralytics/trackers/basetrack.py
@staticmethod
def reset_id():
    """Reset the global track ID counter."""
    BaseTrack._count = 0

update(*args, **kwargs)

طريقة مجردة لتحديث المسار بملاحظات جديدة.

شفرة المصدر في ultralytics/trackers/basetrack.py
def update(self, *args, **kwargs):
    """Abstract method to update the track with new observations."""
    raise NotImplementedError





تم الإنشاء 2023-11-12، تم التحديث 2024-05-08
المؤلفون: برهان-Q (1)، جلين-جوتشر (3)