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

相关推荐
.柒宇.2 小时前
信创实战:银河麒麟 V10 服务器安装、网络配置与 Docker 环境搭建
linux·运维·docker·国产信创·麒麟操作系统
IT从业者张某某2 小时前
基于Docker的hadoop容器安装hive并测试
hive·hadoop·docker
杨浦老苏2 小时前
Docker容器管理面板Dockhand
运维·docker·群晖
努力的搬砖人.2 小时前
配置 Docker 镜像加速器
运维·docker·容器
江湖有缘2 小时前
实时监控所有端口,Docker 部署 WatchYourPorts 保姆级教程
运维·docker·容器
IT从业者张某某2 小时前
基于Docker的hadoop容器安装zookeeper
hadoop·docker·zookeeper
guojb8242 小时前
告别部署踩坑:用 Docker Compose 优雅搞定多前端站点、HTTPS 与 SSE 推送
nginx·docker·https
pupudawang3 小时前
docker desktop安装redis
redis·docker·容器
用户78937733908533 小时前
从0到1实战:FastAPI + MySQL 项目 Docker 容器化部署与避坑指南
docker
dLYG DUMS3 小时前
如何在docker中的mysql容器内执行命令与执行SQL文件
sql·mysql·docker