# Tracker
## Supported Trackers
- [x] ByteTracker
- [x] BoT-SORT
## Usage
### python interface:
You can use the Python interface to track objects using the YOLO model.
```python
from ultralytics import YOLO
model = YOLO("yolov8n.pt") # or a segmentation model .i.e yolov8n-seg.pt
model.track(
source="video/streams",
stream=True,
tracker="botsort.yaml", # or 'bytetrack.yaml'
show=True,
)
```
You can get the IDs of the tracked objects using the following code:
```python
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
for result in model.track(source="video.mp4"):
print(
result.boxes.id.cpu().numpy().astype(int)
) # this will print the IDs of the tracked objects in the frame
```
If you want to use the tracker with a folder of images or when you loop on the video frames, you should use the `persist` parameter to tell the model that these frames are related to each other so the IDs will be fixed for the same objects. Otherwise, the IDs will be different in each frame because in each loop, the model creates a new object for tracking, but the `persist` parameter makes it use the same object for tracking.
```python
import cv2
from ultralytics import YOLO
cap = cv2.VideoCapture("video.mp4")
model = YOLO("yolov8n.pt")
while True:
ret, frame = cap.read()
if not ret:
break
results = model.track(frame, persist=True)
boxes = results[0].boxes.xyxy.cpu().numpy().astype(int)
ids = results[0].boxes.id.cpu().numpy().astype(int)
for box, id in zip(boxes, ids):
cv2.rectangle(frame, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2)
cv2.putText(
frame,
f"Id {id}",
(box[0], box[1]),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(0, 0, 255),
2,
)
cv2.imshow("frame", frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
```
## Change tracker parameters
You can change the tracker parameters by eding the `tracker.yaml` file which is located in the ultralytics/cfg/trackers folder.
## Command Line Interface (CLI)
You can also use the command line interface to track objects using the YOLO model.
```bash
yolo detect track source=... tracker=...
yolo segment track source=... tracker=...
yolo pose track source=... tracker=...
```
By default, trackers will use the configuration in `ultralytics/cfg/trackers`.
We also support using a modified tracker config file. Please refer to the tracker config files
in `ultralytics/cfg/trackers`.<br>
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
客户端环境配置 第一步 配置python环境 下载python(版本:python>=3.8)(建议使用访问Anaconda官网配置虚拟环境,具体步骤如下) 1)访问Anaconda官网:https://www.anaconda.com/products/individual 2)选择相应的操作系统版本并下载对应的安装包(推荐下载64位版本) 3)打开下载的安装包,按照提示进行安装即可 4)创建一个虚拟环境: conda create --name 自命名 python=3.9.16 第二步 下载库 注意:下载库前,如果想要更好的帧数体验请安装cuda版本哦(因为一般默认会安装cpu的版本) pip换源: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 切换到项目文件夹下,下载依赖: pip install -r requirements.txt 我自己使用的环境:python3.9+CPU 第三步 运行项目(如果不需要(开启网页端) 或 (对接RTSP))
资源推荐
资源详情
资源评论
收起资源包目录
基于YOLOv8的多端车流检测系统 (397个子文件)
end-back.env 675B
2023-08-01-11-31-10_kknqb_alarm.jpg 147KB
2023-08-01-17-16-31_xnbqo_default.jpg 147KB
2023-08-01-16-55-29_siwvt_default.jpg 147KB
2023-08-01-11-31-10_zqhxx_alarm.jpg 147KB
2023-08-01-17-24-06_dudvl_testImg.jpg 138KB
2023-08-01-11-44-44_ccpds_testImg.jpg 138KB
2023-08-01-17-56-06_doqhl_testImg.jpg 138KB
2023-08-01-16-55-27_oqpsd_testImg.jpg 138KB
2023-08-01-17-16-29_syiln_testImg.jpg 138KB
2023-08-01-11-28-30_qhfph_testImg.jpg 138KB
2023-08-01-11-29-01_livvh_testImg.jpg 138KB
2023-07-30-15-50-08_ecmmh_testImg.jpg 138KB
2023-07-30-15-59-07_zrdsl_testImg.jpg 138KB
2023-07-30-15-49-16_lifuv_testImg.jpg 138KB
2023-07-30-15-50-27_zqhwo_testImg.jpg 138KB
2023-07-30-15-51-01_zxueu_testImg.jpg 138KB
2023-07-30-15-52-27_akdmb_testImg.jpg 138KB
bus.jpg 134KB
testImg.jpg 132KB
zidane.jpg 49KB
2023-07-30-15-50-03_uuygm_11111.jpg 49KB
logo.jpg 37KB
2023-07-30-15-49-56_hjiyb_a.jpg 2KB
config.json 336B
README.md 2KB
README.md 2KB
README.md 2KB
testVideo.mp4 5.89MB
2023-08-01-17-24-21_radyn.png 117KB
2023-08-01-17-23-09_wxqsh.png 112KB
2023-08-01-11-44-54_sxprv.png 95KB
2023-08-01-11-28-47_cyuje.png 95KB
2023-08-01-11-28-39_eyfah.png 94KB
2023-08-01-11-28-42_fzxsh.png 94KB
2023-08-01-17-21-31_axbdk.png 93KB
2023-08-01-17-22-43_pxgef.png 66KB
2023-08-01-17-21-40_avzvt.png 66KB
2023-08-01-17-22-47_mtkck.png 57KB
2023-07-30-15-59-28_efyuy.png 41KB
2023-08-01-17-24-27_wbjlc.png 10KB
info.png 7KB
2023-08-01-16-55-57_wdrha.png 4KB
danger.png 4KB
warning.png 4KB
success.png 3KB
2023-08-01-17-16-48_goftt.png 2KB
2023-08-01-17-16-54_jzjpv.png 2KB
check_yes.png 867B
delay.png 718B
web.png 596B
RTSP.png 577B
cam.png 553B
conf.png 547B
resize.png 501B
check_no.png 493B
model.png 480B
track.png 461B
IOU.png 445B
pause.png 437B
flow.png 407B
file.png 372B
set.png 345B
begin.png 341B
stop.png 306B
box_down.png 280B
box_up.png 269B
menu.png 248B
save.png 239B
yolov8n.pt 6.23MB
car.pt 6.23MB
resources.py 146KB
main_window.py 87KB
rc_icons.py 56KB
exporter.py 45KB
metrics.py 41KB
augment.py 37KB
tasks.py 35KB
trainer.py 30KB
main.py 29KB
__init__.py 29KB
ops.py 28KB
plotting.py 27KB
autobackend.py 25KB
utils.py 25KB
results.py 24KB
torch_utils.py 23KB
encoders.py 22KB
tiny_encoder.py 21KB
yolo_abandon_01.py 20KB
model.py 20KB
predict.py 19KB
checks.py 19KB
loss.py 19KB
__init__.py 18KB
kalman_filter.py 18KB
yolo_abandon_02.py 17KB
prompt.py 16KB
predictor.py 16KB
loaders.py 16KB
共 397 条
- 1
- 2
- 3
- 4
资源评论
hakesashou
- 粉丝: 4242
- 资源: 1091
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功