Reference for ultralytics/trackers/basetrack.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/basetrack.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.trackers.basetrack.TrackState
Enumeration class representing the possible states of an object being tracked.
Attributes:
Name | Type | Description |
---|---|---|
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:
ultralytics.trackers.basetrack.BaseTrack
Base class for object tracking, providing foundational attributes and methods.
Attributes:
Name | Type | Description |
---|---|---|
_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:
Name | Description |
---|---|
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:
Examples:
Initialize a new track
Source code in ultralytics/trackers/basetrack.py
activate
Activates the track with provided arguments, initializing necessary attributes for tracking.
mark_lost
mark_removed
next_id staticmethod
predict
reset_id staticmethod
update
Updates the track with new observations and data, modifying its state and attributes accordingly.