-
Notifications
You must be signed in to change notification settings - Fork 0
/
gene_VLAD_Fea_Freq_5C.m
executable file
·64 lines (49 loc) · 1.93 KB
/
gene_VLAD_Fea_Freq_5C.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%%
%% Haimin ZHANG 13 OCT 2015
%%
function [] = gene_FV_Fea_Freq()
clear all; close all; clc;
fea_dir = 'featuresFreq_vladfreq';
run('./vlfeat-0.9.20/toolbox/vl_setup.m');
pyramid = [1 ];
dictPath = 'dictionary/DEEP_CodeBook_FreqDom_16.mat';
load(dictPath);
centers = DEEP_CodeBook_FreqDom_16;
load('dictionary/videoDatabase_resnet.mat');
videoDatabase = videoDatabase_resnet;
nFea = length(videoDatabase.path);
feaDatabase_Freq = struct;
feaDatabase_Freq.path = cell(nFea, 1);
feaDatabase_Freq.label = zeros(nFea, 1);
tic;
for iter1 = 7:nFea
%iter1
if ~mod(iter1, 10)
fprintf('%d video clips processed', iter1);
toc;
end
fpath = videoDatabase.path{iter1};
flabel = videoDatabase.label(iter1);
load(fpath);
feaArr = feaSet.feaArr(:,:,3);
[rtpath, fname] = fileparts(fpath);
feaPath = fullfile(fea_dir, num2str(flabel), [fname '.mat']);
%fea = TPM_pooling(feaSet, B, pyramid);
kdtree = vl_kdtreebuild(centers) ;
nn = vl_kdtreequery(kdtree, centers, feaArr');
assignments = zeros( size(centers, 2), size(feaArr, 2));
assignments(sub2ind(size(assignments), nn, 1:length(nn))) = 1;
fea = vl_vlad(feaArr',centers,assignments, 'SquareRoot');
%fea = fea / norm(fea);
%feaFreqDom = TPM_FreqDom_pooling(feaSet, [1], [1]);
if ~isdir(fullfile(fea_dir, num2str(flabel)))
mkdir(fullfile(fea_dir, num2str(flabel)))
end
label = videoDatabase.label(iter1);
save(feaPath, 'fea', 'label');
feaDatabase_Freq.path{iter1} = feaPath;
feaDatabase_Freq.label(iter1) = flabel;
end
feaDatabase_Freq_vlad = feaDatabase_Freq;
save('dictionary/feaDatabase_Freq_vlad', 'feaDatabase_Freq_vlad');
end