YOLOv8 with BoT-SORT: Real-Time Object Detection and Tracking

YOLOv8 with BoT-SORT combines real-time object detection with multi-object tracking. YOLOv8 detects objects in each video frame, while BoT-SORT associates those detections across frames and assigns persistent tracking IDs. In the current Ultralytics tracking system, BoT-SORT is available as a built-in tracker and is the default tracker used by model.track() unless another tracker is selected.

Table of Contents

Introduction to YOLOv8 with BoT-SORT

Object detection identifies what objects appear in a frame and where they are located. Object tracking adds temporal information by determining whether a detection in one frame represents the same object seen in earlier frames.

YOLOv8 can handle the detection stage, while BoT-SORT manages object association and identity over time.

The combination is useful for applications such as people tracking, vehicle monitoring, surveillance, traffic analysis, sports analytics, and crowd monitoring.

BoT-SORT is integrated into the Ultralytics tracking workflow and can be selected using the botsort.yaml tracker configuration.

What Is BoT-SORT in YOLOv8?

BoT-SORT is a multi-object tracking algorithm designed to associate detections across video frames while maintaining stable object identities.

Within the Ultralytics ecosystem, BoT-SORT can use motion prediction, global camera motion compensation, detection-score-aware matching, and optional appearance-based Re-Identification.

Role of YOLOv8 in Object Detection

YOLOv8 processes each frame and predicts information such as:

bounding box
object class
confidence score

For example:

person → 0.94
car → 0.89
truck → 0.82

These detections provide the observations that the tracker needs.

YOLOv8 determines what objects are visible, while BoT-SORT determines how those detections relate to tracks from previous frames.

Role of BoT-SORT in Multi-Object Tracking

BoT-SORT maintains an identity for each tracked object.

For example:

Frame 1:
Person → ID 5

Frame 2:
Person → ID 5

Frame 3:
Person → ID 5

Instead of treating every detection as a completely new object, the tracker compares it with existing tracks and attempts to maintain the same ID.

This makes it possible to count unique objects and analyze their movement over time.

How YOLOv8 and BoT-SORT Work Together

The overall tracking pipeline can be represented as:

Video Frame
     ↓
YOLOv8 Detection
     ↓
Bounding Boxes + Classes + Confidence
     ↓
BoT-SORT
     ↓
Track Association
     ↓
Persistent Object IDs

The process repeats for every frame.

Detecting Objects with YOLOv8

YOLOv8 first performs normal inference on the frame.

When using the Ultralytics tracking interface, this detection process is handled internally:

from ultralytics import YOLO

model = YOLO("yolov8n.pt")

results = model.track(
    source="video.mp4",
    tracker="botsort.yaml"
)

The tracker then works with the detections generated by the model. BoT-SORT is directly supported through the Ultralytics tracking mode.

Passing Detections to the Tracker

The tracker receives detection information including object position and confidence.

BoT-SORT then evaluates which detections are likely to belong to existing tracks.

The association process can consider:

  • motion predictions,
  • bounding box overlap,
  • detection confidence,
  • camera motion,
  • appearance similarity when ReID is enabled.

The current Ultralytics BoT-SORT configuration includes options such as match_thresh, fuse_score, gmc_method, proximity_thresh, appearance_thresh, and with_reid.

Assigning and Maintaining Tracking IDs

When a new object is detected and cannot be matched to an existing track, BoT-SORT can create a new tracking ID.

For example:

Car A → ID 7
Car B → ID 11
Person → ID 15

In later frames, the tracker attempts to associate new detections with these active tracks.

If the association succeeds, the same ID continues.

How BoT-SORT Tracks Objects

BoT-SORT combines several tracking mechanisms instead of relying on only one matching rule.

Motion Prediction and Kalman Filtering

BoT-SORT uses a Kalman-filter-based motion model to estimate where a tracked object is likely to appear in the next frame. The Ultralytics tracker documentation describes BoT-SORT as using a linear Kalman motion model.

For example, if a car is moving steadily toward the right side of the frame, the tracker can predict its expected next location.

This prediction helps associate the correct detection with the existing track.

Appearance-Based Re-Identification

BoT-SORT can optionally use Re-Identification, or ReID, features.

