将.m放在KCF的matlab代码文件夹中即可运行
base_path = 'E:\DSP-c66\KCF工程汇总\1.KCF初代版\KCF初代VS2019工程文件\data\';
video = 'coke';
video_path = [base_path video '/'];
img_files = dir([video_path '*.png']);
if isempty(img_files),
img_files = dir([video_path '*.jpg']);
assert(~isempty(img_files), 'No image files to load.')
end
img_files = sort({img_files.name});
update_visualization = show_video(img_files, video_path, 0);
res_file = 'E:\DSP-c66\KCF工程汇总\1.KCF初代版\KCF初代VS2019工程文件\data\output\res_13629388.txt';
%% 读取groundtruth文件
gt_file = 'E:\single_object_tracking\Benchmark\Coke\groundtruth_rect.txt';
gtid = fopen(gt_file);
groundtruth = textscan(gtid,'%f%f%f%f','Delimiter',',');
groundtruth = cell2mat(groundtruth);
fclose(gtid);
%% 读取结果文件
resid = fopen(res_file);
res = textscan(resid,'%f%f%f%f','Delimiter',',');
res = cell2mat(res);
fclose(resid);
for i = 1:length(res),
box = res(i,:);
stop = update_visualization(i, box);
if stop, break, end %user pressed Esc, stop early
drawnow
end
%% 计算精度
max_threshold = 50; %used for graphs in the paper
precisions = zeros(max_threshold, 1);
%calculate distances to ground truth over all frames
distances = sqrt((res(:,1) - groundtruth(:,1)).^2 + ...
(res(:,2) - groundtruth(:,2)).^2);
distances(isnan(distances)) = [];
%compute precisions
for p = 1:max_threshold,
precisions(p) = nnz(distances <= p) / numel(distances);
end
fprintf('%12s - Precision (20px):% 1.3f, FPS:% 4.2f\n', video, precisions(20))