This repository has been archived by the owner on Apr 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testPictures.asv
113 lines (95 loc) · 3.5 KB
/
testPictures.asv
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function testPictures()
picFolder = 'faces/';
logFile = 'logOutput.txt';
results = struct();
clearTextFile(logFile);
[picPaths, picCount] = scanFolder4Pics(picFolder);
for i = 1:picCount
pic = picPaths{i};
field = strrep(pic,'.','');
field = strrep(field,'/','');
field = strrep(field,'\','');
value = {[0 0 0], pic};
results = setfield(results, strcat(field), value);
end
fields = fieldnames(results);
for i = 1:picCount
try
[gender, percentage] = augenBraue(results.(fields{i}){2}, logFile);
if gender == 'm'
results.(fields{i}){1}(1) = getP(results.(fields{i}){1}(1), percentage);
elseif gender == 'w'
results.(fields{i}){1}(2) = getP(results.(fields{i}){1}(2), percentage);
elseif gender == 'u'
results.(fields{i}){1}(3) = getP(results.(fields{i}){1}(3), percentage);
end
catch
%augen braun fehler
end
try
[gender, percentage] = lipsdetection(results.(fields{i}){2});
if gender == 'm'
results.(fields{i}){1}(1) = getP(results.(fields{i}){1}(1), percentage);
elseif gender == 'w'
results.(fields{i}){1}(2) = getP(results.(fields{i}){1}(2), percentage);
elseif gender == 'u'
results.(fields{i}){1}(3) = getP(results.(fields{i}){1}(3), percentage);
end
catch
% fehler
end
try
% feature bart
[gender, BinMask] = beardRecognition(results.(fields{i}){2});
if gender == 'm'
results.(fields{i}){1}(1) = getP(results.(fields{i}){1}(1), percentage);
elseif gender == 'w'
results.(fields{i}){1}(2) = getP(results.(fields{i}){1}(2), percentage);
elseif gender == 'u'
results.(fields{i}){1}(3) = getP(results.(fields{i}){1}(3), percentage);
end
catch
% fehler
end
try
% feature kinn
catch
% fehler
end
try
measurements = regionprops(Binmask, 'BoundingBox', 'Area');
%Setup loop seching for the biggest area of the found regions
mainRegion = measurements(1);
if ndims(measurements)/2 > 1
for regionCnt = 2:ndims(measurements)/2
if(measurements(regionCnt*2).Area > mainRegion.Area)
mainRegion = measurements(regionCnt);
end
end
end
[gender, percentage] = hairDetection(results.(fields{i}){2},mainRegion);
if gender == 'm'
results.(fields{i}){1}(1) = getP(results.(fields{i}){1}(1), percentage);
elseif gender == 'w'
results.(fields{i}){1}(2) = getP(results.(fields{i}){1}(2), percentage);
elseif gender == 'u'
results.(fields{i}){1}(3) = getP(results.(fields{i}){1}(3), percentage);
end
catch
% fehler
end
end
end
function [r] = getP(already, addition)
if addition == 0
r = already;
elseif already == 0;
r = addition;
else
r = already * addition;
end;
end
function clearTextFile(textFile)
fileID = fopen(textFile,'w');
fclose(fileID);
end