DSP跑KCF代码之后读取结果txt文件并在Matlab中可视化结果

将.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))
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhengky6

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值