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 "trackers[detection]"

从源代码安装

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

相关推荐
winfreedoms3 小时前
宿主机有网、Docker 容器不能解析域名?用 daemon.json 一键配置永久 DNS
运维·docker·容器·json
橙露3 小时前
Docker 实战:镜像瘦身、多阶段构建与最佳实践
运维·docker·容器
TT哇3 小时前
【项目】从“本地能跑”到“生产级部署”:Java + Docker 自动化部署深度复盘
java·docker·自动化
小李小李快乐不已5 小时前
docker(1)-环境和基本概念
运维·c++·docker·容器
God__is__a__girl5 小时前
Docker Desktop 在 Windows 上启动失败:500 Internal Server Error 完整排查与修复指南
windows·docker·容器
摸鱼的后端5 小时前
Docker容器中Kingbase数据库授权到期更换解决方案
数据库·docker·容器
yuweiade6 小时前
使用 Docker 部署 RabbitMQ 的详细指南
docker·容器·rabbitmq
2601_949814177 小时前
docker离线安装及部署各类中间件(x86系统架构)
docker·中间件·系统架构
舒一笑7 小时前
Docker 场景下 Linux 内核参数调优:哪些必须改宿主机?哪些可以写进容器
docker·容器