参考
步骤
一、仿照写接口 VOT_mosse_ca.m (不会…)
此时,只需要下载一个能够正常运行的跟踪器,仿照其配置的 .m 来写一遍接口就行。
这里给出一个可以正常运行的跟踪器的链接:http://data.votchallenge.net/vot2017/trackers/35_MOSSE_CA.zip
这个跟踪器中的接口文件是 VOT_MOSSE_CA.m ,只需要仿照该.m文件把待运行的跟踪器的接口写好就行
此外,在配置 tracker_MOSSE_CA.m (对应于 tracker_ncc)时,应写为:
tracker_command = generate_matlab_command(‘VOT_MOSSE_CA’, {‘D:\vot-toolkit\workspace_MOSSE_CA\MOSSE_CA’});
这里的 VOT_MOSSE_CA 是待运行脚本的名字,也就是该跟踪器的接口文件,D:\vot-toolkit\workspace_MOSSE_CA\MOSSE_CA 是MOSSE_CA跟踪器的路径,这个路径要换成自己电脑中的跟踪器路径。
————————————————
VOT_MOSSE_CA.m 如下
function VOT_MOSSE_CA
% VOT integration
%
% *************************************************************
% VOT: Always call exit command at the end to terminate Matlab!
% *************************************************************
cleanup = onCleanup(@() exit() );
% *************************************************************
% VOT: Set random seed to a different value every time.
% *************************************************************
RandStream.setGlobalStream(RandStream('mt19937ar', 'Seed', sum(clock)));
% **********************************
% VOT: Get initialization data
% **********************************
[handle, image, region] = vot('rectangle');
target_sz = [region(1,4), region(1,3)];
pos = [region(1,2), region(1,1)] + floor(target_sz/2);
frame = 1;
%default settings
kernel.type = 'linear';
padding = 2;%1.75; %extra area surrounding the target
lambda1 = 1e-4; %regularization
lambda2 = 20;%0.8;
interp_factor = 0.05;%0.025; %linear interpolation factor for adaptation
output_sigma_factor = 0.1; %0.06; %spatial bandwidth (proportional to target)
features.gray = true;
features.hog = false;
features.hogcolor = false;
cell_size = 1;
%if the target is large, lower the resolution, we don't need that much
%detail
resize_image = (sqrt(prod(target_sz)) >= 100); %diagonal size >= threshold
if resize_image,
pos = floor(pos / 2);
target_sz = floor(target_sz / 2);
end
%window size, taking padding into account
window_sz = floor(target_sz * (1 + padding));
% %we could choose a size that is a power of two, for better FFT
% %performance. in practice it is slower, due to the larger window size.
% window_sz = 2 .^ nextpow2(window_sz);
%create regression labels, gaussian shaped, with a bandwidth
%proportional to target size
output_sigma = sqrt(prod(target_sz)) * output_sigma_factor / cell_size;
yf = fft2(gaussian_shaped_labels(output_sigma, floor(window_sz / cell_size)));
%store pre-computed cosine window
cos_window = hann(size(yf,1)) * hann(size(yf,2))';
%note: variables ending with 'f' are in the Fourier domain.
offset = [-target_sz(1) 0; 0 -target_sz(2); target_sz(1) 0; 0 target_sz(2)];
while true
% **********************************
% VOT: Get next frame
% **********************************
if(frame > 1)
[handle, image] = handle.frame(handle);
if isempty(image)
break;
end;
end
im = imread(image);
if (~features.hogcolor)
if size(im,3) > 1,
im = rgb2gray(im);
end
end
if resize_image,
im = imresize(im, 0.5);
end
% tic()
if frame > 1,
%obtain a subwindow for detection at the position from last
%frame, and convert to Fourier domain (its size is unchanged)
patch = get_subwindow(im, pos, window_sz);
zf = fft2(get_features(patch, features, cell_size, cos_window));
response = real(ifft2(model_wf .* zf)); %equation for fast detection
%target location is at the maximum response. we must take into
%account the fact that, if the target doesn't move, the peak
%will appear at the top-left corner, not at the center (this is
%discussed in the paper). the responses wrap around cyclically.
[vert_delta, horiz_delta] = find(response == max(response(:)), 1);
if vert_delta > size(zf,1) / 2, %wrap around to negative half-space of vertical axis
vert_delta = vert_delta - size(zf,1);
end
if horiz_delta > size(zf,2) / 2, %same for horizontal axis
horiz_delta = horiz_delta - size(zf,2);
end
pos = pos + cell_size * [vert_delta - 1, horiz_delta - 1];
end
%obtain a subwindow for training at newly estimated target position
patch = get_subwindow(im, pos, window_sz);
xf = fft2(get_features(patch, features, cell_size, cos_window));
kf = conj(xf) .* xf;
kfn = zeros([size(xf) length(offset)]);
for j=1:length(offset)
%obtain a subwindow close to target for regression to 0
patch = get_subwindow(im, pos+offset(j,:), window_sz);
xfn = fft2(get_features(patch, features, cell_size, cos_window));
kfn(:,:,j) = conj(xfn) .* xfn;
end
num = conj(xf) .* yf;
den = kf + lambda1 + lambda2.*sum(kfn,3);
wf = num ./ den;
if frame == 1, %first frame, train with a single image
model_wf = wf;
else
%subsequent frames, interpolate model
model_wf = (1 - interp_factor) * model_wf + interp_factor * wf;
end
%save position and timing
%positions(frame,:) = pos;
%time = time + toc();
region = [pos([2,1]) - target_sz([2,1])/2, target_sz([2,1])];
if resize_image,
region = region * 2;
end
%rect_results(frame,:)=region;
% **********************************
% VOT: Report position for frame
% **********************************
if(frame > 1)
handle = handle.report(handle, region);
end
frame = frame + 1;
end;
% **********************************
% VOT: Output the results
% **********************************
handle.quit(handle);
end