# 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个文件
txt:968个
xml:959个
md:41个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 14 浏览量
2024-12-28
12:05:34
上传
评论
收藏 231.3MB ZIP 举报
温馨提示
YOLOv10算法快递包裹-包装纸盒质量好坏检测权重, 包含近1000多张递包裹-包装纸盒质量好坏检测数据集,数据集目录已经配置好,划分好 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/142426701 数据集配置目录结构data.yaml: train: ../train/images val: ../valid/images test: ../test/images nc: 5 names: - Box - Box_broken - Package - Box_damaged - person
资源推荐
资源详情
资源评论
收起资源包目录
YOLOv10算法快递包裹-包装纸盒质量好坏检测权重+数据集 (2000个子文件)
inference.cpp 13KB
inference.cpp 6KB
main.cpp 5KB
main.cpp 2KB
style.css 1KB
inference.h 2KB
inference.h 2KB
comments.html 2KB
source-file.html 858B
main.html 439B
extra.js 3KB
cfg.md 42KB
inference-api.md 15KB
simple-utilities.md 14KB
README.md 13KB
pose.md 12KB
python.md 12KB
README.md 12KB
obb.md 12KB
segment.md 12KB
projects.md 11KB
classify.md 11KB
detect.md 11KB
android.md 10KB
cli.md 9KB
datasets.md 8KB
models.md 8KB
ios.md 7KB
README.md 7KB
README.md 7KB
CONTRIBUTING.md 5KB
index.md 5KB
readme.md 5KB
README.md 5KB
cloud-training.md 5KB
callbacks.md 5KB
integrations.md 5KB
index.md 5KB
index.md 3KB
quickstart.md 3KB
engine.md 3KB
README.md 3KB
README.md 3KB
readme.md 3KB
README.md 2KB
README.md 2KB
index.md 2KB
index.md 2KB
README.md 2KB
README.md 1KB
README.md 624B
README.md 356B
test_python.py 22KB
main.py 13KB
main.py 11KB
yolov8_region_counter.py 9KB
main.py 9KB
test_integrations.py 6KB
build_docs.py 5KB
app.py 5KB
build_reference.py 5KB
test_cli.py 5KB
test_engine.py 4KB
main.py 4KB
yolov8_sahi.py 4KB
test_cuda.py 3KB
conftest.py 3KB
test_explorer.py 2KB
flops.py 212B
SOURCES.txt 8KB
CMakeLists.txt 3KB
CMakeLists.txt 2KB
img_01000_192.txt 937B
robots.txt 806B
requires.txt 757B
img_01000_792.txt 632B
img_085_62.txt 551B
CMakeLists.txt 547B
img_01000_242.txt 449B
img_01000_490.txt 380B
img_085_16.txt 343B
img_01000_563.txt 321B
img_01000_831.txt 292B
img_01000_238.txt 290B
img_01000_494.txt 289B
img_01000_724.txt 257B
img_01000_354.txt 254B
img_01000_818.txt 253B
img_01000_679.txt 214B
img_01000_58.txt 213B
img_01000_247.txt 208B
img_01000_128.txt 204B
img_01000_499.txt 203B
img_01000_152.txt 201B
img_01000_103.txt 188B
img_01000_761.txt 176B
img_01000_767.txt 174B
img_01000_61.txt 168B
img_01000_302.txt 166B
img_01000_251.txt 165B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
stsdddd
- 粉丝: 3w+
- 资源: 967
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Adobe Acrobat Pro 2024.003.20112 安装指南及注意事项(内含下载链接)
- 机械设计自动组装上下料机sw18可编辑全套设计资料100%好用.zip
- 基于springboot的小学生古诗词学习软件的设计与实现源码(java毕业设计完整源码).zip
- (176349852)雷达分选算法(PRI变换)
- 钢铁英雄.exe钢铁英雄1.exe钢铁英雄2.exe
- (176566424)数据库课程设计springboot306基于Java的民宿管理系统.sql
- A First Course in Probability, CN HD, English eBook
- (176593844)数据库课程设计ssm404民宿住宿管理系统.sql
- 番茄的随笔之FIR与IIR滤波
- 基于springboot的小说阅读平台的设计源码(java毕业设计完整源码+LW).zip
- (176630234)SpringBoot+Vue课程作业管理系统答辩PPT.pptx
- (176954422)基于jsp+servlet+mysql校园任务管理系统设计
- 基于springboot的就业系统源码(java毕业设计完整源码).zip
- (177416408)vb+access学生学籍管理系统(系统+论文).zip
- 空袭:这不是演习.exe
- (177416420)vb+access学籍管理系统(系统+论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功