roboflow的trackers追踪

git国内地址: https://gitcode.com/GitHub_Trending/track/trackers

github地址:https://github.com/roboflow/trackers

官网文档地址:https://trackers.roboflow.com/develop/trackers/bytetrack/

环境可以在之前的一篇rf-detr环境基础上安装即可。

pip install trackers

额外的库:

pip install "trackersdetection"

从源代码安装

pip install git+https://github.com/roboflow/trackers.git

运行检测追踪代码:

复制代码
import cv2
import supervision as sv
# from rfdetr import RFDETRLarge
from rfdetr.platform.models import RFDETR2XLarge

from trackers import ByteTrackTracker
tracker = ByteTrackTracker()

# from trackers import SORTTracker
# tracker = SORTTracker()


model = RFDETR2XLarge()

box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()

video_capture = cv2.VideoCapture("input.mp4")
if not video_capture.isOpened():
    raise RuntimeError("Failed to open video source")

while True:
    success, frame_bgr = video_capture.read()
    if not success:
        break

    frame_rgb = cv2.cvtColor(frame_bgr, cv2.COLOR_BGR2RGB)
    detections = model.predict(frame_rgb)
    detections = tracker.update(detections)

    annotated_frame = box_annotator.annotate(frame_bgr, detections)
    annotated_frame = label_annotator.annotate(
        annotated_frame,
        detections,
        labels=detections.tracker_id,
    )

    cv2.imshow("RF-DETR + ByteTrack", annotated_frame)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

video_capture.release()
cv2.destroyAllWindows()

注意如果想使用RFDETR2XLarge模型:需要安装扩展:

pip install rfdetr[plus]

调用:

from rfdetr.platform.models import RFDETR2XLarge

相关推荐
张文君17 小时前
docker使用代理拉取镜像
运维·docker·容器
陌路2018 小时前
Docker教程从入门到精通(0基础)
运维·docker·容器
初级炼丹师(爱说实话版)19 小时前
Ubuntu24.04 Docker+vLLM+qianwen2.5-coder-32B部署文档
docker·容器·vllm
ᥬ 小月亮1 天前
SonarQube使用教程(Docker安装)
运维·docker·容器
在世修行1 天前
Windows 上 Docker Desktop 部署 MySQL + TDengine 全过程(含 WSL 报错与镜像加速排障实战)
windows·mysql·docker·tdengine
自律最差的编程狗1 天前
从零搭建:VMware + Ubuntu + Docker + MySQL 完整指南
mysql·ubuntu·docker
老虎海子1 天前
Dockerfile 零基础:指令详解 + Compose 对比 + 前端镜像实战
开发语言·前端·docker·rpc
天空之外1361 天前
Docker安装MySQL 8.4 LTS、Docker安装Redis 7.4.x、Docker安装MinIO
java·mysql·docker
空谷有来人1 天前
springcloud中配置ci/cd集成docker的配置文件
spring cloud·ci/cd·docker
空谷有来人1 天前
docker安装redis
redis·docker·容器