-
Notifications
You must be signed in to change notification settings - Fork 4
/
visualizeWider.m
59 lines (50 loc) · 1.66 KB
/
visualizeWider.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
function visualizeWider(widerRootDir, partition)
%VISUALIZEWIDER displays WIDER images with annotations
% VISUALIZEWIDER(widerRootDir, partition) generates
% figures that display the bounding box annotations
% provided with the WIDER faces database
%
% `widerRootDir` - a path to the WIDER dataset (contains
% subfolders called WIDER_train, WIDER_val, WIDER_test
% and wider_face_split
%
% `partition` - the portion of the dataset to visualize
% (can be "train" or "val")
%
% Author: Samuel Albanie
% load data for partition
partitionData = load(fullfile(widerRootDir, ...
'wider_face_split', ...
sprintf('wider_face_%s.mat', ...
partition)));
% create containers for the image paths and bounding boxes
imgList = {};
bboxList = {};
% Loop over WIDER "events"
for i = 1: numel(partitionData.event_list)
eventImgList = cellfun(@(x) fullfile(widerRootDir, ...
sprintf('WIDER_%s', partition), ...
'images', ...
partitionData.event_list{i}, ...
strcat(x, '.jpg')), ...
partitionData.file_list{i}, ...
'UniformOutput', false);
eventBboxList = partitionData.face_bbx_list{i};
imgList = vertcat(imgList, eventImgList);
bboxList = vertcat(bboxList, eventBboxList);
end
% Display annotations one image at a time
for i = 1:numel(imgList)
% read in the image
im = imread(imgList{i});
% insert bounding boxes
for j = 1: size(bboxList{i}, 1)
im = insertShape(im, 'Rectangle', ...
bboxList{i}(j,:), ...
'LineWidth', 3);
end
% show image and wait for user
imshow(im);
disp('press any key to continue');
pause;
end