trackers目标跟踪库安装和试用

环境搭建

bash 复制代码
git clone https://github.com/roboflow/trackers.git
conda create -n trackers python=3.12.0
conda activate trackers
pip install torch==2.7.0 --index-url https://download.pytorch.org/whl/cu128               
pip install inference -i https://pypi.mirrors.ustc.edu.cn/simple/   
pip install -e . -i https://pypi.mirrors.ustc.edu.cn/simple/                   

demo测试

测试demo:

python 复制代码
import cv2
import supervision as sv
from inference import get_model
from trackers import ByteTrackTracker

model = get_model(model_id="rfdetr-medium")
tracker = ByteTrackTracker()

label_annotator = sv.LabelAnnotator()
trajectory_annotator = sv.TraceAnnotator()

cap = cv2.VideoCapture("720p60hz.mp4")

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    result = model.infer(frame)[0]
    detections = sv.Detections.from_inference(result)
    tracked = tracker.update(detections)

    frame = label_annotator.annotate(frame, tracked)
    frame = trajectory_annotator.annotate(frame, tracked)
    
    cv2.imshow("frame", frame)
    cv2.waitKey(1)

效果如下:

如果检测速度很慢,说明模型在cpu端运行。若需要在gpu上运行模型,需要执行:

bash 复制代码
pip uninstall onnxruntime
pip install onnxruntime-gpu -i https://pypi.mirrors.ustc.edu.cn/simple/ 
相关推荐
VIP_CQCRE13 小时前
GPT Image 2.6 商品图换背景后悬浮?接触阴影、透明区域与反射验收
图像处理·人工智能·ai·电商
泯泷14 小时前
别再傻傻地喂文件了,大厂都在偷偷给AI建这种“专属图书馆”
人工智能
oak隔壁找我15 小时前
一款运行在 DSH(DeepSeek Harness)中的类 Postman HTTP 接口调试插件
人工智能·程序员
高洁0115 小时前
数字孪生与计算机视觉:让机器看懂现场
人工智能·python·机器学习·transformer·迁移学习
Csvn16 小时前
如果明天供应商涨价 3 倍?三层解耦,换模型只改一行配置(C05)
人工智能·aigc·agent
在所不辞兄16 小时前
为什么数字孪生驱动的产线标定需要在线更新机制,而不能一次标定后长期沿用?
人工智能·神经网络·其他·算法·机器学习
锋行天下17 小时前
langgraph 全栈项目(三)
前端·人工智能·后端
黄啊码17 小时前
【黄啊码】最近面了十几个想转 FDE 的程序员,一个都没招
人工智能
锋行天下18 小时前
langgraph 全栈项目(二)
前端·人工智能·后端
大模型真好玩18 小时前
用 Seedance 2.5 Flash 实现1分钟AI短剧,满足孩子的超级英雄对战梦
人工智能·aigc·deepseek