ReID analyzes the appearance of detected objects and creates feature representations that help distinguish between visually different targets.

This can be particularly useful when:

  • objects cross paths,
  • an object is briefly hidden,
  • multiple objects are close together,
  • motion information alone becomes ambiguous.

In the current Ultralytics botsort.yaml, ReID support exists but with_reid is set to False by default. It can be enabled through a custom tracker configuration.

Camera Motion Compensation

One important feature of BoT-SORT is Global Motion Compensation, or GMC.

When the camera itself moves, object positions can shift even when objects remain stationary in the real world.

BoT-SORT attempts to compensate for this camera movement before associating detections.

The current Ultralytics BoT-SORT configuration uses:

gmc_method: sparseOptFlow

by default, while supported methods include alternatives such as orb, sift, ecc, and none.

This feature can be useful for tracking from moving cameras, drones, or handheld video.

How to Set Up YOLOv8 with BoT-SORT

Because BoT-SORT is built into the Ultralytics tracking workflow, setup is simpler than integrating an external tracker manually.

Install the Required Libraries

Install Ultralytics:

pip install ultralytics

For video processing, OpenCV can also be useful:

pip install opencv-python

Then import YOLO:

from ultralytics import YOLO

Load a YOLOv8 Model

Load a pretrained YOLOv8 detection model:

from ultralytics import YOLO

model = YOLO("yolov8n.pt")

You can also use custom weights:

model = YOLO("best.pt")

Ultralytics tracking supports custom-trained YOLO models in addition to standard pretrained checkpoints.

Configure the BoT-SORT Tracker

BoT-SORT can be selected explicitly using:

results = model.track(
    source="video.mp4",
    tracker="botsort.yaml"
)

It is also the current default tracker in Ultralytics tracking mode.

For custom behavior, copy the default botsort.yaml, modify the desired settings, and pass the custom YAML:

results = model.track(
    source="video.mp4",
    tracker="custom_botsort.yaml"
)

Do not change tracker_type to an unsupported value when creating the custom configuration.

Run YOLOv8 with BoT-SORT on Video

YOLOv8 and BoT-SORT can process a saved video, camera source, or stream.

Process Video Frames

A simple video example is:

from ultralytics import YOLO

model = YOLO("yolov8n.pt")

results = model.track(
    source="video.mp4",
    tracker="botsort.yaml",
    show=True
)

Ultralytics handles detection, tracking, and visualization internally.

For more control, video frames can be processed manually with OpenCV.

Track Multiple Objects in Real Time

For manual frame processing:

import cv2
from ultralytics import YOLO

model = YOLO("yolov8n.pt")

cap = cv2.VideoCapture("video.mp4")

while cap.isOpened():
    success, frame = cap.read()

    if not success:
        break

    results = model.track(
        frame,
        persist=True,
        tracker="botsort.yaml"
    )

cap.release()

persist=True tells the tracker that frames belong to the same sequence so identities can be maintained across consecutive calls.

Display Bounding Boxes and Track IDs

Ultralytics results can be plotted directly:

annotated_frame = results[0].plot()

Tracked boxes can also expose their IDs through the returned result structure when tracking IDs are available.

A typical tracking display might show:

person ID: 3
person ID: 8
car ID: 11

This makes it possible to visually follow objects through the scene.

YOLOv8 BoT-SORT Configuration

BoT-SORT behavior can be adjusted through its tracker YAML file.

The current Ultralytics configuration exposes multiple parameters for detection association, track persistence, camera motion, and optional ReID.

Tracking Confidence Thresholds

Important settings include parameters such as:

track_high_thresh:
track_low_thresh:
new_track_thresh:

These values influence which detections are considered during tracking and when new tracks may be created.

If thresholds are too high, useful detections may be discarded.

If they are too low, false detections may create unstable tracks.

Thresholds should therefore be tuned according to detector quality and scene difficulty.

Matching and Track Buffer Settings

Two important parameters are:

match_thresh:
track_buffer:

match_thresh affects detection-to-track association.

track_buffer determines how long a lost track can remain alive before being removed.

The current default Ultralytics BoT-SORT configuration uses a track buffer of 30 frames. Increasing it can help preserve identities through longer occlusions, but it can also increase the risk of incorrect reassociation.

Re-Identification Settings

