c++版本
https://github.com/vojirt/kcf
https://github.com/foolwood/KCF
python版本
-
-
-
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.
--------------------------------------------
解决了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
---------------------------
--------------------
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
- Cython: A Guide for Python Programmers by Kurt Smith
- Cython wrapper between opencv Mat in C++ and numpy http://nicellama.blogspot.com/2015/06/cython-wrapper-between-opencv-mat-in-c.html
-----------------------------