# 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桥梁道路裂缝检测+训练好的模型+标注好的数据集+QT界面
共2000个文件
txt:1610个
py:171个
jpg:139个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 59 浏览量
2024-04-21
17:22:31
上传
评论 4
收藏 374.31MB ZIP 举报
温馨提示
1、YOLOv8训练好的道路裂缝检测模型,并包含1000多张标注好的数据集,标签格式为xml和txt两种,配置好YOLOv5环境后可以直接使用,含QT界面 2、数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 3、采用pytrch框架,代码是python的
资源推荐
资源详情
资源评论
收起资源包目录
YOLOv8桥梁道路裂缝检测+训练好的模型+标注好的数据集+QT界面 (2000个子文件)
labels.cache 345KB
crack_00351.jpg 330KB
crack_01225.jpg 315KB
crack_00655.jpg 310KB
crack_00378.jpg 307KB
crack_0139.jpg 306KB
crack_01471.jpg 304KB
crack_01209.jpg 296KB
crack_00339.jpg 295KB
crack_0011.jpg 294KB
crack_00459.jpg 292KB
crack_00244.jpg 291KB
crack_00683.jpg 290KB
crack_0044.jpg 289KB
crack_00119.jpg 289KB
crack_0087.jpg 287KB
crack_01118.jpg 287KB
crack_01556.jpg 284KB
crack_0053.jpg 282KB
crack_01446.jpg 281KB
crack_00610.jpg 279KB
crack_00540.jpg 279KB
crack_01380.jpg 275KB
crack_01634.jpg 275KB
crack_00452.jpg 275KB
crack_00432.jpg 274KB
crack_01474.jpg 274KB
crack_0043.jpg 273KB
crack_0025.jpg 272KB
crack_00237.jpg 271KB
crack_01571.jpg 270KB
crack_0071.jpg 270KB
crack_01389.jpg 270KB
crack_00240.jpg 270KB
crack_01201.jpg 270KB
crack_01596.jpg 268KB
crack_01641.jpg 268KB
crack_00684.jpg 266KB
crack_01154.jpg 265KB
crack_00486.jpg 264KB
crack_01144.jpg 264KB
crack_0112.jpg 263KB
crack_01470.jpg 262KB
crack_00675.jpg 259KB
crack_00599.jpg 258KB
crack_00332.jpg 258KB
crack_01425.jpg 257KB
crack_00208.jpg 257KB
crack_00412.jpg 256KB
crack_01348.jpg 256KB
crack_00433.jpg 256KB
crack_00275.jpg 254KB
crack_00510.jpg 253KB
crack_01604.jpg 251KB
crack_0017.jpg 250KB
crack_01198.jpg 250KB
crack_00536.jpg 248KB
crack_01608.jpg 248KB
crack_01365.jpg 247KB
crack_0064.jpg 247KB
crack_01369.jpg 246KB
crack_0190.jpg 246KB
crack_01250.jpg 245KB
crack_00255.jpg 243KB
crack_01292.jpg 243KB
crack_01405.jpg 243KB
crack_00261.jpg 243KB
crack_01595.jpg 239KB
crack_00761.jpg 239KB
crack_00639.jpg 236KB
crack_00477.jpg 236KB
crack_00392.jpg 235KB
crack_01400.jpg 235KB
crack_0199.jpg 234KB
crack_00760.jpg 231KB
crack_00385.jpg 230KB
crack_01139.jpg 230KB
crack_01322.jpg 225KB
crack_00334.jpg 225KB
crack_0070.jpg 224KB
crack_00171.jpg 214KB
crack_00199.jpg 213KB
crack_00224.jpg 208KB
crack_00111.jpg 205KB
crack_00671.jpg 204KB
crack_00320.jpg 198KB
crack_01212.jpg 196KB
crack_01403.jpg 194KB
crack_00559.jpg 190KB
crack_01533.jpg 188KB
crack_00112.jpg 187KB
crack_01305.jpg 186KB
crack_01615.jpg 180KB
crack_01416.jpg 180KB
crack_01181.jpg 179KB
crack_0122.jpg 165KB
crack_00624.jpg 158KB
crack_01200.jpg 157KB
crack_00759.jpg 155KB
crack_0037.jpg 155KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- m0_700349162024-06-09这个资源总结的也太全面了吧,内容详实,对我帮助很大。
stsdddd
- 粉丝: 3w+
- 资源: 946
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 本地磁盘E的文件使用查找到的
- STM32F407连接EC20-4G模块实现TCP协议上传数据到云服务器及接收指令下发.zip
- 基于yolov5实现的B站蒙版弹幕效果源码+详细文档 +全部资料+高分项目.zip
- 基于YOLOv5旋转标签格式的Copy-paste小目标数据增强,数据集为DOTA源码+详细文档 +全部资料+高分项目.zip
- 本地磁盘E的文件使用查找到的
- STM32F407连接EC20-4G模块实现单片机修改4G模块串口波特率的功能.zip
- 本地磁盘E的文件使用查找到的
- 基于旋转框的yolov5目标检测算法源码+详细文档 +全部资料+高分项目.zip
- 本地磁盘E的文件使用查找到的
- 基于深度学习的驾驶员分心驾驶行为(疲劳+危险行为)预警系统使用YOLOv5+Deepsort实现驾驶员的危险驾驶行为的预警监测源码+详细文档 +全部资料+高分项目.zip
- 本地磁盘E的文件使用查找到的
- 高清必备 C语言 C++ DEV-C++等常用数据资源 数据类型 占位符 转义字符 运算符优先级 进制转换 速查表
- 本地磁盘E的文件使用查找到的
- 基于echarts关系图的知识图谱源码+文档+全部资料.zip
- 基于bert的微调和特征提取方法来进行知识图谱源码+文档+全部资料.zip
- 基于Neo4j的知识图谱和问答案例源码+文档+全部资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功