Relevant ReID settings include:

with_reid: False
proximity_thresh: 0.5
appearance_thresh: 0.8
model: auto

These are the current values shown in Ultralytics’ default BoT-SORT configuration.

To enable ReID, a custom configuration can set:

with_reid: True

ReID may improve identity consistency in difficult scenes but adds additional computational work.

YOLOv8 with BoT-SORT vs Other Trackers

Different trackers make different tradeoffs between speed, appearance matching, occlusion handling, and complexity.

BoT-SORT vs ByteTrack

Both BoT-SORT and ByteTrack are supported directly by Ultralytics.

ByteTrack focuses heavily on detection association, including the recovery of useful lower-confidence detections.

BoT-SORT adds capabilities such as:

  • global motion compensation,
  • optional appearance-based ReID,
  • motion prediction,
  • detection-score fusion.

Ultralytics describes ByteTrack as having no ReID and no camera-motion compensation in its standard configuration, while BoT-SORT supports both optional ReID and GMC.

BoT-SORT vs DeepSORT

DeepSORT is known for combining motion tracking with deep appearance embeddings.

BoT-SORT also supports appearance-based ReID, but additionally incorporates camera-motion compensation and other association improvements.

A practical difference for YOLOv8 users is integration: BoT-SORT is built directly into current Ultralytics tracking mode, while DeepSORT typically requires an external library and manual detection-to-tracker integration.

Which Tracker Should You Use with YOLOv8?

Use BoT-SORT when:

  • camera movement is important,
  • stable IDs matter,
  • ReID may be useful,
  • you want built-in Ultralytics integration.

Use ByteTrack when:

  • you want a simpler tracker,
  • speed is important,
  • appearance ReID is unnecessary,
  • detection confidence is reliable.

For difficult identity-sensitive applications, test both trackers on your actual video rather than assuming one will always perform better.

Benefits of Using YOLOv8 with BoT-SORT

BoT-SORT adds temporal identity information to YOLOv8 detections.

Better ID Consistency

A tracking system should ideally assign the same ID to an object while it remains visible.

BoT-SORT combines motion information with additional association tools to reduce incorrect identity changes.

When ReID is enabled, visual appearance provides another signal for maintaining identity.

Improved Tracking Through Occlusion

An object may disappear temporarily behind another person, vehicle, or scene element.

The track buffer allows a lost track to remain active for a limited period, while motion prediction estimates where it may reappear.

Optional ReID can provide additional help when reconnecting a detection to an existing track.

Reliable Multi-Object Tracking

BoT-SORT is designed for multi-object tracking, so many objects can be tracked simultaneously.

For example:

Person → ID 1
Person → ID 2
Person → ID 3
Car → ID 4
Bus → ID 5

This makes it useful for crowded scenes, traffic footage, and surveillance video.

Common YOLOv8 BoT-SORT Tracking Problems

Tracking quality depends heavily on detection quality, scene conditions, and tracker configuration.

ID Switching

An ID switch occurs when two objects exchange identities.

For example:

Before crossing:
Person A → ID 4
Person B → ID 7

After crossing:
Person A → ID 7
Person B → ID 4

Possible improvements include:

  • enabling ReID,
  • improving detection accuracy,
  • tuning match_thresh,
  • adjusting appearance_thresh,
  • using better image resolution.

Lost Tracks During Occlusion

If an object remains hidden longer than the allowed track lifetime, its track may be removed.

When it reappears, it may receive a new ID.

Increasing:

track_buffer:

can keep tracks alive longer, though excessive values can create incorrect associations.

Duplicate Tracking IDs

Sometimes one physical object can eventually receive multiple IDs.

This can happen when:

  • detections disappear,
  • tracking confidence becomes weak,
  • the object is heavily occluded,
  • the previous track expires.

Improving detector consistency and tuning track lifetime can reduce these cases.

Slow Real-Time Performance

Tracking adds processing beyond normal YOLOv8 detection.

The workload may include:

YOLO inference
+
motion association
+
camera motion compensation
+
optional ReID
+
visualization

To improve speed:

  • use yolov8n.pt or another smaller model,
  • lower image resolution,
  • disable ReID when unnecessary,
  • use GPU acceleration,
  • track only required classes.

