# 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 车牌识别 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌.zip
共227个文件
py:149个
yaml:48个
jpg:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 54 浏览量
2024-11-26
12:30:52
上传
评论
收藏 38.42MB ZIP 举报
温馨提示
yolov8车牌识别算法,支持12种中文车牌类型图片测试演示:直接运行detect_plate.py或者运行如下命令行python detect_rec_plate.py --detect_model weights/yolov8s.pt --rec_model weights/plate_rec_color.pth --image_path imgs --output result测试文件夹imgs,结果保存再结果文件夹中车牌识别训练车牌检测训练链接如下车牌识别训练车牌识别训练车牌识别训练链接如下车牌识别训练支持如下1.单行蓝牌2.单行黄牌3.新能源汽车牌4.白色警用车牌5.教练车牌6.武警车牌7.双层黄牌8.双层白牌9.使馆车牌10.港澳粤Z牌11.双层绿牌12.民航车牌参考https://github.com/derronqi/yolov8-facehttps://github.com/ultralytics/ultralytics。有问题可以提问题或者加QQ群:769809695(新群) 8379
资源推荐
资源详情
资源评论
收起资源包目录
yolov8 车牌识别 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌.zip (227个子文件)
.gitignore 331B
single_blue.jpg 1.81MB
xue.jpg 999KB
single_green.jpg 903KB
hongkang1.jpg 571KB
police.jpg 382KB
bus.jpg 134KB
single_yellow.jpg 85KB
zidane.jpg 49KB
shi_lin_guan.jpg 47KB
double_yellow.jpg 29KB
README.md 13KB
CONTRIBUTING.md 5KB
README.md 3KB
README.md 1KB
README.md 869B
Quicker_20220930_180919.png 1.02MB
tmpA5E3.png 513KB
Quicker_20220930_180938.png 241KB
105384078.png 19KB
yolov8s.pt 23.41MB
plate_rec_color.pth 733KB
metrics.py 52KB
exporter.py 51KB
augment.py 51KB
plotting.py 42KB
tasks.py 37KB
trainer.py 33KB
__init__.py 33KB
ops.py 32KB
loss.py 32KB
utils.py 29KB
tiny_encoder.py 28KB
checks.py 27KB
results.py 27KB
autobackend.py 26KB
torch_utils.py 25KB
encoders.py 24KB
predict.py 23KB
loaders.py 22KB
downloads.py 21KB
model.py 21KB
__init__.py 20KB
test_python.py 20KB
head.py 19KB
explorer.py 18KB
byte_tracker.py 18KB
transformer.py 18KB
predictor.py 17KB
benchmarks.py 17KB
dataset.py 16KB
prompt.py 16KB
tal.py 16KB
instance.py 15KB
kalman_filter.py 15KB
loss.py 15KB
validator.py 14KB
block.py 14KB
session.py 14KB
gmc.py 14KB
converter.py 14KB
comet.py 13KB
val.py 13KB
ops.py 13KB
base.py 13KB
conv.py 12KB
tuner.py 11KB
val.py 11KB
transformer.py 11KB
heatmap.py 11KB
detect_rec_plate.py 11KB
val.py 10KB
object_counter.py 10KB
split_dota.py 10KB
utils.py 10KB
dash.py 9KB
bot_sort.py 8KB
val.py 8KB
plateNet.py 8KB
amg.py 8KB
decoders.py 8KB
utils.py 7KB
train.py 7KB
distance_calculation.py 7KB
wb.py 6KB
speed_estimation.py 6KB
build.py 6KB
train.py 6KB
ai_gym.py 6KB
tuner.py 6KB
clearml.py 6KB
base.py 6KB
val.py 5KB
auth.py 5KB
files.py 5KB
test_cli.py 5KB
dvc.py 5KB
__init__.py 5KB
matching.py 5KB
build.py 5KB
共 227 条
- 1
- 2
- 3
资源评论
徐浪老师
- 粉丝: 8182
- 资源: 9015
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JAVA的Springboot2.x快速开发框架后台管理平台源码数据库 MySQL源码类型 WebForm
- 数据科学、数据分析、人工智能必备知识汇总-分布分析-持续更新
- 基于灰度多属性决策的海洋塑料碎片污染程度评估与政策建议
- 2024认证杯B题代码及数据可视化
- 2024认证杯D题1-3问可运行代码
- 基于python2.7的一些渗透测试小工具.zip
- 手机年度报告-换机行为-购买行为分析
- 基于golang的渗透测试武器,将web打点部分与常规的漏扫部分进行整合与改进.zip
- 域渗透攻击技术、检测规则以及方便覆盖漏洞的虚拟机实验环境 - 攻击 Active Directory 的技巧和工具、威胁搜寻检测规则以及用于重现漏洞的实验室 .zip
- Python期末大作业-基于LSTM实现文本的情感分析与可视化项目源码(高分项目)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功