# 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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1、yolov8算法裂缝检测-汽车车身凹陷-抓痕检测-汽车车身损伤检测,包含训练好的yolo算法裂缝检测-汽车车身凹陷-抓痕检测-汽车车身损伤检测,以及PR曲线,loss曲线等等,和数据集 2、pyqt界面可以检测图片、视频、调用摄像头 3、数据集和检测结果参考:https://blog.csdn.net/zhiqingAI/article/details/124230743 4、采用pytrch框架,python代码 https://blog.csdn.net/zhiqingAI/article/details/137371158
资源推荐
资源详情
资源评论
收起资源包目录
yolov8算法裂缝检测-汽车车身凹陷-抓痕检测-汽车车身损伤检测+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
IMG_20220310_115922_jpg.rf.47aed01d02d4d5f270f198b17188d011.txt 2KB
IMG_20220310_120612_jpg.rf.8bd26197a00f06fcc8251546337df973.txt 2KB
IMG_20220310_115922_jpg.rf.a523b8accd79fe7f0418ae951fac55ee.txt 2KB
IMG_20220307_143450_jpg.rf.3dac8ec69f4d116e8baf6ffd617e183f.txt 2KB
IMG_20220307_182243_jpg.rf.ed322cdcd55a4b98632c180407af6c9e.txt 1KB
IMG_20220310_120612_jpg.rf.788538313dca2e9c6712e63c65308899.txt 1KB
crack_72_jpg.rf.1ae5cbec5e1285f69904bf97f281b367.txt 958B
IMG_20220310_120618_jpg.rf.50712c3f050c1f29f3b8bfb8f3261fc8.txt 877B
IMG_20220310_120618_jpg.rf.47745744240b784bd29f19151eac5d32.txt 832B
IMG_20220308_105335_jpg.rf.b43c70803cbdffad46006a08ae09e5fe.txt 746B
IMG_20220310_120623_jpg.rf.b2b5e28b0ccb9691ba834611524678c6.txt 720B
foto_32_jpg.rf.3d8285c1f0310cc364369c0f711f1b1b.txt 718B
image20_jpeg_jpg.rf.a2c8204ece0e5c9bfc53e5be19315239.txt 717B
IMG_20220310_120533_jpg.rf.48425e9d5e7e74ef03c5e878824a5f2d.txt 715B
IMG_20220310_115914_jpg.rf.87210c06ae49255f441010166c494a25.txt 670B
IMG_20220310_120628_jpg.rf.039925c74c9ed30caf543a0557f63fee.txt 665B
IMG_20220307_182253_jpg.rf.d47fd288ba89939b7e739fc1849195fc.txt 652B
2390_jpg.rf.1bdf1f32fb3beb3856de5292b54591eb.txt 647B
2390_jpg.rf.9f489aab8d83cdcde207ca77b9e061e2.txt 638B
IMG_20220307_143337_jpg.rf.de392e8173110718abb6573455e131dc.txt 617B
image20_jpeg_jpg.rf.9277c6177c68a965a84d69ac92e428ca.txt 577B
foto_31_jpg.rf.396a929f3ea0750676ab15fb3e34bef0.txt 560B
IMG_20220310_120616_jpg.rf.28d6d55ede1134ca867297841e5184de.txt 560B
How-to-Prevent-Wall-Cracks_jpg.rf.0999536c8bb6f2b546c2702ae8d2c31c.txt 542B
foto_30_jpg.rf.79ed640d6e94da5822fe4325b3c7d9c7.txt 532B
foto_28_jpg.rf.a1e398cf62d377392e477e18a659225e.txt 520B
IMG_20220308_122213_jpg.rf.b328e23cd08017bbe0578fa22ff01556.txt 501B
IMG_20220307_182253_jpg.rf.933a66be456abc7205a310ac1055216c.txt 501B
IMG_20220308_122213_jpg.rf.5fed5214710c4526837f9b10c4298000.txt 500B
2047_jpg.rf.ef922ece423d60e08e27278b9508918b.txt 480B
2047_jpg.rf.66be851a016931deeb01ec6f7116cf38.txt 477B
StepCracks415DJFs_jpg.rf.c1adabb12530933e5f29cd0ac77a0e76.txt 476B
foto_34_jpg.rf.202cf39f956c370558d3c9230eb1913d.txt 475B
2548_jpg.rf.63c261b1c0c9188785cfa8921bfacbc1.txt 474B
foto_9_jpg.rf.3223181b6027a3ababddf9e41b0850de.txt 473B
2548_jpg.rf.9f63ddc247573e729e90197426d59940.txt 472B
IMG_20220310_120533_jpg.rf.33be08ed2c5b12a92027604875ad48ea.txt 430B
IMG_20220309_120509_jpg.rf.9bdc573ee433ff77b8d4d2d9594569fb.txt 403B
55954f1b-bc09cedc-c18_jpg.rf.74a91cac9f87640d8acbc6369c30877d.txt 402B
smallscratches_original_23-jpg_123d8e22-4241-4f35-9e7b-6847c1c66377_jpg.rf.73f3dc10864cf1d48bac459687e45275.txt 402B
Wall-cracks-cornice_jpg.rf.7d282fe29ecabf2c3dc0cf0a8a9d0235.txt 400B
2017_jpg.rf.9a43ba34eb1e382b049b19b7a1427e30.txt 400B
04ff146c-13216e9b-c11_jpg.rf.4a4e4787c58a3f1053dc67ecd64f46b5.txt 399B
smallscratches_original_18-jpg_9b4d78fd-e6ad-46d0-ac9d-d3a53e83d6e2_jpg.rf.537650c5120f846a99b95565335dd337.txt 399B
How-to-fix-a-cracked-wall-step-by-step_jpg.rf.6acf4a69a3265fb0e3dccc71340719e2.txt 398B
smallscratches_original_18-jpg_2a49f25c-ecf6-46da-8060-c973c2a0e3c0_jpg.rf.c7f983047299444ed1712fd1aa870634.txt 398B
04ff146c-13216e9b-c11_jpg.rf.fefb943c1014ae446b8cfc8ff1f39bcf.txt 396B
smallscratches_original_23-jpg_689570d3-a0c9-4d1a-8877-813847b537a7_jpg.rf.6cb5ddaae87e39eaa50576fc7bb253a4.txt 395B
04ff146c-13216e9b-c11_jpg.rf.9fdb68dd527d304e89e65405ec4addb9.txt 395B
images660_jpg.rf.daa499291449f211896c3844dca2b568.txt 394B
2390_jpg.rf.46587f95d20536e31444eef32e84ef0c.txt 377B
IMG_20220308_122213_jpg.rf.c93a7db9eed4982661440e5dd94c0efa.txt 343B
IMG_20220307_143354_jpg.rf.32e06c6d42f898e77596a8eafd13ac0c.txt 333B
IMG_20220310_115851_jpg.rf.8122de806394b78ed2037d8668475070.txt 331B
images660_jpg.rf.a56e10fcdff99f5fd12b13367e7a83d4.txt 325B
smallscratches_original_18-jpg_3c88c640-8363-4f63-a413-e3e377cf03f9_jpg.rf.1e96761866c7a83b670de216ca6bd7ca.txt 322B
smallscratches_original_18-jpg_327f3d6c-a3ad-464b-83eb-658d6ad5a173_jpg.rf.231270c1c78e8de06564102f07669973.txt 318B
images320_jpg.rf.8f24ce5232e64cfa83277e0cf0111c69.txt 317B
smallscratches_original_14-jpg_a7efee5e-d05f-4175-b26a-cabf3bd71091_jpg.rf.44b8d89767a9bae5d1ec8cc22a82b8e9.txt 317B
smallscratches_original_18-jpg_c5056973-366a-4f87-b77c-841f433c2e75_jpg.rf.bbf4b65cbbe9aa0a89994b1b5cb32b3d.txt 317B
smallscratches_original_14-jpg_20bb6438-e3de-4800-ae19-bb640d741724_jpg.rf.8ef58df273a614dc06892db8d7cfb0f5.txt 317B
smallscratches_original_18-jpg_c5056973-366a-4f87-b77c-841f433c2e75_jpg.rf.cf476b5a338b21bb9d70a999d2ce461d.txt 317B
smallscratches_original_18-jpg_a67ef894-1149-456d-9349-39e0e77b99e3_jpg.rf.2c737d1f3ede0884fbfc695f44ff2d33.txt 316B
smallscratches_original_14-jpg_974226e1-f8cb-4237-adb7-564ca35100cd_jpg.rf.a825872c3942269c6f49a1bb1ec2d6e1.txt 316B
foto_5_jpg.rf.3d139116ef20c846a1a4ab0b2533350c.txt 315B
smallscratches_original_14-jpg_5b6338c9-4835-4df1-a23b-ba2b6f5f3b5d_jpg.rf.b32f700877c8e9ba7b2f1eb965232313.txt 314B
smallscratches_original_14-jpg_57988d2f-0183-49ed-9df5-a1dadef81a4d_jpg.rf.c40d24404da57b6f6c2a4b43945ebd77.txt 312B
smallscratches_original_23-jpg_f0865fad-8e2d-4002-8143-2b6fb6c60c77_jpg.rf.d64ba3cd994ba59c31d5cbe32d463d18.txt 307B
00787_jpg.rf.70af2b7cfda7fb8c00cbf7e15a63faff.txt 302B
foto_36_jpg.rf.82081a05d2c2d77a8a8cbbc85e5b6a3c.txt 291B
foto_37_jpg.rf.42569032d406cd252de58614bc0d9179.txt 288B
smallscratches_original_23-jpg_3eb78b39-296e-4046-a28d-41eff5c49b84_jpg.rf.6b245680ce19479476c56af4e908a7ab.txt 257B
foto_15_jpg.rf.10d348cebb6bb1e62d3112540b80f3e4.txt 250B
IMG_20220310_115937_jpg.rf.cc700584f7fb6663c021ebafdae1afe3.txt 242B
01370_jpg.rf.69ed29dd16872df3e6b11a84e1d22121.txt 241B
00101_jpg.rf.3f5185ceb1b4ade94810c699fcbb9e20.txt 241B
March-15-094731_jpg.rf.348e9a4a5f604576f627e53bb85e8960.txt 240B
IMG20220608103740_jpg.rf.8076074759425fa7bb4b0d504ad70920.txt 240B
foto_17_jpg.rf.6f46892afdd086cd48c0ce5ffd39bc3c.txt 239B
2376_png_jpg.rf.73722d502ac5dcdb76bffe6585a44307.txt 238B
foto_24_jpg.rf.d1459b259da996cc0dd54d87dfe0a201.txt 238B
2558_jpeg_jpg.rf.013c93c49c29a21d7dfcc43ddbfc12d7.txt 237B
smallscratches_original_25-jpg_6780c6c7-93b3-47ae-9e7f-4c628231e95e_jpg.rf.22d02156b31e1dafae40c772367cc556.txt 237B
smallscratches_original_25-jpg_3c9072da-63b0-4f02-aaf7-f0e785f59661_jpg.rf.a4c9224baf5b28e00b4b334c0fc32ba4.txt 237B
foto_3_jpg.rf.d07ca8d2adb00ae849d586a0643f8cb9.txt 237B
crack-repair2_jpg.rf.804c91c4380a2f5eed99cf55d321187e.txt 237B
de65bfc4563c4813bb25bb65eb6cfe76_jpg.rf.a743200e803b9519aa5045110190457d.txt 236B
smallscratches_original_26-jpg_a11832d1-8d4c-46e6-be06-066d143795cc_jpg.rf.04cb5d84215e31ed42df7a730f6681bb.txt 236B
crack_245_jpg.rf.79e6108957517979e79208b596271074.txt 236B
2028_JPEG_jpg.rf.aa0ada1de98ac194a3cf690e98e8e723.txt 235B
2558_jpeg_jpg.rf.160d621e3b2bedb881589d77b47d9ea3.txt 235B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
stsdddd
- 粉丝: 2w+
- 资源: 710
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功