# 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水果质量检测检测权重,包含3000多张yolo水果质量检测数据集,划分好 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/136969433 数据集配置目录结构data.yaml: nc: 6 names: - bad apple - bad banana - bad orange - good apple - good banana - good orange
资源推荐
资源详情
资源评论
收起资源包目录
yolov8水果质量检测检测权重+3000数据集+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
IMG20200728131027_jpg.rf.877783a88fc57916b6edfd946fa101d2.txt 612B
IMG20200728131011_jpg.rf.58563ea7b17a7c9e0cf5b475e67201b6.txt 609B
IMG20200728131020_jpg.rf.b1264fd9e41334af7ab7cc5bd7a4ecb2.txt 607B
IMG20200728130920_jpg.rf.736e322645071c33b02df89bee90af8d.txt 604B
IMG20200728131028_jpg.rf.3a9d45c5f91ae0c006fed4099e946f04.txt 600B
IMG20200728130936_jpg.rf.6d6db8b163fa29d9ac5d8f29fc3e8e9b.txt 600B
IMG20200728131029_jpg.rf.2e85a3a07492b4cd0445102975013802.txt 600B
IMG20200728130929_jpg.rf.7da9a60307276b1559c30f7e40758e92.txt 598B
IMG20200728131031_jpg.rf.b9172a8cb480c359fd45b28c0bc75ba5.txt 596B
IMG20200728130948_jpg.rf.b35378ec7ae77d2f00ebf1fe96e2a211.txt 596B
IMG20200728130949_jpg.rf.5e5731bb6390e30673d6711d1978d23e.txt 596B
IMG20200728130927_jpg.rf.5ce950ff63dac6e2833c33ddb04cfe6c.txt 596B
IMG20200728130951_jpg.rf.3e82c77e5ef768c9b243751f6734c594.txt 595B
IMG20200728130944_jpg.rf.dcb0374aae1bed60afa7562b2c7ffdaf.txt 595B
IMG20200728130942_jpg.rf.aee099d02f4821d836fe06345dfc6ee5.txt 594B
IMG20200728131013_jpg.rf.27db8e6cd8d21ac7e9adc76a41a25b9f.txt 593B
IMG20200728130934_jpg.rf.dd684c569efd20844aa93bb77cea6348.txt 592B
IMG20200728131014_jpg.rf.170c99119da21ce824f208f9ccf6126c.txt 572B
IMG20200728130957_jpg.rf.e69e490bc2a8ce14fa128874fb1eadf3.txt 557B
IMG20200728130926_jpg.rf.4547637cd81607a54c01acd4529d9ac3.txt 543B
IMG20200728130959_jpg.rf.7857ab4897518c5a886b445bf328726f.txt 543B
IMG20200728131022_jpg.rf.aa470dba11a02e203f6e26e37f124458.txt 536B
IMG20200728131224_jpg.rf.c37e668af29c4fe946abe28b144eca19.txt 452B
IMG20200728131232_jpg.rf.ff60acf2a2b1b960eef1fe686ebeb19f.txt 442B
IMG20200728131235_jpg.rf.f3a19df068afc921d02f4945745eb2c4.txt 438B
IMG20200728131236_01_jpg.rf.cf46583b0b96e8e068e0db487980b42f.txt 437B
IMG20200728131236_jpg.rf.a09f6d3965484b510f80ce15a6a99eac.txt 426B
IMG20200728131205_jpg.rf.a582512c6a9fa2a9231343b375b7f7bf.txt 409B
IMG_20190924_153435_jpg.rf.ce13871148d2adcd3792608a624a0360.txt 403B
IMG20200728131206_jpg.rf.b0f90ff9098b4fda81cfa0972ea45d64.txt 400B
IMG20200728131218_jpg.rf.91aa9b5d71d2b5b26b28c760fd28efbb.txt 396B
IMG_20190924_153325_jpg.rf.5b78593c0e67f8f463f7615e695ca79a.txt 390B
IMG_20190924_153435_1_jpg.rf.60cd9d902d84e4647cf2250b64332c0c.txt 387B
IMG20200728131210_jpg.rf.5dcbcfe9a7ab8a2012db8581c6ccb721.txt 383B
IMG_20190924_153324_1_jpg.rf.76e61982bcf0469088ca470946e4f9eb.txt 371B
IMG20200728131216_jpg.rf.3bf1ffab8d279ca4bd48ad13a4130f0d.txt 364B
IMG_20190924_153409_jpg.rf.6e981fecbca510d39652de6516a680ea.txt 356B
IMG20200728130843_jpg.rf.a5e8422b28a7242b44da66a718e819a5.txt 343B
IMG20200728130459_jpg.rf.c89f1b1be8bb275f657553e0c87b2eaf.txt 328B
IMG20200728130120_jpg.rf.6b1a43a89bf876fd3c2364c0fad8c9af.txt 327B
IMG20200728130426_jpg.rf.2cc623460f08508406ec2dae7170fe7c.txt 325B
IMG20200728130803_jpg.rf.360feab183c099daf4780deb58104619.txt 324B
IMG20200728130425_jpg.rf.5de598131f3a44f2544453cae9d5b979.txt 324B
IMG20200728130504_01_jpg.rf.9765f509057c0b2aa604eb963419a324.txt 324B
IMG20200728130830_jpg.rf.7416af053ba13767f12348b5271e8e02.txt 324B
IMG20200728131145_jpg.rf.2382ded5479dd6d4f42c19f07f8a026f.txt 323B
IMG20200728130755_jpg.rf.04089afd0e9e4719fda06759e0c1c1ef.txt 323B
IMG20200728130553_jpg.rf.5a4167863f9a8b763497b0ff45453ab5.txt 323B
IMG20200728130826_jpg.rf.107f0a8770637f333448919d6b614423.txt 322B
IMG20200728130544_01_jpg.rf.12b901ba03ff336700209724cde2773e.txt 322B
IMG20200728130128_jpg.rf.6968b8379f50456c2fd093dd4784192e.txt 322B
IMG20200728130820_jpg.rf.f5054a89589bbf8ac974f48694c7face.txt 320B
IMG20200728131147_jpg.rf.374a9b9f236862ece57dae4ab0b60955.txt 320B
IMG20200728130458_jpg.rf.907d63101a609022254f790e33a05ddd.txt 320B
IMG20200728130514_jpg.rf.c5b139cd1ef90dd5af2027363583f67c.txt 319B
IMG20200728130812_jpg.rf.615edcbcca1cc4dc27f470f12b0c9d66.txt 319B
IMG20200728130420_jpg.rf.ed08b7d1744360876e34ba980bc8572d.txt 318B
IMG20200728130527_jpg.rf.28054d57595673bd56d036adb932a92e.txt 318B
IMG20200728131142_jpg.rf.af833e82e03e9d5634eae88682ec1d4e.txt 317B
IMG20200728130805_jpg.rf.f316abf8ff4a596c0f88c30e821169f9.txt 316B
IMG20200728130108_jpg.rf.672ffdadbab4c0db5f0306be23521692.txt 315B
IMG20200728130526_jpg.rf.bb921121ef099f27928ad154e5e65b34.txt 315B
IMG20200728130122_jpg.rf.a248c0baa7bb9d90524857249f0cd79f.txt 315B
IMG20200728130825_jpg.rf.f2611b0bab301bdf974884e00a1b99c7.txt 315B
IMG20200728130756_jpg.rf.8010efd07768a05b15dc3862017eff23.txt 314B
IMG20200728130524_jpg.rf.8c45a9440d4d8f9d6e12c1e1e77eab77.txt 313B
IMG20200728130515_jpg.rf.57381dbf3fd4b67f46ddc200c9589bbb.txt 312B
IMG20200728130431_jpg.rf.8dc09d957122de89098f0971ba803227.txt 312B
IMG20200728130544_jpg.rf.503d456f0419b939906b2368d04ef5a5.txt 311B
IMG20200728130804_jpg.rf.1439dbd708ed22d98ed42afa20337615.txt 311B
IMG20200728130522_jpg.rf.6ce6a3aa9dbedbcb5cadde5629d2a263.txt 310B
IMG20200728130136_jpg.rf.3c269cb9be0b2f33f6dc67de9f664b7c.txt 310B
IMG20200728130036_jpg.rf.7d673afdccca406266f0f94a2e0f07a4.txt 310B
IMG20200728130115_jpg.rf.14ea9afd6a59cb54cca424b3795c37f8.txt 310B
IMG20200728130814_jpg.rf.38617f5f545411e9b5197d61182f6dca.txt 310B
IMG20200728130125_jpg.rf.9027ba9b91d2254206064dc6821110e2.txt 308B
IMG20200728130831_jpg.rf.787bfdf7a33932bf37c507852438b5ba.txt 307B
IMG20200728130112_jpg.rf.5835ed95ec26c4a4928fe48fe06cc598.txt 305B
IMG20200728131141_jpg.rf.65743f5147563271628c1862bca246d1.txt 305B
IMG20200728130551_jpg.rf.474fb1daa441fa0a1940aa9848beaf57.txt 303B
IMG20200728130504_jpg.rf.f3c66e14db2613d48a15a950031493ce.txt 303B
IMG20200728130432_jpg.rf.fc6604164aac0b7d6ae008b3239234d9.txt 296B
IMG20200728130014_jpg.rf.30f863d88b543ad2d85318bf311993dd.txt 287B
IMG20200728131107_jpg.rf.beffa9c89566107252e71267ad9c25cd.txt 283B
IMG20200728131127_jpg.rf.0e9cb8565205e53f059a73fea1947ede.txt 282B
IMG20200728131119_jpg.rf.73e40933b9898a8e46af400da6f61b88.txt 281B
IMG20200728131103_jpg.rf.e26be444efe671cc0748ee0b8220b338.txt 281B
IMG20200728130753_jpg.rf.d4429895f06d0706d912ec3b572fcc23.txt 281B
IMG20200728131134_jpg.rf.9d078732335247c294fd9ee7c27bf954.txt 280B
IMG20200728130007_jpg.rf.bd3c18d3b41d06679ea4ad1eb0c77f7d.txt 279B
IMG20200728130134_jpg.rf.fdccaa95d205e0623dca1221e08b0c70.txt 279B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- m0_671702512024-07-09内容与描述一致,超赞的资源,值得借鉴的内容很多,支持!
stsdddd
- 粉丝: 3w+
- 资源: 929
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Django和OpenCV的智能车视频处理系统.zip
- (源码)基于ESP8266的WebDAV服务器与3D打印机管理系统.zip
- (源码)基于Nio实现的Mycat 2.0数据库代理系统.zip
- (源码)基于Java的高校学生就业管理系统.zip
- (源码)基于Spring Boot框架的博客系统.zip
- (源码)基于Spring Boot框架的博客管理系统.zip
- (源码)基于ESP8266和Blynk的IR设备控制系统.zip
- (源码)基于Java和JSP的校园论坛系统.zip
- (源码)基于ROS Kinetic框架的AGV激光雷达导航与SLAM系统.zip
- (源码)基于PythonDjango框架的资产管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功