/CSK

A Python implementation of "Exploiting the Circulant Structure of Tracking-by-Detection with Kernels"

Primary LanguagePythonMIT LicenseMIT

CSK Tracker in Python

This is a Python implementation of "Exploiting the Circulant Structure of Tracking-by-Detection with Kernels" [1]. The above three sequences (Dog1, Sylvester, FaceOcc2) are taken from [2].

Requirements

  • Numpy
  • Scipy

Sample Code

from csk import *
import numpy as np
from scipy.misc import imread, imsave
import cv2 # (Optional) OpenCV for drawing bounding boxes

length = 472 # sequence length

# 1st frame's groundtruth information
x1 = 125 # position x of the top-left corner of bounding box
y1 = 162 # position y of the top-left corner of bounding box
width = 74 # the width of bounding box
height = 55 # the height of bounding box

sequence_path = "" # your sequence path
save_path = "" # your save path

tracker = csk.CSK() # CSK instance

for i in range(1,length+1): # repeat for all frames
    frame = imread(sequence_path+"%04d.jpg"%i)

    if i == 1: # 1st frame
        print(str(i)+"/"+str(length)) # progress
        tracker.init(frame,x1,y1,width,height) # initialize CSK tracker with GT bounding box
        imsave(save_path+'%04d.jpg'%i,cv2.rectangle(cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR), \
        (x1, y1), (x1+width, y1+height), (0,255,0), 2)) # draw bounding box and save the frame

    else: # other frames
        print(str(i)+"/"+str(length)) # progress
        x1, y1 = tracker.update(frame) # update CSK tracker and output estimated position
        imsave(save_path+'%04d.jpg'%i,cv2.rectangle(cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR), \
        (x1, y1), (x1+width, y1+height), (0,255,0), 2)) # draw bounding box and save the frame

Precision Plots

     

This is precision plots for 3 sequences above (Dog1, Sylvester, FaceOcc2).

References

[1]

Exploiting the Circulant Structure of Tracking-by-Detection with Kernels
João F. Henriques, Rui Caseiro, Pedro Martins, Jorge Batista
ECCV 2012

[2]

Online Object Tracking: A Benchmark
Yi Wu, Jongwoo Lim, Ming-Hsuan Yang
CVPR 2013