Reference for ultralytics/trackers/track.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/track.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.trackers.track.on_predict_start
Initialize trackers for object tracking during prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor |
object
|
The predictor object to initialize trackers for. |
required |
persist |
bool
|
Whether to persist the trackers if they already exist. |
False
|
Raises:
Type | Description |
---|---|
AssertionError
|
If the tracker_type is not 'bytetrack' or 'botsort'. |
Examples:
Initialize trackers for a predictor object:
Source code in ultralytics/trackers/track.py
ultralytics.trackers.track.on_predict_postprocess_end
Postprocess detected boxes and update with object tracking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor |
object
|
The predictor object containing the predictions. |
required |
persist |
bool
|
Whether to persist the trackers if they already exist. |
False
|
Examples:
Postprocess predictions and update with tracking
Source code in ultralytics/trackers/track.py
ultralytics.trackers.track.register_tracker
Register tracking callbacks to the model for object tracking during prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
object
|
The model object to register tracking callbacks for. |
required |
persist |
bool
|
Whether to persist the trackers if they already exist. |
required |
Examples:
Register tracking callbacks to a YOLO model