how to use kcf tracker with HOG features in opencv3.3.1?

asked 2018-03-14 21:52:27 -0500

Hello, guys! I'm playing with KCF tracker in Opencv3.3.1. I have learned this tutorial on Now I wonder how I can use HOG feature in KCF. I tried using HOGDescriptor to compute the features of roi region. But it seems that the dimensions of feat and dimensions of hann used in KCF implementations mismatched. I have googled for it but I can't find related issues. So is there anyone can help or give me some hints kindly? Thank you very much.

edit retag flag offensive close merge delete


did you see 2. there in the tutorial ?

like many other trackers, KCF cannot change it's internal window size, you have to fit everything to the initial rect

berak gravatar imageberak ( 2018-03-15 02:20:32 -0500 )edit

Thank you very much! I tried fitting the HOG features into the initial rect, and it works now. Besides, I have noticed that there is a TrackerFeatureHOG class here( But it seems that there's no tutorial on how to use it. I wonder if you know something about such TrackerFeature class.

mihawk2010 gravatar imagemihawk2010 ( 2018-03-15 04:11:30 -0500 )edit

i whish i would know !

the interfaces there are a total mess, if you want my 2 ct. there is a CvHogEvaluator in features.cpp, but no real trace, which tracker class is actually using it, or how to get it from the public api.

(the Boosting and Mil uses the CvHaarFeature, at least)

berak gravatar imageberak ( 2018-03-15 04:36:03 -0500 )edit

ok, I'll see it. Thank you again

mihawk2010 gravatar imagemihawk2010 ( 2018-03-15 04:44:58 -0500 )edit

@mihawk2010 Can you give more details how you use HOG feature in KCFtracker? Thanks.

DavidT gravatar imageDavidT ( 2018-03-23 13:15:29 -0500 )edit

@berak , @mihawk2010 Could you please share your code for fitting the HOG features into the initial rect. I dont know how to do it, since the initial rect is a mxn Matrix and the HOG features are a 1xn vector

mk_ocv gravatar imagemk_ocv ( 2018-10-01 02:28:18 -0500 )edit

@mk_ocv , you probably can't. those KCF features are "per-pixel".

maybe you can use angle / magnitude features (sobel -> cartToPolar), that would be HOG without the H. (no histograms)

berak gravatar imageberak ( 2018-10-01 02:40:16 -0500 )edit

@berak Thanks for your quick answer! Sounds like an interesting approch, i'll definetily try that one! You said kcf uses raw pixels only, are you talking about the OpenCV implementation or about the algorithm in general? In the original paper to the KCF Tracking framework, they proposed to use kcf on hog features. So I guess there must be a way to do it?! Also i noticed there is a cv::TrackerFeature class which also implements cv::TrackerFeatureHOG. I'm assuming it can be used with the TrackerKCF class but i don't know how? Any ideas?


mk_ocv gravatar imagemk_ocv ( 2018-10-01 03:33:25 -0500 )edit

read the other comments again. i think it's used with MIL

and personally, i never had any nice results, trying with KCF, or even trying to extend it. MOSSE,CSRT or MEDIANFLOW worked good for me.

berak gravatar imageberak ( 2018-10-01 03:36:54 -0500 )edit

Tracking results highly depend on use-case. KCF seems to be one which fits my use-case quite well. Unfortunetaly, openCV tracking API is not documented well :/

mk_ocv gravatar imagemk_ocv ( 2018-10-01 07:30:40 -0500 )edit