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

相关推荐
AOwhisky9 小时前
下一代容器来了?Docker 宣布原生支持 WebAssembly
java·运维·docker·容器·rust·wasm
念何架构之路14 小时前
Docker 容器状态机 学习
java·学习·docker
jieyucx14 小时前
Docker 入门第六阶段:综合实战项目
运维·docker·容器
不能只会打代码16 小时前
Day 002 — Python 工程化 & FastAPI & 数据库速通
数据库·redis·python·docker·fastapi·测试
海涛从不浪16 小时前
03 oect刷入Armbian后安装Onepanel并进行docker迁移
运维·docker·容器·onepanel
yanjieliyun19 小时前
家庭服务器从入门到精通 · 第 5 篇 · NPM反向代理从安装到起飞:一条命令搞定HTTPS
docker
天狼啸月199020 小时前
RagSEDE复现: Docker and Ragflow 关系
docker·容器·ragflow·ragsede
java_logo20 小时前
Docker 部署 SamWaf 完整教程:开源 Web 应用防火墙实测
docker·开源·防火墙·waf·samwaf·轩辕镜像·docker部署waf
C137的本贾尼20 小时前
第十篇:Docker & K8s——标准化应用的“集装箱“和“码头调度中心“
docker·容器·kubernetes
增量星球21 小时前
《持续交付2.0系列一》从技术交付到业务引领
java·docker·容器·devops