# Multi-Object Tracking with Ultralytics YOLO
<img width="1024" src="https://user-images.githubusercontent.com/26833433/243418637-1d6250fd-1515-4c10-a844-a32818ae6d46.png" alt="YOLOv8 trackers visualization">
Object tracking in the realm of video analytics is a critical task that not only identifies the location and class of objects within the frame but also maintains a unique ID for each detected object as the video progresses. The applications are limitless—ranging from surveillance and security to real-time sports analytics.
## Why Choose Ultralytics YOLO for Object Tracking?
The output from Ultralytics trackers is consistent with standard object detection but has the added value of object IDs. This makes it easy to track objects in video streams and perform subsequent analytics. Here's why you should consider using Ultralytics YOLO for your object tracking needs:
- **Efficiency:** Process video streams in real-time without compromising accuracy.
- **Flexibility:** Supports multiple tracking algorithms and configurations.
- **Ease of Use:** Simple Python API and CLI options for quick integration and deployment.
- **Customizability:** Easy to use with custom trained YOLO models, allowing integration into domain-specific applications.
**Video Tutorial:** [Object Detection and Tracking with Ultralytics YOLOv8](https://www.youtube.com/embed/hHyHmOtmEgs?si=VNZtXmm45Nb9s-N-).
## Features at a Glance
Ultralytics YOLO extends its object detection features to provide robust and versatile object tracking:
- **Real-Time Tracking:** Seamlessly track objects in high-frame-rate videos.
- **Multiple Tracker Support:** Choose from a variety of established tracking algorithms.
- **Customizable Tracker Configurations:** Tailor the tracking algorithm to meet specific requirements by adjusting various parameters.
## Available Trackers
Ultralytics YOLO supports the following tracking algorithms. They can be enabled by passing the relevant YAML configuration file such as `tracker=tracker_type.yaml`:
- [BoT-SORT](https://github.com/NirAharon/BoT-SORT) - Use `botsort.yaml` to enable this tracker.
- [ByteTrack](https://github.com/ifzhang/ByteTrack) - Use `bytetrack.yaml` to enable this tracker.
The default tracker is BoT-SORT.
## Tracking
To run the tracker on video streams, use a trained Detect, Segment or Pose model such as YOLOv8n, YOLOv8n-seg and YOLOv8n-pose.
#### Python
```python
from ultralytics import YOLO
# Load an official or custom model
model = YOLO("yolov8n.pt") # Load an official Detect model
model = YOLO("yolov8n-seg.pt") # Load an official Segment model
model = YOLO("yolov8n-pose.pt") # Load an official Pose model
model = YOLO("path/to/best.pt") # Load a custom trained model
# Perform tracking with the model
results = model.track(
source="https://youtu.be/LNwODJXcvt4", show=True
) # Tracking with default tracker
results = model.track(
source="https://youtu.be/LNwODJXcvt4", show=True, tracker="bytetrack.yaml"
) # Tracking with ByteTrack tracker
```
#### CLI
```bash
# Perform tracking with various models using the command line interface
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" # Official Detect model
yolo track model=yolov8n-seg.pt source="https://youtu.be/LNwODJXcvt4" # Official Segment model
yolo track model=yolov8n-pose.pt source="https://youtu.be/LNwODJXcvt4" # Official Pose model
yolo track model=path/to/best.pt source="https://youtu.be/LNwODJXcvt4" # Custom trained model
# Track using ByteTrack tracker
yolo track model=path/to/best.pt tracker="bytetrack.yaml"
```
As can be seen in the above usage, tracking is available for all Detect, Segment and Pose models run on videos or streaming sources.
## Configuration
### Tracking Arguments
Tracking configuration shares properties with Predict mode, such as `conf`, `iou`, and `show`. For further configurations, refer to the [Predict](https://docs.ultralytics.com/modes/predict/) model page.
#### Python
```python
from ultralytics import YOLO
# Configure the tracking parameters and run the tracker
model = YOLO("yolov8n.pt")
results = model.track(
source="https://youtu.be/LNwODJXcvt4", conf=0.3, iou=0.5, show=True
)
```
#### CLI
```bash
# Configure tracking parameters and run the tracker using the command line interface
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" conf=0.3, iou=0.5 show
```
### Tracker Selection
Ultralytics also allows you to use a modified tracker configuration file. To do this, simply make a copy of a tracker config file (for example, `custom_tracker.yaml`) from [ultralytics/cfg/trackers](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/trackers) and modify any configurations (except the `tracker_type`) as per your needs.
#### Python
```python
from ultralytics import YOLO
# Load the model and run the tracker with a custom configuration file
model = YOLO("yolov8n.pt")
results = model.track(
source="https://youtu.be/LNwODJXcvt4", tracker="custom_tracker.yaml"
)
```
#### CLI
```bash
# Load the model and run the tracker with a custom configuration file using the command line interface
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" tracker='custom_tracker.yaml'
```
For a comprehensive list of tracking arguments, refer to the [ultralytics/cfg/trackers](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/trackers) page.
## Python Examples
### Persisting Tracks Loop
Here is a Python script using OpenCV (`cv2`) and YOLOv8 to run object tracking on video frames. This script still assumes you have already installed the necessary packages (`opencv-python` and `ultralytics`). The `persist=True` argument tells the tracker than the current image or frame is the next in a sequence and to expect tracks from the previous image in the current image.
#### Python
```python
import cv2
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO("yolov8n.pt")
# Open the video file
video_path = "path/to/video.mp4"
cap = cv2.VideoCapture(video_path)
# Loop through the video frames
while cap.isOpened():
# Read a frame from the video
success, frame = cap.read()
if success:
# Run YOLOv8 tracking on the frame, persisting tracks between frames
results = model.track(frame, persist=True)
# Visualize the results on the frame
annotated_frame = results[0].plot()
# Display the annotated frame
cv2.imshow("YOLOv8 Tracking", annotated_frame)
# Break the loop if 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord("q"):
break
else:
# Break the loop if the end of the video is reached
break
# Release the video capture object and close the display window
cap.release()
cv2.destroyAllWindows()
```
Please note the change from `model(frame)` to `model.track(frame)`, which enables object tracking instead of simple detection. This modified script will run the tracker on each frame of the video, visualize the results, and display them in a window. The loop can be exited by pressing 'q'.
### Plotting Tracks Over Time
Visualizing object tracks over consecutive frames can provide valuable insights into the movement patterns and behavior of detected objects within a video. With Ultralytics YOLOv8, plotting these tracks is a seamless and efficient process.
In the following example, we demonstrate how to utilize YOLOv8's tracking capabilities to plot the movement of detected objects across multiple video frames. This script involves opening a video file, reading it frame by frame, and utilizing the YOLO model to identify and track various objects. By retaining the center points of the detected bounding boxes and connecting them, we can draw lines that represent the paths followed by the tracked objects.
#### Python
```python
from collections import defaultdict
import cv2
import numpy as np
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO("y
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
yolov8算法DMS驾驶员抽烟-打电话-喝水-吃东西检测, 包含5000多张DMS驾驶员抽烟-打电话-喝水-吃东西检测数据集,数据集目录已经配置好,划分好 train,val, test,并附有data.yaml文件,yolov5、yolov7、yolov8,yolov9等算法可以直接进行训练模型,txt格式标签, 数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 数据集配置目录结构data.yaml: train: ../train/images val: ../valid/images test: ../test/images nc: 4 names: ['drinking', 'eating', 'mobile use', 'smoking']
资源推荐
资源详情
资源评论
收起资源包目录
yolov8算法DMS驾驶员抽烟-打电话-喝水-吃东西分神检测+数据集+pyqt界面 (2000个子文件)
README.md 13KB
README.md 11KB
README.md 3KB
README.md 2KB
【yolov3-YOLOv5-yolov7-yolov8环境配置-教程1】.pdf 6.55MB
yolov8-pyqt运行步骤(配置好环境后执行).pdf 1.71MB
【yolov3-YOLOv5-yolov7-yolov8环境配置-教程2】.pdf 580KB
apprcc_rc.py 11.22MB
win.py 47KB
image21_png.rf.88d1a1230c5b906e02faa20fb0747e93.txt 229B
image21_png.rf.1122945cf71fe20673fba7acffe26ec4.txt 228B
image2431_png.rf.a557b47dec9ac4249afe806fe16829f9.txt 81B
image2434_png.rf.42b323c586dcfbbc82efc3099dde7cb0.txt 81B
image2431_png.rf.fd55d991baa13d9cc33b29738e75c380.txt 81B
image2434_png.rf.e3a8fcc195cd7a1d52c0af930e206c72.txt 81B
image2443_png.rf.9e427296e66baff440259b5dc021c482.txt 76B
image2433_png.rf.f2258171c4342e0a41d36fe7ca429c22.txt 76B
image2432_png.rf.c24e046a205e9425031a4f6287df224d.txt 76B
image2433_png.rf.55737d6b0d354e91b8891c348c261566.txt 76B
image2445_png.rf.2ac6ea3ae90903c0cb4a48a9e1de3f0e.txt 74B
image2446_png.rf.7cddac85a42039d2b1e213ebc440ce6e.txt 73B
image2446_png.rf.1acfcac890435fe0729d84bb4c993a3a.txt 73B
image704_png.rf.b7dc21e5de9d806c93e3e9fd27080b6e.txt 72B
image2440_png.rf.da2b9c0414a444de753a3d3da2805837.txt 71B
image1307_png.rf.5f4de13326413518568515bdc4c7d081.txt 43B
image1731_png.rf.81ed2801a54bdaaa1f6c717ef11400bd.txt 43B
image1307_png.rf.a8c502bf3cf4cade02f85402113b8c71.txt 43B
image863_png.rf.f7b3902e758e48d7c19c35f8acf74dae.txt 43B
image1534_png.rf.468eda74a7553602c1a0792fdc5f0bd2.txt 43B
image1894_png.rf.ad5f715c0758547e4edfc492eb4874b3.txt 43B
image1533_png.rf.e05b51653f51733951645906e427a30a.txt 43B
image1531_png.rf.da527e7792de01798c95d06622b09935.txt 43B
image1532_png.rf.af6cdd6dd4cdd5495fe478e5446507bb.txt 43B
image1731_png.rf.1407f6e1c93cfd3739458c705816c6db.txt 43B
image915_png.rf.b8383030d7d28b6766f8e9cca13bee9e.txt 43B
image2260_png.rf.75a260181a73754e9baaba9877e5fded.txt 43B
image2132_png.rf.f7d233c7d68430c967065701460ebca8.txt 43B
image915_png.rf.5b9bdeb0e2efbd1b01b867a6520a5a61.txt 43B
image1894_png.rf.992a94618082a220d9c46ce12d674d75.txt 43B
image1258_png.rf.ed3490082cd7e9ef5417b3e4d31a1510.txt 43B
image1505_png.rf.f2870f66cfe5205b5c301a1c6aeb9ce6.txt 43B
image2158_png.rf.69f373f6aa6077d724b37b440f200e6a.txt 43B
image1995_png.rf.532d0d6fe2fd651e49abcbea5f867ec0.txt 43B
image2962_png.rf.8b1ffce4b8059bcc3a67f91ad84565a9.txt 43B
image2193_png.rf.3a27650c8f0f3647fddebf0a7dfe0e9d.txt 43B
image843_png.rf.3bd164d3773d76f1b9bb9334e44046b0.txt 43B
image428_png.rf.6713954dd375c1dfeab12a972c80783b.txt 43B
image644_png.rf.4147fc6982b805ab2f9e1647410f348d.txt 43B
image1729_png.rf.5608f623cf60ebc4061f33938ba12378.txt 43B
image1417_png.rf.3b424dc36d4330f758c96bfd548f3857.txt 43B
image1307_png.rf.32d801d65708dde3d014f9c628489c4d.txt 43B
image1258_png.rf.8c481e4b74af23d3ae6e3fb1bf0174a7.txt 43B
image2145_png.rf.b5c3ca9369f1d246b09b087fa1c50eae.txt 43B
image2888_png.rf.8018d03052b28a1233a95338519a937d.txt 43B
image2962_png.rf.e39e94d5a74f76288bf78f59a39cf961.txt 43B
image2888_png.rf.623071c1672bcfcc431f6790b87fcbd4.txt 43B
image2159_png.rf.eb02d42f1d6ed215e7ed92dc389db38d.txt 43B
image1731_png.rf.b09258df05c26e01f8b30474735faad8.txt 43B
image1258_png.rf.9a776b619c2bb9f881184789e2e5167b.txt 43B
image842_png.rf.42b4e42b43db96740e56bfde29299a58.txt 43B
image843_png.rf.985f78b02d238ce66c8dd69f8028c0ba.txt 43B
image2145_png.rf.7e560dfa973d4134b5f62542f42cbf1f.txt 43B
image2132_png.rf.b44ba767c12f27b74fc8dee3cc2fc8b7.txt 43B
image1534_png.rf.593a059442b9ebeac13b41730dc08af4.txt 43B
image1995_png.rf.2fc7b8104791abedf7ff4d72b1f5c583.txt 43B
image2421_png.rf.d8195df34266642bb7345777bd9d6e4f.txt 42B
image2140_png.rf.c6c15d1df4b58b28593917038158e248.txt 42B
image814_png.rf.b4be1a6ec44040cee2aa2ec3d6ddf0ff.txt 42B
image89_png.rf.91bda0189d985861c53725db6e59d0c2.txt 42B
image1990_png.rf.d15535a48ea6526992e777cda65313dc.txt 42B
image2327_png.rf.7b6961e3c6cf30fa26ef6fa37091e771.txt 42B
image1608_png.rf.0788db0295df7723c3724793c4e5dbe8.txt 42B
image2048_png.rf.0a7f02c6760a4236c2be2fbcd47bafe1.txt 42B
image803_png.rf.7aa399f0feca2e79048265e78eae7d87.txt 42B
image947_png.rf.352659c6dce697d0b3d8ec551aa73b28.txt 42B
image3051_png.rf.34c4a827d6ef54192383611b69b0d66b.txt 42B
image717_png.rf.e37d278ecfacdfbf1926d008ec502d66.txt 42B
image2332_png.rf.45fe9ea212fcc9bdd03fa931ef50474a.txt 42B
image2096_png.rf.c31c3d4fbe324e60c650faf56293e63e.txt 42B
image2825_png.rf.13e716129ba4a1a7f708b8293eb43d15.txt 42B
image1316_png.rf.098656525607fc43e0840d224a4a970c.txt 42B
image2678_png.rf.c23904a0fc620f258760aab82ffcef79.txt 42B
image808_png.rf.38a5d54485b72f061783de4529c6dfc1.txt 42B
image2871_png.rf.da860c9f15175ad99981077b0ee3840a.txt 42B
image1218_png.rf.3739272c78246d51f87926501a9516db.txt 42B
image1999_png.rf.beac5abefed27cea897ef32e74a05867.txt 42B
image2794_png.rf.636ae4b37da9d73e8e16da380d85b7e9.txt 42B
image2373_png.rf.ee4b3eedef90cfa3a157249bdd21eca4.txt 42B
image2103_png.rf.a91741107335913326a196cdfa6ce09d.txt 42B
image947_png.rf.dde1a2d88781adad0594ad1a213f9549.txt 42B
image594_png.rf.d6b6329f57de1cd5ffefe025ad8819cc.txt 42B
image1394_png.rf.0d03cc92eb7aa1eff355a475145804ac.txt 42B
image1441_png.rf.75a5e4da683df3f07f74651c0ed81666.txt 42B
image2952_png.rf.10d3808b31323e6787ecf011b9280cc4.txt 42B
image1340_png.rf.bcd4b0b9d61688ded675e99442224cfa.txt 42B
image2031_png.rf.167c3803a8a880efa78c56cd27dedc1c.txt 42B
image1383_png.rf.22dda5bace9aa80d77dd9f3cd693959d.txt 42B
image2313_png.rf.bbab94a28bacf201c0d064442698a749.txt 42B
image2421_png.rf.24e60e3c423ea477923b8334754f7772.txt 42B
image2616_png.rf.6b64542854ba9914330c33da57c841bc.txt 42B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- tiebiao0992024-05-07非常有用的资源,有一定的参考价值,受益匪浅,值得下载。
- m0_733283492024-05-11资源简直太好了,完美解决了当下遇到的难题,这样的资源很难不支持~
stsdddd
- 粉丝: 2w+
- 资源: 688
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【全网最新最全】大气公司年度月度总结汇报PPT
- C语言实现低功耗STM32F411开发板(原理图+PCB源文件+官方例程+驱动等).zip
- C语言实现基于STM32 的联合调试侦听设备解决方案(原理图、PCB源文件、调试工具、视频).zip
- 【全网最全最酷】部门年度年终工作总结汇报PPT模板
- C语言实现基于STM32F103RC的电子相册(原理图、PCB源文件、程序源码及制作).zip
- C语言实现基于stm32和mpu9250的usb hid键盘、鼠标、游戏控制器.zip
- SAP GUI for Windows 7.70 Patch16
- C语言实现基于物联网的户外环境检测装置(STM32、APP、WIFI).zip
- Models for ICM/MCM美赛常用模型.zip
- cef源码CEF全称Chromium Embedded Framework
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功