recently, i need call the KCF tracker in my graduation project. the KCF tracker is fast and best performance now. see http://home.isr.uc.pt/~henriques/circulant/, however, this only matlab version of KCF code in the author's homepage. i need to implement KCF in c++ version, however, i find it is hard to do it, because this is no opencv version of fhog which is used in the matlab version. and the correlation of complex number is hard too. So in the last , i build Windows Standalone Application. and it is easy to improve in matlab.
so let do it now.

first let make a file runKCFexe.m

function runKCFexe( base_path ,video)
%./data/Benchmark/ Boy
interp_factor = 0.02;
kernel.sigma = 0.5;
kernel.type = 'gaussian';
kernel.poly_a = 1;
kernel.poly_b = 9;
feature_type = 'hog';
features.hog = true;
features.gray = false;
features.hog_orientations = 9;
cell_size = 4;

padding = 1.5;  %extra area surrounding the target
lambda = 1e-4;  %regularization
output_sigma_factor = 0.1;  %spatial bandwidth (proportional to target)

[img_files, pos, target_sz, ground_truth, video_path] = load_video_info(base_path, video);
[positions, time] = tracker(video_path, img_files, pos, target_sz, ...
			padding, kernel, lambda, output_sigma_factor, interp_factor, ...
			cell_size, features, 0);
        
fileID = fopen('centerPointResult.txt','w');
fprintf(fileID,'%d %d\n',positions');
fclose(fileID);
%fprintf('kcf finished %s\n','done');
end

and edit the tracker.m to the follow:

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

the box2[1] is the frame number and box2[2:5] is the rect box

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

add the reference files like follows

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

and then build

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

and we will get the KCFexe.exe

test run the KCFexe.exe

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

Yehh, it works

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

Qt C++ programming

let's build a q widget application

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

the OpenDir Button is used to select the dir path like
call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

the Qlabe is used to show the image.
the project dir structure

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

the dirpath and video is the Parameters for KCFexe.exe
frameNo is used for read NO.image from capture , procOutput is used to get the frame num and rect box from KCFexe.exe output and store in the s_data,capturePath is used for VideoCapture.open function , program is the KCFexe.exe path,on_pushButton_clicked() is to select the dir,readyReadStandardOutput() is to read the KCFexe.exe output,processRect() is used to show image in Qlabel.RectReady() is signal for processRect.

init and connect

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

select dir

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

run the KCFexe.exe

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

read the output of KCFexe.exe

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

show image in Qlabel

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

Note ,because the speed of KCFexe.exe output is not the same with readyReadStandardOutput so the code is need in the processRect()

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

finnally ,it run like this

call Kernelized Correlation Filters Tracker(Matab) in Qt(c++)

相关文章:

  • 2021-10-08
  • 2021-05-18
  • 2021-06-11
  • 2021-05-17
  • 2022-01-18
  • 2021-09-25
  • 2021-05-26
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2021-06-22
  • 2021-06-10
  • 2021-08-09
  • 2021-09-20
  • 2021-05-23
相关资源
相似解决方案