# 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红外微小无人机-直升机-飞机-飞鸟目标检测模型,4000多千张yolo红外微小无人机-直升机-飞机-飞鸟目标检测数据集,数据集目录已经配置好,yolo格式(txt)的标签,划分好 train,val, test,并附有data.yaml文件,yolov5、yolov7、yolov8等算法可以直接进行训练模型, 数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 https://blog.csdn.net/zhiqingAI/article/details/136952543 数据集配置目录结构data.yaml: nc: 4 names: ['Airplane', 'Bird', 'Drone', 'Helicopter']
资源推荐
资源详情
资源评论
收起资源包目录
YOLOv10红外微小无人机-直升机-飞机-飞鸟目标检测模型权重+4000数据集+使用教程 (2000个子文件)
README.md 13KB
README.md 12KB
README.md 7KB
README.md 7KB
readme.md 5KB
README.md 5KB
README.md 3KB
README.md 3KB
readme.md 3KB
README.md 2KB
README.md 2KB
README.md 2KB
README.md 1KB
README.md 624B
README.md 356B
flops.py 212B
IR_BIRD_027_frame_173_jpg.rf.ad13a23f0a417eaef8b89cdbf3d571b3.xml 1KB
IR_BIRD_027_frame_173_jpg.rf.86f15aae2f4569ef50a753451f6d9328.xml 1KB
IR_BIRD_035_frame_206_jpg.rf.908c541d1f11066b449e4bab3b344766.xml 786B
IR_BIRD_027_frame_111_jpg.rf.cb1aecf4db694d0bf1e2fb5cc85e24a5.xml 786B
IR_BIRD_035_frame_87_jpg.rf.94064de7f0474fd69838b3d1184e6ee8.xml 785B
IR_BIRD_035_frame_87_jpg.rf.9218f34bd30e167f525a92a580db1ee4.xml 785B
IR_BIRD_027_frame_66_jpg.rf.80b25146b6dfc609b346cd66c5951fc2.xml 784B
IR_BIRD_027_frame_67_jpg.rf.5879ac833d7384824dfb24ef4852d7b7.xml 784B
IR_BIRD_027_frame_67_jpg.rf.fd000cf2e41a988b19e97b01221d201e.xml 784B
IR_BIRD_027_frame_67_jpg.rf.ae49032b86645ceac5fad21b89305b90.xml 784B
IR_DRONE_150_frame_307_jpg.rf.790211af58ab81d68218bbcf8ffe2b6c.xml 618B
IR_DRONE_150_frame_307_jpg.rf.92951056d7b743a9bd1c671db8ac6815.xml 618B
IR_AIRPLANE_070_frame_28_jpg.rf.e7da45fbcce96401634f475ae8dedaa2.xml 616B
IR_DRONE_146_frame_141_jpg.rf.b8387f778a4812a0893cd05959843629.xml 608B
IR_DRONE_147_frame_152_jpg.rf.033ca86c47de91723b9c82065aa00b32.xml 608B
IR_DRONE_146_frame_103_jpg.rf.e2b100969847007b786a278c358b652f.xml 608B
IR_DRONE_146_frame_25_jpg.rf.b2e432bfe2187fece092ba51bc715c37.xml 607B
IR_DRONE_144_frame_169_jpg.rf.70bbda3f66977a771b99e42866f844bb.xml 607B
IR_DRONE_144_frame_169_jpg.rf.a5d75c453715a1b9f81ecd7d939ae5f8.xml 607B
IR_DRONE_144_frame_169_jpg.rf.eef6da192637594ced9217d9e242d84f.xml 607B
IR_DRONE_147_frame_76_jpg.rf.aba8a8eb14c697db233aef5ce8e89fa1.xml 607B
IR_DRONE_143_frame_198_jpg.rf.58ca329fd68ee90e983b9ed219156150.xml 607B
IR_DRONE_147_frame_76_jpg.rf.b32a9fd565c172fc5daace66fe5d28f5.xml 607B
IR_DRONE_146_frame_40_jpg.rf.9092089146024ea7b37d5bfd12430fde.xml 607B
IR_DRONE_146_frame_40_jpg.rf.0620e39136a340b73d66b417a1593e4c.xml 607B
IR_DRONE_143_frame_42_jpg.rf.afdf7ec5db1b72f4b5a364f011936a54.xml 606B
IR_DRONE_145_frame_84_jpg.rf.4cf0edad4ffaffb0d0f255323910511c.xml 606B
IR_DRONE_143_frame_42_jpg.rf.7550b18610ae57a19b22069f5e656cd1.xml 606B
IR_DRONE_145_frame_84_jpg.rf.dea6e92e8bc26811f3d6e8ea72ac5f2c.xml 606B
IR_DRONE_144_frame_294_jpg.rf.8485401c9dec22280a4108750c75f4da.xml 605B
IR_DRONE_144_frame_294_jpg.rf.8cb8cde1b8b4a9f87218a1a8569cc9da.xml 605B
IR_BIRD_001_frame_241_jpg.rf.bedad86af36b15ea4219f2122dab1d55.xml 605B
IR_BIRD_001_frame_241_jpg.rf.37c07fc5ab02bb243042c8a73f7a344d.xml 605B
IR_BIRD_038_frame_247_jpg.rf.5c8027edecc658fbdd6690e0d0896f0a.xml 605B
IR_BIRD_071_frame_158_jpg.rf.f6bbf978093d21a65c84017898f6789a.xml 605B
IR_BIRD_038_frame_247_jpg.rf.c9bac1e618acd7a3c8703df9d615bf3d.xml 605B
IR_DRONE_145_frame_131_jpg.rf.90861ac4cc8c5b52fbedd707bcbf1b0b.xml 604B
IR_DRONE_143_frame_11_jpg.rf.538c66b0a6d5bd4cb3704041f40f68e0.xml 604B
IR_DRONE_143_frame_14_jpg.rf.4ee90907c83149ab2380b9c303f157d6.xml 604B
IR_BIRD_007_frame_148_jpg.rf.7e3c4a93c52a9cd4d17443ef873deb7a.xml 604B
IR_BIRD_007_frame_148_jpg.rf.f22527b7e86673b3f8be5e3f87b7c1f8.xml 604B
IR_DRONE_143_frame_11_jpg.rf.dcc230dabbd4c0fd9abea8a278b8edd1.xml 604B
IR_BIRD_072_frame_98_jpg.rf.b8bb965022ee096be218d5e78a6f63ae.xml 604B
IR_DRONE_143_frame_14_jpg.rf.6fa59f3e93c30d5e4910a979eaa269bf.xml 604B
IR_BIRD_018_frame_39_jpg.rf.b8fec4d530dd2bcb18be215ef5dedc1c.xml 604B
IR_BIRD_072_frame_98_jpg.rf.770fb66cc6d370ac66c9fda93973cb7e.xml 604B
IR_DRONE_145_frame_131_jpg.rf.dae114cc612d9dd23b6a3d51261e02e6.xml 604B
IR_BIRD_018_frame_39_jpg.rf.8c334d2d74224211de6be28a8ce2126b.xml 604B
IR_BIRD_071_frame_233_jpg.rf.546b3b8eb5b2b55f67c8c8a576e08571.xml 603B
IR_BIRD_071_frame_233_jpg.rf.bade8e2ef24f0871568f2f8c3cbf0ed1.xml 603B
IR_BIRD_072_frame_247_jpg.rf.8d62128dc36cbe1f54f2be7c8afddff8.xml 603B
IR_BIRD_007_frame_79_jpg.rf.2743d4c85165f1578ff4f1745e9ebfed.xml 603B
IR_BIRD_071_frame_233_jpg.rf.4e2549c6e00c2dc880344a52e94727f4.xml 603B
IR_frame_0_jpg.rf.d132673d5661a72b00a245955a2c35d8.xml 595B
IR_HELICOPTER_007_frame_233_jpg.rf.e44670fb8ac5be7168a1cb8afeb02167.xml 436B
IR_HELICOPTER_045_frame_251_jpg.rf.0247f35ce315c0a5bce417d2d8997c97.xml 436B
IR_HELICOPTER_031_frame_254_jpg.rf.fc36d47d64ec7f0bda70230a0d911cca.xml 436B
IR_HELICOPTER_044_frame_308_jpg.rf.65ce226efe333fff6d090f55e3d4c72c.xml 436B
IR_HELICOPTER_028_frame_211_jpg.rf.768c87c678730baf99fb56286dc6989d.xml 436B
IR_HELICOPTER_047_frame_284_jpg.rf.52b8db2e97a0693bfaea1988d4e899d6.xml 436B
IR_HELICOPTER_046_frame_103_jpg.rf.f3ce7048654f300aa475f15c1d97b1f3.xml 436B
IR_HELICOPTER_024_frame_105_jpg.rf.d74bd35ca1c4150b9b2c3770acce39a6.xml 436B
IR_HELICOPTER_020_frame_283_jpg.rf.bb878264596e3d07e55facfe558ad6b2.xml 436B
IR_HELICOPTER_053_frame_124_jpg.rf.4eb52911ebe858b89abd1f1081d2eea0.xml 436B
IR_HELICOPTER_048_frame_256_jpg.rf.7fba4c1b2faca2d8744bc5833fe089c0.xml 436B
IR_HELICOPTER_013_frame_126_jpg.rf.172048c109bc6b2e338491d0eef14b7f.xml 436B
IR_HELICOPTER_006_frame_275_jpg.rf.c7896df30819d3a3f40ea6d3c565aa3b.xml 436B
IR_HELICOPTER_043_frame_190_jpg.rf.7347452957abe060a3cbd888b47614ae.xml 436B
IR_HELICOPTER_021_frame_233_jpg.rf.d9360377062530183c417d0cec563d85.xml 436B
IR_HELICOPTER_031_frame_250_jpg.rf.e32086abbfedd3804d8ece2b2894096a.xml 436B
IR_HELICOPTER_033_frame_232_jpg.rf.b364e06861129478f759aa0f9da6cafd.xml 436B
IR_HELICOPTER_049_frame_219_jpg.rf.5421fef139357489a0aed09232b87773.xml 436B
IR_HELICOPTER_016_frame_100_jpg.rf.442502e0dbdfcc0accbea9cebd402210.xml 436B
IR_HELICOPTER_014_frame_163_jpg.rf.5d6b93df0279dd0ada8a517c3ca671ca.xml 436B
IR_HELICOPTER_013_frame_126_jpg.rf.5c409c42c41cb2873e15f7cf46502a7d.xml 436B
IR_HELICOPTER_031_frame_254_jpg.rf.1bc9422fabb841d22299e4d4974efb8b.xml 436B
IR_HELICOPTER_021_frame_195_jpg.rf.67edbab23440a0533161bc70f8d9feb4.xml 436B
IR_HELICOPTER_024_frame_143_jpg.rf.2ddba1cd8d95ebecc89087f66c1b86d0.xml 436B
IR_HELICOPTER_040_frame_253_jpg.rf.c0178e8bf1601ddc041794014f40247c.xml 436B
IR_HELICOPTER_034_frame_157_jpg.rf.9191fe6252e7f655545bd6fcd7bfb74b.xml 436B
IR_HELICOPTER_042_frame_245_jpg.rf.9514bf252c064ef493325f8b828508ec.xml 436B
IR_HELICOPTER_022_frame_256_jpg.rf.77cbea29282b95f80d66d0b50550accd.xml 436B
IR_HELICOPTER_007_frame_233_jpg.rf.02b180972b75a9d7b31666a83afd0616.xml 436B
IR_HELICOPTER_011_frame_261_jpg.rf.8eb916ae8dac86345e03e3c60fddc762.xml 436B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- roger_rao2024-08-12资源中能够借鉴的内容很多,值得学习的地方也很多,大家一起进步!
stsdddd
- 粉丝: 3w+
- 资源: 985
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 成熟FOC电机控制GD32F1XX全C程序,全开源 资料含: 电路图,PcB文件及c程序 主要于电动自行车,电动三轮车等,有感控制 直接可用,不是一般的普通代码 也可以自行移植到国产32位芯片
- 毕业设计基于Python卷积神经网络CNN的垃圾邮件分类系统源码+模型(高分毕设)
- Matlab遗传算法路径优化求解,该模型是关于生鲜果蔬冷链配送背景下的路径优化,在经典的路径优化最低成本计算求解的基础上加入了拥堵系数矩阵,模型更加完善,本人写的实列,注释详细带模型,目标函数
- yolov11 改进项目测试1
- 基于自回归整合滑动平均模型(ARIMA)的时间序列预测
- 邢台市桥东区社区停车信息管理系统(编号:68241253).zip
- 校友录管理系统(编号:27740154).zip
- 校园志愿者服务管理系统(编号:01301288).zip
- 光伏并网逆变器控制器避雷器simulink仿真
- 学生竞赛管理系统.zip
- 学生报名管理系统(编号:9093943).zip
- 学生选课系统(编号:54331102).zip
- 庞大的股票市场数据集.zip
- 学校学报出版发行管理系统(编号:73605195).zip
- 雅妮电影票购买系统(编号:8811483).zip
- 学院网站系统 (编号:45648108).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功