-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDemoVBM.m
45 lines (27 loc) · 898 Bytes
/
DemoVBM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% A demo for video background modeling
% Author: Qibin Zhao 2014
%% load video data
fpath = strcat('.', filesep, 'videos', filesep);
fname = 'hall';
% fname = 'WaterSurface';
% fname = 'ShoppingMall';
% fname = 'Lobby';
load(strcat(fpath,fname));
%% BRCPF for video background and foreground modeling
Y = double(reshape(vid1, [imHeight*imWidth, 3, nFrames]));
Y = Y./255;
timecost =[];
IV =10;
if isequal(fname,'ShoppingMall') || isequal(fname,'Lobby')
IV = 1;
end
tic
[model] = BayesRCP(Y, 'init', 'rand', 'maxRank', 10, 'maxiters', 20, 'initVar', IV, 'updateHyper', 'off',...
'tol', 1e-3, 'dimRed', 1, 'verbose', 1);
timecost(1) = toc;
X = double(ktensor(model.Z)) * 255;
S = model.E * 255;
%% Visualization for results
X_BRCPF = reshape(X, [imHeight, imWidth, 3, nFrames]);
S_BRCPF = reshape(S, [imHeight, imWidth, 3, nFrames]);
showbgfg(vid1, X_BRCPF, S_BRCPF);