DSP

KCF各类代码汇总

2019-07-13 18:02发布

c++版本

1.vojirt/kcf

https://github.com/vojirt/kcf

2.foolwood/KCF

https://github.com/foolwood/KCF    

python版本

 
  1. uoip/KCFpy:

  2. uoip/KCFnb:

  3. uoip/KCFcpp-py-wrapper

 

1.uoip/KCFpy:

https://github.com/uoip/KCFpy 本文推荐了(uoip/KCFcpp-py-wrapperhttps://github.com/uoip/KCFcpp-py-wrapper)

 

 

tracker = kcftracker.KCFTracker(False, True, False) # hog, fixed_window, multiscale
You can set the first parameter True for tracking robustness, and set the third parameter True for scale invariance. (I update it now)
I haven't test the the code systematically, so although this code is translated line-by-line from KCFcpp, there may still be some problems.   ------------------------

KCF tracker in Python

Python implementation of
High-Speed Tracking with Kernelized Correlation Filters
J. F. Henriques, R. Caseiro, P. Martins, J. Batista
TPAMI 2015
It is translated from KCFcpp (Authors: Joao Faro, Christian Bailer, Joao F. Henriques), a C++ implementation of Kernelized Correlation Filters. Find more references and code of KCF at http://www.robots.ox.ac.uk/~joao/circulant/

 

Requirements

  • Python 2.7
  • NumPy
  • Numba (needed if you want to use the hog feature)
  • OpenCV (ensure that you can import cv2 in python)
Actually, I have installed Anaconda(for Python 2.7), and OpenCV 3.1(from opencv.org).

 

Use

Download the sources and execute git clone https://github.com/uoip/KCFpy.git cd KCFpy python run.py It will open the default camera of your computer, you can also open a different camera or a video python run.py 2 python run.py ./test.avi Try different options (hog/gray, fixed/flexible window, singlescale/multiscale) of KCF tracker by modifying the arguments in line tracker = kcftracker.KCFTracker(False, True, False) # hog, fixed_window, multiscale in run.py.

 

Peoblem

I have struggled to make this python implementation as fast as possible, but it's still 2 ~ 3 times slower than its C++ counterpart, furthermore, the use of Numba introduce some unpleasant delay when initializing tracker (NEW: the problem has been solved in KCFnb by using AOT compilation). NEWER: I write a python wrapper for KCFcpp, see KCFcpp-py-wrapper, so we can benefit from C++'s speed in python now. --------------------------------------------

2.uoip/KCFnb:

  解决了1.uoip/KCFpy:中的初始化延迟问题 Solve the 'delay' problem of KCFpy by using the Ahead-of-Time compilation (AOT) facility of Numba.     ---------------

KCFnb

Solve the 'delay' problem of KCFpy by using the Ahead-of-Time compilation (AOT) facility of Numba.

 

Requirements

See KCFpy

 

Use

git clone https://github.com/uoip/KCFnb.git cd KCFnb python fhog_utils.py then python run.py

 

Referances:

1.There is a delay when JIT-compiling a complicated function, how can I improve it? http://numba.pydata.org/numba-doc/dev/user/faq.html#there-is-a-delay-when-jit-compiling-a-complicated-function-how-can-i-improve-it
2.Compiling code ahead of time http://numba.pydata.org/numba-doc/dev/user/pycc.html ---------------------------

3.uoip/KCFcpp-py-wrapper

    -------------------- I write a python wrapper for KCFcpp, some of the code are modified from http://nicellama.blogspot.com/2015/06/cython-wrapper-between-opencv-mat-in-c.html .

 

Requirements

  • Python 2.7
  • NumPy
  • Cython
  • OpenCV (both C++ and Python interfaces)

 

Build

python setup.py build_ext --inplace or python setup.py install

 

Usage

python run.py python run.py 1 python run.py test.avi

 

References

  1. Cython: A Guide for Python Programmers by Kurt Smith
  2. Cython wrapper between opencv Mat in C++ and numpy http://nicellama.blogspot.com/2015/06/cython-wrapper-between-opencv-mat-in-c.html
-----------------------------