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

相关推荐
o_insist13 小时前
Docker 入门:从镜像、容器到项目部署
docker·自动化运维·devops
冷小鱼14 小时前
Dockerfile 编写与优化完全指南:从入门到生产级实践
docker·docker file
ziqi52216 小时前
Docker compose 和共享数据
运维·docker·容器
泓博17 小时前
Macbook Docker Compose不识别
运维·docker·容器
susu108301891117 小时前
windows系统的WSL的Ubuntu安装docker
linux·ubuntu·docker
Riu_Peter17 小时前
【技术】Docker 部署 MySQL
mysql·adb·docker
木雷坞19 小时前
Jellyfin Docker Compose 媒体库为空排查:volume、PUID/PGID 和挂载路径
docker·docker-compose·jellyfin
杨浦老苏20 小时前
开源服务器监控工具Checkmate
运维·docker·群晖·网站监控
ℳ₯㎕ddzོꦿ࿐20 小时前
实战指南:使用 Docker Compose 优雅部署 MongoDB 并自动初始化用户
mongodb·docker·容器
一坨阿亮20 小时前
Docker 离线部署
java·spring cloud·docker