-
Notifications
You must be signed in to change notification settings - Fork 0
/
getDatabank.m
32 lines (27 loc) · 985 Bytes
/
getDatabank.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
% Get metadata of the available images
function databank = getDatabank(labels)
databank = struct('files',{},'label',{});
for i=1:length(labels)
label = labels{i};
class_location = strcat(pwd() , '/training_images/', label, '/');
class_set.label = label;
class_set.files = struct('imfile',{},'annfile',{});
j = 0;
n = length(dir([class_location, '\*.mat']));
for counter=1:n
j=j+1;
%% Get next filename
image_file = [class_location, sprintf('image_%04d.jpg',j)];
annotation_file = [class_location, sprintf('annotation_%04d.mat',j)];
while (exist(image_file, 'file')~=2) && (j < n)
j=j+1;
image_file = strcat(class_location,sprintf('image_%04d.jpg',j));
annotation_file = strcat(class_location,sprintf('annotation_%04d.mat',j));
end
% Push metada class_set to bank
file.imfile = image_file;
file.annfile = annotation_file;
class_set.files = [class_set.files file];
end
databank = [databank class_set];
end