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

相关推荐
杨浦老苏14 小时前
把项目管理搬回自己服务器:Windshift部署与避坑
docker·项目管理·群晖
木雷坞14 小时前
Baserow Docker部署:导入设备借用CSV,再用表单新增登记
运维·docker·容器
wefg115 小时前
【Docker】基本指令
运维·docker·容器
牛马工作号17 小时前
Copyparty 轻量文件共享:Docker Compose 部署、权限与多协议使用全指南
运维·docker·容器
oioihoii18 小时前
Windows部署MySpeed自建测速服务:Docker运行后直接测速,再配置固定公网地址远程查看
运维·docker·容器
Jack N20 小时前
【Strapi 系列之八】二次开发 + 生产部署,Docker + PostgreSQL + Nginx 一把梭
nginx·docker·postgresql·strapi
岁月宁静1 天前
一个 AI 项目从本地到上线,要经过哪些步骤?全流程讲清楚
python·docker·agent
正经教主1 天前
【FDE系列】阶段2:Day 42(UP详细版):Dockerfile 实战 — 把你的应用打包成镜像
人工智能·docker·fde
刘马想放假1 天前
Copyparty 轻量文件共享:Docker Compose 部署、权限与多协议使用全指南
docker·容器
岁寒良木2 天前
麒麟 V10 (x86_64) 离线/联网部署 Docker 26.1.4 与 MaxKB v2.10 LTS 实战指南
python·docker·kylin