-
Notifications
You must be signed in to change notification settings - Fork 1
/
ASL_recognition_v1.m
69 lines (54 loc) · 1.81 KB
/
ASL_recognition_v1.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
function alphabetSign = ASL_recognition(HandRightState, inputImage)
%ASL_recognition This recognition algorithm takes in 2 variables: HandRightState and sample image
%
load('features.mat');
%%% SEGMENT OUT THE HAND
I = inputImage;
%%Normalize
% Replace depth value 0 to 4000. This eliminates IR shadow
I((I<=0)) = 4000;
% Minus all values in array I by the minimum value of itself
I = I - min(min(I));
%%Segmentation
% Readjust values above 90 to 4000.
I((I>90)) = 4000;
% Check HandRightState to determine which cropping algorithm to use
if HandRightState == 3
Z = cropImage_Closed(I);
else
Z = cropImage_Open(I);
end
figure;imshow(Z, [0 100]);
[irow,icol]=size(Z);
% Reshape a 640-by-480 matrix into a matrix that has only 1 column
Z=reshape(Z,irow*icol,1);
Z=double(Z);
Z=Z-mean(Z);
% Check HandRightState to determine which database to use
if HandRightState == 3
featureUnknown = coeff2'*Z;
for i = 1:length(featuresClosed)
d(i) = norm(featureUnknown - featuresClosed(:,i));
end
[distance,index] = min(d);
alphabetList = ['A' 'E' 'M' 'N' 'O' 'S' 'T'];
alphabetListClosed = [];
for i = 1:length(alphabetList);
alphabetListTemp = repmat(alphabetList(i),1,10);
alphabetListClosed = [alphabetListClosed alphabetListTemp];
end
alphabetSign = alphabetListClosed(:,index);
else
featureUnknown = coeff1'*Z;
for i = 1:length(featuresOpen)
d(i) = norm(featureUnknown - featuresOpen(:,i));
end
[distance,index] = min(d);
alphabetList = ['B':'D' 'E':'I' 'K':'L' 'O':'R' 'U':'Y'];
alphabetListOpen = [];
for i = 1:length(alphabetList);
alphabetListTemp = repmat(alphabetList(i),1,10);
alphabetListOpen = [alphabetListOpen alphabetListTemp];
end
alphabetSign = alphabetListOpen(:,index);
end