# 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人行横道检测权重 yolov8斑马线检测+pyqt可视化GUI界面
共815个文件
jpg:391个
py:171个
pyc:112个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
2024-04-12
20:38:44
上传
评论
收藏 143.86MB ZIP 举报
温馨提示
1、yolov8行人横道检测,yolov8斑马线检测;包含训练好的yolov8行人横道检测权重以及PR曲线,loss曲线等等,map达90% 多,yolov8行人横道检测数据集中训练得到的权重; 2、数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 3、采用pytrch框架,python代码,可以和YOLOv5共用一个环境,配置好环境就可以加载已经训练好的模型直接进行测试,得出结果 4、https://blog.csdn.net/zhiqingAI/article/details/134629857
资源推荐
资源详情
资源评论
收起资源包目录
yolov8人行横道检测权重 yolov8斑马线检测+pyqt可视化GUI界面 (815个子文件)
events.out.tfevents.1704079625.USER-20231125JB.14600.0 384KB
events.out.tfevents.1704089519.USER-20231125JB.7160.0 371KB
results.csv 40KB
results.csv 33KB
Dockerfile 821B
train_batch2.jpg 516KB
train_batch2.jpg 516KB
train_batch0.jpg 503KB
train_batch0.jpg 503KB
bus.jpg 476KB
train_batch27612.jpg 441KB
train_batch1.jpg 437KB
train_batch1.jpg 437KB
val_batch0_pred.jpg 422KB
val_batch0_pred.jpg 422KB
val_batch0_labels.jpg 418KB
val_batch0_labels.jpg 418KB
train_batch27610.jpg 388KB
train_batch22591.jpg 379KB
train_batch22592.jpg 371KB
train_batch27611.jpg 367KB
val_batch1_pred.jpg 367KB
val_batch1_pred.jpg 367KB
val_batch1_labels.jpg 363KB
val_batch1_labels.jpg 363KB
val_batch2_pred.jpg 353KB
val_batch2_pred.jpg 353KB
train_batch22590.jpg 348KB
val_batch2_labels.jpg 347KB
val_batch2_labels.jpg 347KB
labels_correlogram.jpg 188KB
labels_correlogram.jpg 188KB
background.jpg 181KB
labels.jpg 156KB
labels.jpg 156KB
01_4885_filename1469_jpg.rf.fe1e1a3c80a24526518931a6371e2d51.jpg 148KB
01_4885_filename1566_jpg.rf.7f42b7a22af902672a05d3f5b8469f28.jpg 147KB
01_4885_filename1546_jpg.rf.1cea230e5f428d57564bc5c096c1a05a.jpg 147KB
01_4885_filename1565_jpg.rf.c5f1faaa0cc8803a8fb4230c53688da5.jpg 146KB
01_4885_filename1457_jpg.rf.7eb2e6e8fedece08ea4e087259aba204.jpg 145KB
2024_04_06_21_11_44.jpg 138KB
2024_04_06_21_11_13.jpg 138KB
01_4885_filename1539_jpg.rf.8d057dc7683bee8f3344fc838838909d.jpg 138KB
bus.jpg 134KB
ski.jpg 131KB
03_0760_filename1049_jpg.rf.ed691067f49376d50db62d17af82cb85.jpg 129KB
01_4885_filename3739_jpg.rf.55cb7756dd31ded05312189cb1583839.jpg 129KB
01_4885_filename3714_jpg.rf.95fc1c2bb92e915fbcffd7ad67442768.jpg 128KB
03_0760_filename0840_jpg.rf.c085f11f106462e8da9f84b700bb626a.jpg 127KB
03_0760_filename0852_jpg.rf.3ef00a28fd93403630285fd2a332037c.jpg 123KB
01_4885_filename0180_jpg.rf.6d3a401862453404c31c8a9a2e994538.jpg 120KB
03_0760_filename1052_jpg.rf.1bfd6c61a6647e835ae1a014d1d14dd8.jpg 119KB
03_0760_filename1058_jpg.rf.d8f9e77748501e659fce2b334baa2272.jpg 119KB
03_0760_filename0008_jpg.rf.2deb039f53b71598822ee36296b965a2.jpg 119KB
03_0760_filename0087_jpg.rf.ce661203bd06cc190172817e6d1a3ae0.jpg 119KB
03_0760_filename0006_jpg.rf.6ceb914ce615d99411c3935b34079d2a.jpg 119KB
03_0760_filename0059_jpg.rf.86ac03e50ff7dff4da6e27842cbc20ec.jpg 119KB
03_0760_filename0034_jpg.rf.18185e8b60633f75d74664bd2486e9db.jpg 118KB
01_4885_filename3544_jpg.rf.279b0c5e35555726b629fdec774de53b.jpg 118KB
03_0760_filename0107_jpg.rf.2ffa9296b1b832b9ab12f5bf119ac873.jpg 118KB
03_0760_filename0073_jpg.rf.f2f1f1476a074916af3046c8778917b4.jpg 118KB
01_4885_filename3545_jpg.rf.163d117eb1d05bc1e9206e1420ed3c2e.jpg 118KB
03_0760_filename0092_jpg.rf.6037f5b3b9849f762404b37eccc77935.jpg 117KB
03_0760_filename0174_jpg.rf.0bd07917538baf0ecde89977c682985e.jpg 117KB
01_4885_filename0249_jpg.rf.3edaf64d3039eea7cd0d647317f3648d.jpg 117KB
03_0760_filename0090_jpg.rf.e0a5a3bd4c1cf8a4642f42fcaccdbad7.jpg 117KB
01_4885_filename2492_jpg.rf.c515e90486eeab289168abe8346f1a30.jpg 116KB
03_0760_filename0140_jpg.rf.a1865eaa60c8d81bf485a3f11f904964.jpg 115KB
03_0760_filename0152_jpg.rf.18b4686b81c50df2c2741d4b8454e1e9.jpg 115KB
03_0760_filename2665_jpg.rf.9c6ee767680ec8483f89ccbb62338a98.jpg 114KB
03_0760_filename0869_jpg.rf.f728262be70bd83493919c2e8ee0a935.jpg 114KB
03_0760_filename0869_jpg.rf.71abd69743872882a97ff1e8e8ea5db8.jpg 114KB
03_0760_filename0126_jpg.rf.08b44e4ed50cd15986f45a1aba4f4d96.jpg 113KB
02_0036_filename5563_jpg.rf.3a9faa2d5bd0b317a0face6c022d8ad1.jpg 112KB
02_0036_filename5508_jpg.rf.ebe69e1212335e96588308f39e8653e2.jpg 112KB
02_0036_filename5495_jpg.rf.6a054ae1cdc7caa05a29fb8c3a04edab.jpg 112KB
02_0036_filename5557_jpg.rf.109fe518829a967e4b7ba4f85ea9db0f.jpg 111KB
02_0036_filename5537_jpg.rf.30d865011ace4a1204236c849ab9901a.jpg 111KB
02_0036_filename5447_jpg.rf.a458ab385233f03902a8e4cec275414f.jpg 110KB
03_0760_filename0870_jpg.rf.5740cb7fe71e7cd2bc124c8424a2909a.jpg 110KB
02_0036_filename5486_jpg.rf.4154a28e0a7e483db83b68ec3c330fe7.jpg 110KB
02_0036_filename5447_jpg.rf.d5cbca6d5bacd5b12c6097ebcd65315f.jpg 110KB
02_0036_filename5564_jpg.rf.7380d956b8b848b6dd866f9e29cb35a1.jpg 110KB
02_0036_filename5567_jpg.rf.41757e13bab350c9f7c82e8b3fc83b4e.jpg 109KB
02_0036_filename5437_jpg.rf.9426e9827b17c27fe02ecdbd88405268.jpg 109KB
03_0760_filename1782_jpg.rf.9aa99dfbfa3d3f439f9e63009314a194.jpg 108KB
02_0036_filename5552_jpg.rf.fa3a5b016906094629f5a81b1e5ff813.jpg 108KB
02_0036_filename5395_jpg.rf.7341572e11f3e57b803239d9f0789714.jpg 108KB
02_0036_filename5409_jpg.rf.e32fea75d9c5985109265907f5b9f20c.jpg 108KB
03_0760_filename3229_jpg.rf.d1a662a0b2b28062ac0b15b205563636.jpg 107KB
02_0036_filename5334_jpg.rf.a0135cb74c53478f8282049e220709a4.jpg 107KB
03_0760_filename3120_jpg.rf.41ef9fb9a4de8edc64b6e9fc17364a01.jpg 107KB
01_4885_filename3443_jpg.rf.d5db2b1f63bf0421b102f124e5d279b7.jpg 107KB
02_0036_filename5383_jpg.rf.ec49d794ae03b497da459ebddc7e2e41.jpg 107KB
02_0036_filename5384_jpg.rf.26e83b4d2237a474ef8692044584ea8f.jpg 106KB
02_0036_filename5363_jpg.rf.7283f50ed4db168130f3ad3933323efa.jpg 106KB
02_0036_filename5346_jpg.rf.0c6f73739c97978dcb59df83cb1c4190.jpg 106KB
01_4885_filename3663_jpg.rf.d5b3f974ee739d835f9cf08c886b8ede.jpg 106KB
02_0036_filename5359_jpg.rf.9b80c482d493c5a3dae67b849ab455cb.jpg 105KB
02_0036_filename5463_jpg.rf.147318206751bf314d9a1b858ef01f5f.jpg 105KB
共 815 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
stsdddd
- 粉丝: 2w+
- 资源: 688
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 驱动代码驱动代码驱动代码驱动代码
- SVID_20240523_141155_1.mp4
- Code for the complete guide to tkinter tutorial
- 关于百货中心供应链管理系统.zip
- SimpleFolderIcon-master 修改Unity的Project下的文件夹图标
- A python Tkinter widget to display tile based maps
- A pure Python library for adding tables to a Tkinter application
- Vector资源文件.zip
- MobaXterm-Installer
- MicroMsg.xlsx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功