【目标追踪】基于核相关滤波器实现目标跟踪含matlab源码
【目标追踪】基于核相关滤波器实现目标跟踪含matlab源码
TT_Matlab
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。
1 简介
目标跟踪技术在智能交通、安全监控、人机交互和运动分析等领域有着广泛的应用。近些年,目标跟踪技术取得了飞速的发展,涌现出许多优秀的目标跟踪算法,解决了很多棘手的目标跟踪问题。但是,目标跟踪技术仍然面临着很多的挑战,由于现实环境较为复杂,目前的跟踪算法在实时性、精确性等方面还不能满足实际应用。本文对KCF目标跟踪算法进行优化,KCF跟踪算法利用循环矩阵进行密集采样提取图像的HOG特征,使用正则化最小二乘分类器进行训练提高了运行速度。KCF跟踪算法的优势为目标跟踪速度快,在Benmark视频序列集OTB50的平均速度为172fps,平均精度为73.2%。
2 部分代码
function [img_files,
pos
, target_sz, ground_truth, video_path] = load_video_info(base_path, video)
%LOAD_VIDEO_INFO
% Loads all the relevant information
for
the video in the
given
path:
% the list of image files (cell array of strings), initial position
% (
1
x2), target size (
1
x2), the ground truth information
for
precision
% calculations (Nx2,
for
N frames),
and
the path where the images are
% located. The ordering of coordinates
and
sizes is always [
y
,
x
].
%在给定路径中加载视频的所有相关信息:图像文件列表(字符串单元数组)、初始位置(
1
x2)、
%目标大小(
1
x2)、用于精确计算的ground truth信息(N帧的Nx2)以及图像所在的路径。
%坐标和大小的顺序总是[
y
,
x
]。
%
% Joao F. Henriques,
2014
% http:
//www
.isr.uc.pt/~henriques/
%see
if
there
’s a suffix, specifying one of multiple targets, for
%example the dot and number in ’
Jogging.
1
’ or ’
Jogging.
2
’.
%{
if numel(video) >= 2 && video(end-1) == ’
.
’ && ~isnan(str2double(video(end))),
suffix = video(end-1:end); %remember the suffix
video = video(1:end-2); %remove it from the video name
else
suffix = ’
’;
end
%full path to the video’
s
files
if
base_path(end) ~=
’/’
&& base_path(end) ~=
’’,
base_path(end+1) = ’
/
’;
end
%}
%video_path = [base_path video ’
/
’];
%video_path = [base_path video];
% video_path = choose_video(base_path);%大概因为这句,所以我需要选择两次视频
video_path = video;
%try to load ground truth from text file (Benchmark’
s
format
)
%尝试从文本文件(基准测试的格式)加载ground truth
%{
filename = [video_path
’Basketball_gt’
suffix
’.txt’
];
f = fopen(filename);
assert(f ~= -
1
, [
’No initial position or ground truth to load ("’
filename
’").’
])
%the
format
is [
x
,
y
, width, height]
try
ground_truth = textscan(f,
’%f,%f,%f,%f’
,
’ReturnOnError’
,false);
catch %#ok, try different
format
(
no
commas)
frewind(f);
ground_truth = textscan(f,
’%f %f %f %f’
);
end
%}
text_files = dir([video_path
’*_gt.txt’
]);
assert(~isempty(text_files),
’No initial position and ground truth (*_gt.txt) to load.’
)
f = fopen([video_path text_files(
1
).name]);
ground_truth = textscan(f,
’%f,%f,%f,%f’
);%已经将car4数据进行修改
ground_truth = cat(
2
, ground_truth{:});
fclose(f);
%set initial position
and
size
target_sz = [ground_truth(
1
,
4
), ground_truth(
1
,
3
)];
pos
= [ground_truth(
1
,
2
), ground_truth(
1
,
1
)] + floor(target_sz/
2
);
if
size(ground_truth,
1
) ==
1
,
%we have ground truth
for
the first frame only (initial position)
ground_truth = [];
else
%store positions instead of boxes
ground_truth = ground_truth(:,[
2
,
1
]) + ground_truth(:,[
4
,
3
]) /
2
;
end
%from now on, work in the subfolder where all the images are
video_path = [video_path
’imgs/’
];
%f
or
these sequences, we must limit ourselves to a range of frames.
%for all others, we just load all png/jpg files in the folder.
frames = {
’David’
,
300
,
770
;
’Football1’
,
1
,
74
;
’Freeman3’
,
1
,
460
;
’Freeman4’
,
1
,
283
};
idx = find(strcmpi(video, frames(:,
1
)));
if
isempty(idx),
%general case, just list all images
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});
else
%list specified frames. try png first, then jpg.
if
exist(
sprintf
(
’%s%04i.png’
, video_path, frames{idx,
2
}),
’file’
),
img_files = num2str((frames{idx,
2
} : frames{idx,
3
})
’, ’
%04i.png
’);
elseif exist(sprintf(’
%s%04i.jpg
’, video_path, frames{idx,2}), ’
file
’),
img_files = num2str((frames{idx,2} : frames{idx,3})’
,
’%04i.jpg’
);
else
error(
’No image files to load.’
)
end
img_files = cellstr(img_files);
end
end
3 仿真结果
4 参考文献
[1] J. F. Henriques, R. Caseiro, P. Martins, J. Batista, "High-Speed Tracking with
Kernelized Correlation Filters", TPAMI 2014 (to be published).
[2] J. F. Henriques, R. Caseiro, P. Martins, J. Batista, "Exploiting the Circulant
Structure of Tracking-by-detection with Kernels", ECCV 2012.
[3] Y. Wu, J. Lim, M.-H. Yang, "Online Object Tracking: A Benchmark", CVPR 2013.
Website: http://visual-tracking.net/
[4] P. Dollar, "Piotr’s Image and Video Matlab Toolbox (PMT)".
Website: http://vision.ucsd.edu/~pdollar/toolbox/doc/index.html
[5] P. Dollar, S. Belongie, P. Perona, "The Fastest Pedestrian Detector in the
West", BMVC 2010.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
适
适
-
2023年血糖新标准公布,不是3.9-6.1,快来看看你的血糖正常吗? 2023-02-07
-
2023年各省最新电价一览!8省中午执行谷段电价! 2023-01-03
-
GB 55009-2021《燃气工程项目规范》(含条文说明),2022年1月1日起实施 2021-11-07
-
PPT导出高分辨率图片的四种方法 2022-09-22
-
2023年最新!国家电网27家省级电力公司负责人大盘点 2023-03-14
-
全国消防救援总队主官及简历(2023.2) 2023-02-10
-
盘点 l 中国石油大庆油田现任领导班子 2023-02-28
-
我们的前辈!历届全国工程勘察设计大师完整名单! 2022-11-18
-
关于某送变电公司“4·22”人身死亡事故的快报 2022-04-26
