# 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
没有合适的资源?快使用搜索试试~ 我知道了~
yolov10驾驶员疲劳检测权重,包含2000多张yolo驾驶员疲劳驾驶检测&打哈欠&打瞌睡检测数据集
共2000个文件
txt:1984个
md:15个
py:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 163 浏览量
2024-07-13
17:38:47
上传
评论
收藏 302.15MB ZIP 举报
温馨提示
yolov10驾驶员疲劳检测权重,包含2000多张yolo驾驶员疲劳驾驶检测&打哈欠&打瞌睡检测数据集,划分好 train,val, test,并附有data.yaml文件,yolov5、yolov7、yolov8,yolov9等算法可以直接进行训练模型,txt格式标签, 数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 https://blog.csdn.net/zhiqingAI/article/details/137196103 数据集配置目录结构data.yaml: nc: 3 names: - awake - nodding - yawning
资源推荐
资源详情
资源评论
收起资源包目录
yolov10驾驶员疲劳检测权重,包含2000多张yolo驾驶员疲劳驾驶检测&打哈欠&打瞌睡检测数据集 (2000个子文件)
README.md 13KB
README.md 12KB
README.md 7KB
README.md 7KB
readme.md 5KB
README.md 5KB
README.md 3KB
README.md 3KB
readme.md 3KB
README.md 2KB
README.md 2KB
README.md 2KB
README.md 1KB
README.md 624B
README.md 356B
flops.py 212B
Sequence-01183_jpg.rf.b173b9c9c8bcfd6e9ccb0d1f92aff073.txt 47B
Sequence-010753_jpg.rf.e8a0c9b7f6e03b7884da5789cb9e4270.txt 47B
Sequence-010454_jpg.rf.11e94c91d3a3382b202d3fc0c972cffa.txt 47B
Sequence-010461_jpg.rf.f989bedc3cb5cadea5586a4c1daaec1e.txt 47B
217_jpg.rf.41c55a344f3daa180a1fc11c12729bdf.txt 47B
Sequence-010446_jpg.rf.aae868d91eb89b4db1232243411d14d2.txt 47B
Sequence-01217_jpg.rf.00d2b50ed18d2969d2e8c6881090799d.txt 47B
Sequence-010755_jpg.rf.6f41c0c1b4e73f198c2db9f7500e7529.txt 47B
Sequence-01183_jpg.rf.acb09aa678f4183de6a3c2d742696d24.txt 47B
205_jpg.rf.effdc0db40f21a4ae22595f3d60f631e.txt 47B
179_jpg.rf.12c46c7b9e4f5df3bbb03cc80c0e1419.txt 47B
Sequence-010625_jpg.rf.4204fa4986e05e9d6f0c809fcd89c314.txt 47B
217_jpg.rf.7d58e478952091cb443610f61dd1d4d9.txt 47B
205_jpg.rf.b734a0b42bc976ebee156bdef7851f08.txt 47B
Sequence-01194_jpg.rf.1d4a785c8bc8432f19cc5d052b2f680c.txt 47B
Sequence-011914_jpg.rf.7e19cf8852d013f6f62eb443262ff925.txt 47B
Sequence-010488_jpg.rf.819e5f3d153afb45141d5e5de4f526e5.txt 47B
Sequence-011928_jpg.rf.d11305c17f3a70b03d01578b01c06706.txt 47B
Sequence-011778_jpg.rf.7466d6257ed8a639f8f9a6537060c773.txt 47B
Sequence-010461_jpg.rf.860f96a422e3a123afd3d0d4170415f5.txt 47B
Sequence-011778_jpg.rf.a99a7316a0255f592481ae3625b1bcee.txt 47B
Sequence-011397_jpg.rf.d8782cb8872eb8b154ec2b3bb6a66b29.txt 47B
Sequence-011512_jpg.rf.6122746d1f9217d42b5a7a98c441943c.txt 47B
Sequence-011914_jpg.rf.fdc36d2b549cee7ac93490dd9f6e302f.txt 47B
1202_jpg.rf.9b02f22f80b6d3e87165e02baa95ee9c.txt 47B
Sequence-011548_jpg.rf.796689ff44622a98d9712aa62e41e134.txt 47B
Sequence-010444_jpg.rf.2c7f902278cf0b207c511bcc2fb587be.txt 47B
Sequence-010462_jpg.rf.b3520347bed8cb215462c369480c2ed4.txt 47B
Sequence-010488_jpg.rf.b49e8010eeeaf8fbe63613a1c2f84eeb.txt 47B
Sequence-01371_jpg.rf.dcef24f8cf61f88889b3b7799aaf23d8.txt 47B
Sequence-010446_jpg.rf.c3173623854b18d7cc15daf1655f6784.txt 47B
Sequence-011557_jpg.rf.8f3a44613ad36337e74c2016343050cc.txt 47B
Sequence-01134_jpg.rf.2e06f3ee7ad0003eca92036bac5a74aa.txt 47B
1061_jpg.rf.742ea0e61172584ccdbee08097ee17ae.txt 47B
Sequence-01371_jpg.rf.ecc14e37e03985e15c7d95413a453068.txt 47B
Sequence-011920_jpg.rf.f05eaaa6e9d442f8a97a06177c35eee1.txt 47B
1964_jpg.rf.c10431483a1f47d0d251fcc4226687a3.txt 47B
Sequence-011928_jpg.rf.fb1f21461f051a4379eeb6c8a17ed323.txt 47B
Sequence-01217_jpg.rf.b74e0da9b0f92e3a2e6392902d5cad20.txt 47B
Sequence-010454_jpg.rf.35935573bd53ef6802da104a0ee01b86.txt 47B
Sequence-011407_jpg.rf.bb63a3ca38dff5e5ee29395407a24848.txt 47B
1780_jpg.rf.ee23a3950ad8bd4e998d122ede45bef2.txt 47B
1964_jpg.rf.d7841bb8a3a013f7b49187eb1dcd68d1.txt 47B
Sequence-010444_jpg.rf.02c9b6fa1ad16a6878c7a13a8dc11586.txt 47B
Sequence-01316_jpg.rf.732714461973f6da6d7c996b6f4b58d8.txt 47B
1202_jpg.rf.ad5fcc158c0e442142e01c97403866e1.txt 47B
Sequence-011512_jpg.rf.831ead6f2afe5e6e01dc677cdc52f874.txt 47B
3_jpg.rf.372a653014b2186011897167fd229324.txt 47B
Sequence-011920_jpg.rf.957b929929be3afe2460e1615e9239c1.txt 47B
Sequence-011407_jpg.rf.81eb8ad8a0dbee36d90ca62729e72f13.txt 47B
Sequence-010005_jpg.rf.a949293e8c68ead9dcf935b451472508.txt 47B
Sequence-01134_jpg.rf.1dc7d7facb1217c1175f8ab90fee4bba.txt 47B
1981_jpg.rf.d27fb3e16fad76b6dddaddd77a260c84.txt 47B
179_jpg.rf.7d4d56365740b0def5e54ba061080606.txt 47B
Sequence-01316_jpg.rf.acbf5683417cc0b0fa6900c54981c554.txt 47B
Sequence-010755_jpg.rf.d7e2a2ce9dd053dbd6e2966d5a71578b.txt 47B
Sequence-011912_jpg.rf.68f4848e8eb42affec57d4f1ebe0f97c.txt 47B
3_jpg.rf.845cbc128dbb0d7b67ac9ca2420b1070.txt 47B
1981_jpg.rf.33a734f4cb69af0673c2c45a6ae71362.txt 47B
Sequence-010753_jpg.rf.89db5843d7cd76c2131dfb94832e7689.txt 47B
Sequence-01194_jpg.rf.b39ef86ca699231166f9020b44ee3549.txt 47B
Sequence-010005_jpg.rf.1cd4bc519ae4d9fb891e7b88230cfe2e.txt 47B
1780_jpg.rf.55f19431212f01cad4dc282af01dff50.txt 47B
1061_jpg.rf.1d1f7c79ba86e0f6cc726865c42efcae.txt 47B
Sequence-011557_jpg.rf.1ead944b633c0b37bafa3ce668b33c35.txt 47B
Sequence-010625_jpg.rf.66d69a0a5ac4e23ef49c90ae86c264fe.txt 47B
Sequence-011548_jpg.rf.986497cabdf36af061841ee905e1c2c4.txt 47B
Sequence-010462_jpg.rf.c45bd70b11fe6a361931fb648839ba65.txt 47B
Sequence-011397_jpg.rf.c246f6b9991628fca2374f7b737cdf29.txt 47B
Sequence-011912_jpg.rf.cb4b2308646e61bb4146f2a1ab044ae4.txt 47B
70_jpg.rf.f55bd36e10e6171df10535d2172fc6f4.txt 46B
Sequence-010456_jpg.rf.05bf4dc7688c8bdd0612021c56fc1115.txt 46B
63_jpg.rf.be408d8a4140c17d5fa065490b1e749f.txt 46B
1178_jpg.rf.83196730bbce4afbcad93913f1c382b2.txt 46B
30_jpg.rf.0663f118322471e9fdf7eedecec42867.txt 46B
Sequence-011771_jpg.rf.485c2b012c05061ec2df978c0d8a7647.txt 46B
Sequence-011867_jpg.rf.8bc28795218ef8fe3d22f0e6505cece6.txt 46B
Sequence-011516_jpg.rf.5787881bd722ea916e6b2686f8ffe2af.txt 46B
Sequence-011593_jpg.rf.4d9394e76a1360bc38e11f901f2c2a02.txt 46B
Sequence-01203_jpg.rf.f4a06e121f485b5dda07a6b0c9698d80.txt 46B
Sequence-01146_jpg.rf.828b26e77b79948b95879aaa9dc77ddd.txt 46B
Sequence-01384_jpg.rf.4a54a823ec714bdafa460bccced607f7.txt 46B
Sequence-011514_jpg.rf.191881a21f1eb7481cb77b12016ffd3d.txt 46B
Sequence-010762_jpg.rf.b915944212964faa15420779f5fe0959.txt 46B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
stsdddd
- 粉丝: 3w+
- 资源: 951
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于ssh框架的校园论坛项目全部资料+详细文档+高分项目.zip
- 基于SSM的校园二手交易平台全部资料+详细文档+高分项目.zip
- 基于uniapp的微信小程序二手平台,二手交易,校园交易、物品二手交易,买卖在线聊天全部资料+详细文档+高分项目.zip
- 基于SSM校园二手购物商城设计全部资料+详细文档+高分项目.zip
- 基于SSM框架一个比赛裁判管理系统校园赛事管理系统,主要技术(SpringMVC + Spring + Mybatis+Hui+Jquery+Ueditor)全部资料+详细文档+高分项目.zip
- 基于vue+element-ui的SSM校园活动信息平台全部资料+详细文档+高分项目.zip
- 基于wagtail的简单校园维基站点全部资料+详细文档+高分项目.zip
- 基于高德地图的校园导航全部资料+详细文档+高分项目.zip
- allwinner全志-V3S-LINUX-QT-4G-GC0308摄像头实现4G传输视频数据到网络服务器.zip
- Labview 利用属性节点 改变控件颜色及可见性
- 基于微信平台的校园早餐外卖平台全部资料+详细文档+高分项目.zip
- 基于微服务和智能推荐的校园服务平台、全部资料+详细文档+高分项目.zip
- 基于微信小程序的校园二手交易平台全部资料+详细文档+高分项目.zip
- 基于微信小程序的校园疫情防控系统全部资料+详细文档+高分项目.zip
- 基于微信小程序的校园论坛;微信小程序;云开发;云数据库;云储存;云函数;纯JS无后台;全部资料+详细文档+高分项目.zip
- 基于微信小程序的校园失物招领平台,提供OCR识别证件、失物招领消息订阅、web后台可视化数据管理等全部资料+详细文档+高分项目.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功