当前位置:   article > 正文

十六.CSRT 追踪算法的使用_trackercsrt

trackercsrt

© Fu Xianjun. All Rights Reserved.

import cv2
import numpy as np

OPENCV_OBJECT_TRACKERS = {
    "csrt":cv2.TrackerCSRT_create,
    "kcf":cv2.TrackerKCF_create,
    "boosting":cv2.TrackerBoosting_create,
    "mil":cv2.TrackerMIL_create,
    "tld":cv2.TrackerTLD_create,
}

trackers = cv2.MultiTracker_create()

vs = cv2.VideoCapture("1.mp4")
while True:
    frame = vs.read()
    frame = frame[1]
    if frame is None:
        break
   
    (h,w) = frame.shape[:2]
    width =  600
    r = width/float(w)
    dim = (width,int(h*r))
    frame = cv2.resize(frame,dim)
    #追踪结果
    (success,boxes) = trackers.update(frame)
    for box in boxes:
        (x,y,w,h) = [int(v) for v in box]
        cv2.rectangle(frame,(x,y),(x

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/864738
推荐阅读
相关标签
  

闽ICP备14008679号