ReID especially adds additional computational cost, which is one reason it is disabled by default in the current Ultralytics BoT-SORT configuration.

Applications of YOLOv8 with BoT-SORT

YOLOv8 with BoT-SORT is useful wherever objects need to be followed across video frames.

Person Tracking

A person-tracking system can assign unique IDs to individuals.

For example:

Person 1 → ID 5
Person 2 → ID 9
Person 3 → ID 14

These IDs can support:

  • people counting,
  • movement analysis,
  • entrance monitoring,
  • trajectory analysis.

Vehicle and Traffic Tracking

Vehicles can be detected and followed across road scenes.

Possible uses include:

  • traffic counting,
  • lane analysis,
  • vehicle trajectories,
  • intersection monitoring,
  • parking analysis.

Camera-motion compensation may also be useful for tracking from moving platforms.

Surveillance and Crowd Monitoring

Tracking adds temporal information to surveillance systems.

Instead of detecting the same person as a new object in every frame, persistent IDs allow the system to follow movement through a scene.

This can support:

  • crowd flow analysis,
  • occupancy measurement,
  • entry and exit counting,
  • movement pattern analysis.

FAQs About YOLOv8 with BoT-SORT

Can YOLOv8 be used with BoT-SORT?

Yes. BoT-SORT is directly supported by the Ultralytics tracking framework and can be selected using:

tracker="botsort.yaml"

It is also currently the default Ultralytics tracker.

How does BoT-SORT work with YOLOv8?

YOLOv8 detects objects in each video frame. BoT-SORT then associates those detections with previous tracks using motion information, detection matching, camera-motion compensation, and optionally appearance-based ReID.

The result is persistent object IDs across frames.

Is BoT-SORT included with Ultralytics YOLOv8?

Yes. BoT-SORT is integrated into the current Ultralytics multi-object tracking system through botsort.yaml.

You do not normally need to install a separate BoT-SORT package when using standard Ultralytics tracking mode.

What is the difference between BoT-SORT and ByteTrack?

Both are multi-object trackers supported by Ultralytics.

ByteTrack uses motion-based association and a two-stage approach that can recover lower-confidence detections.

BoT-SORT additionally supports global camera-motion compensation and optional ReID appearance matching.

Is BoT-SORT better than DeepSORT?

Not in every scenario.

Both can use appearance information to improve identity consistency, but BoT-SORT additionally includes camera-motion compensation and is directly integrated with Ultralytics.

DeepSORT remains useful in applications where its specific appearance-based tracking workflow is preferred.

The best tracker should be selected by testing on the target video and evaluating identity stability, speed, and occlusion handling.

Can BoT-SORT track multiple object classes?

Yes.

Because YOLOv8 supplies class-aware detections, BoT-SORT can maintain tracks for many detected objects and classes in the same video.

You can also restrict YOLOv8 inference to selected classes when only certain categories need to be tracked.

Is YOLOv8 with BoT-SORT suitable for real-time tracking?

Yes, it can be suitable for real-time or near-real-time multi-object tracking.

Actual performance depends on:

  • YOLOv8 model size,
  • input resolution,
  • hardware,
  • number of detected objects,
  • ReID configuration,
  • video resolution.

Smaller YOLOv8 models and GPU acceleration are usually preferable when frame rate is a priority.

Conclusion

YOLOv8 with BoT-SORT provides a practical real-time tracking pipeline that combines YOLOv8 object detection with persistent multi-object identities.

YOLOv8 determines what objects are present and where they are located. BoT-SORT then associates those detections across frames using a linear Kalman motion model, score-aware matching, camera-motion compensation, track persistence, and optional appearance-based ReID.

The basic workflow is:

Video
  ↓
YOLOv8 Detection
  ↓
Bounding Boxes + Classes + Confidence
  ↓
BoT-SORT
  ↓
Motion + Matching + Optional ReID
  ↓
Persistent Tracking IDs

Because BoT-SORT is built directly into the current Ultralytics tracking system, it is easier to integrate with YOLOv8 than trackers that require separate libraries. Its configurable tracking thresholds, track buffer, camera-motion compensation, and optional ReID make it suitable for person tracking, vehicle monitoring, surveillance, traffic analysis, and other multi-object tracking applications.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top