📄 kfdfacerecognition.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function kfdFaceRecognition()
% z.li, 06-14-2004
% fisher discriminant analysis with local kernel mapping based
% recognition
% function dependency:
% - n/a
% input:
% fm1, fm2, fm3 - face models in d x n
% xId, xPose - an unknown person
% ids - known persons
% poses - known poses
% R - [R1 R2 R3] local radius for 3 models
% options - 'linear', 'kernel', 'distnc'
% output:
% results -[rId1 err1 nModel1]
% -[rId2 err2 nModel2]
% -[rId3 err3 nModel3]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function [results]=kfdFaceRecognition(fm1, fm2, fm3, xId, xPose, ids, poses, R, minFaceCnt, options)
function [results]=kfdFaceRecognition(fm1, fm2, fm3, xId, xPose, ids, poses, R, minFaceCnt, options)
dbg = 'n';
if dbg=='y'
% 18x16 upper face
fm1 = load('prjATTUpperFaceS04T08L08W18H16K16.dat');
% 14x18 lower face
fm2 = load('prjATTLowerFaceS01T-06L14W18H12K12.dat');
% 21x28 full face
fm3 = load('prjATTFullFaceModel4.dat');
xId = 22; xPose = 5;
ids = 11:30; poses = [1 2 3 4 6 7];
R = [400 600 800];
options = 'kernel';
end
% const
nFace = 40; nPose = 10;
if options == 'linear' %'quadratic' 'linear', 'mahalanobis'
method = 'linear';
elseif options == 'kernel'
method = 'quadratic';
else
method = 'mahalanobis';
end
% var
R1 = R(1); R2 = R(2); R3 = R(3);
% get the unknown face projection x1, x2, x3, check for existance
x1 = getAttFaceProj(fm1, xId, xPose);
if isnan(x1(1))==1
fprintf('\n face %d:%d has no proj in upper model, exit', xId, xPose);
results=-2*ones(3,3);
return;
end
x2 = getAttFaceProj(fm2, xId, xPose);
if isnan(x2(1))==1
fprintf('\n face %d:%d has no proj in lower model, exit', xId, xPose);
results=-2*ones(3,3);
return;
end
x3 = getAttFaceProj(fm3, xId, xPose);
if isnan(x3(1))==1
fprintf('\n face %d:%d has no proj in full model, exit', xId, xPose);
results=-2*ones(3,3);
return;
end
% build recognition models from known faces
[X1, Y1, pCnt1]=buildLocalFaceRecogModel(fm1, x1, R1, ids, poses);
[X2, Y2, pCnt2]=buildLocalFaceRecogModel(fm2, x2, R2, ids, poses);
[X3, Y3, pCnt3]=buildLocalFaceRecogModel(fm3, x3, R3, ids, poses);
% purge models
[X1, Y1, nModel1]=purgeFaceRecogModel(ids, pCnt1, X1, Y1, minFaceCnt);
[X2, Y2, nModel2]=purgeFaceRecogModel(ids, pCnt2, X2, Y2, minFaceCnt);
[X3, Y3, nModel3]=purgeFaceRecogModel(ids, pCnt3, X3, Y3, minFaceCnt);
% local model evaluation and recognition
if nModel1 ~= -1
[rId1, err1]=mixedClassify(x1', X1', Y1', method);
if isinf(err1)
rId1=-1;
end
else
rId1 = -1; err1= inf; % not recognized
end
if nModel2 ~= -1
[rId2, err2]=mixedClassify(x2', X2', Y2', method);
if isinf(err2)
rId2=-1;
end
else
rId2 = -1; err2=inf; % not recognized
end
if nModel3 ~= -1
[rId3, err3]=mixedClassify(x3', X3', Y3', method);
if isinf(err3)
rId3=-1;
end
else
rId3 = -1; err3=inf; % not recognized
end
results=[rId1 err1 nModel1;rId2 err2 nModel2; rId3 err3 nModel3];
if dbg=='y'
[rId1 err1 nModel1]
[rId2 err2 nModel2]
[rId3 err3 nModel3]
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -