# 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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1、YOLOv8道路破损检测,包含训练好的道路破损检测权重,以及PR曲线,loss曲线等等 2、YOLO道路破损检测数据集,7000多张使用lableimg标注软件,标注好的真实场景的高质量图片数据,图片格式为jpg,标签有两种,分别为VOC格式和yolo格式,分别保存在两个文件夹中,可以直接用于YOL道路破损识别,类别为D40、D44、D0、D20、D01、D11、D10、D50、D43、D0w0,数据集图片数量为7000 3、数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743
资源推荐
资源详情
资源评论
收起资源包目录
YOLOv8道路破损检测+训练好的权重+道路破损检测数据集+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
India_005743.txt 724B
India_006862.txt 722B
India_000052.txt 697B
India_001550.txt 684B
India_008597.txt 649B
India_008233.txt 619B
India_009856.txt 609B
India_004028.txt 596B
India_000439.txt 587B
India_001338.txt 558B
India_009051.txt 552B
India_005421.txt 552B
India_008416.txt 550B
India_000223.txt 549B
India_008749.txt 549B
India_007998.txt 545B
India_009213.txt 545B
India_007071.txt 541B
India_008022.txt 540B
India_001588.txt 532B
India_004208.txt 531B
India_000209.txt 525B
India_006707.txt 518B
India_006177.txt 517B
India_007749.txt 491B
India_008218.txt 490B
India_000027.txt 479B
India_009225.txt 478B
India_000652.txt 478B
India_006787.txt 475B
India_003056.txt 473B
India_000383.txt 465B
India_002487.txt 461B
India_003553.txt 460B
India_008261.txt 458B
India_008694.txt 450B
India_002419.txt 449B
India_005245.txt 445B
India_006201.txt 437B
India_005870.txt 406B
India_001494.txt 406B
India_006973.txt 406B
India_009001.txt 405B
India_005595.txt 404B
India_006640.txt 402B
India_000557.txt 401B
India_004321.txt 397B
India_006627.txt 396B
India_003103.txt 395B
India_002249.txt 394B
India_009161.txt 393B
India_008762.txt 393B
India_008094.txt 392B
India_003975.txt 392B
India_007785.txt 392B
India_008772.txt 390B
India_008223.txt 378B
India_003093.txt 377B
India_001812.txt 371B
India_004732.txt 370B
India_003885.txt 370B
India_006699.txt 368B
India_007781.txt 367B
India_008437.txt 366B
India_002061.txt 363B
India_005882.txt 360B
India_009117.txt 359B
India_006212.txt 358B
India_005022.txt 354B
India_007000.txt 351B
India_007398.txt 349B
India_000963.txt 343B
India_008367.txt 334B
India_005489.txt 331B
India_009725.txt 327B
India_000812.txt 327B
India_003810.txt 327B
India_007972.txt 327B
India_006058.txt 326B
India_007734.txt 326B
India_002954.txt 325B
India_001779.txt 325B
India_004365.txt 325B
India_008133.txt 325B
India_002757.txt 324B
India_003828.txt 324B
India_001141.txt 324B
India_002503.txt 323B
India_008488.txt 323B
India_003231.txt 323B
India_005693.txt 321B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
stsdddd
- 粉丝: 2w+
- 资源: 686
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MMDF1N05ER2G-VB一款SOP8封装2个N-Channel场效应MOS管
- zipkin-server-3.3.0-exec.jar
- MI9933-VB一款SOP8封装2个P-Channel场效应MOS管
- zipkin-server-2.24.4-exec.jar
- MI4953-VB一款SOP8封装2个P-Channel场效应MOS管
- 基于Akka模拟实现Spark Standalone.pdf
- MI4946-VB一款SOP8封装2个N-Channel场效应MOS管
- 毕业答辩模板(动态模板)苹果IOS星空通用论文答辩模板
- 有效cookie值获取方式汇总
- 基于python实现的英雄联盟知识图谱问答系统源码(期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功