-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_lmdata.m
120 lines (89 loc) · 3.27 KB
/
load_lmdata.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
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
114
115
116
117
118
%function [LM_Num,LM_XX,LM_YY] = load_lmdata(LM_Path)
function [LM_DATA] = load_lmdata(LM_Path)
% Load the facial image file name
%
% LM_Path : Landmark data File path
%
% LM_Num : Landmark data size
% LM_XX : Landmark data x-axis
% LM_YY : Landmark data y-axis
%
%Initial the LM data
LM_DATA = InitLMData();
%i = 0;
fid = fopen(LM_Path,'rt');
while (feof(fid) == 0)
tline = fgetl(fid);
d = size(tline);
if (tline(1) == '#')
p = findstr(tline, '=');
if (strcmp(tline(2:p-1),'name'))
%disp(tline(p-1:d(2)));
LM_DATA.Path = tline(p+1:d(2));
elseif (strcmp(tline(2:p-1),'operator'))
%disp(tline(p-1:d(2)));
LM_DATA.Operator = tline(p+1:d(2));
elseif (strcmp(tline(2:p-1),'num'))
%disp(tline(p-1:d(2)));
LM_DATA.Num = str2num(tline(p+1:d(2)));
if LM_DATA.Num < 52
LM_DATA.Num = 52;
end
LM_DATA.XX = zeros(LM_DATA.Num,1);
LM_DATA.YY = zeros(LM_DATA.Num,1);
%i = 0;
elseif (strcmp(tline(2:p-1),'use'))
LM_DATA.USE = str2num(tline(p+1:d(2)));
elseif (strcmp(tline(2:p-1),'score'))
%disp(tline(p-1:d(2)));
LM_DATA.SCORE = str2num(tline(p+1:d(2)));
if LM_DATA.SCORE > 5
LM_DATA.SCORE = 5;
elseif LM_DATA.SCORE < 0
LM_DATA.SCORE = 0;
end
elseif (strcmp(tline(2:p-1),'face_emotation'))
%LM_DATA.FACE_EMOTATION:
%0:default; 1:smile; 2:cry; 3:angry; 4:fear; 5:sorrow
LM_DATA.FACE_EMOTATION = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'face_type'))
%LM_DATA.FACE_TYPE:
%0:default; 1:cute; 2:cool; 3:smart; 4:normal; 5:others
LM_DATA.FACE_TYPE = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'mouth_type'))
%LM_DATA.MOUTH_TYPE:
%0:close; 1:open; 2:moddle
LM_DATA.MOUTH_TYPE = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'left_eye'))
%LM_DATA.LEFT_EYE:
%1:close; 0:open
LM_DATA.LEFT_EYE = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'right_eye'))
%LM_DATA.RIGHT_EYE:
%1:close; 0:open
LM_DATA.RIGHT_EYE = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'im_width'))
LM_DATA.IM_WIDTH = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'im_height'))
LM_DATA.IM_HEIGHT = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
elseif (strcmp(tline(2:p-1),'ver'))
%Landmark data file fomart version
LM_DATA.VER = str2num(tline(p+1:d(2)));
%disp(tline(p-1:d(2)));
end
elseif (tline(1) == '@')
%disp(tline(2:d(2)));
numlist = str2num(tline(2:d(2)));
idx = numlist(1);
LM_DATA.XX(idx) = numlist(2);
LM_DATA.YY(idx) = numlist(3);
end
end
fclose(fid);