⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmultimodelfacerecognition.m

📁 It is for Face Recognition
💻 M
字号:
%function [recRate, ct]=testMultiModelFaceRecognition(Fm1, Fm2, Fm3, wt1, wt2, wt3, R1, R2, R3, ids, poses, xPoses, printExec)
function [recRate, ct]=testMultiModelFaceRecognition(Fm1, Fm2, Fm3, wt1, wt2, wt3, R1, R2, R3, ids, poses, xPoses, printExec)
  dbg='n';
  if dbg=='y'
    fm1 = load('prjATTUpperFaceS04T08L08W18H16K16.dat');
    % 14x18 lower face, 12-d
    fm2 = load('prjATTLowerFaceS01T-06L14W18H12K12.dat');
    % 21x28 full face,  20-d
    fm3 = load('prjATTFullFaceModel4.dat');    

    wt1=ones(16);R1=420; wt2=ones(12);R2=400; wt3=ones(20);R3=860;
    
    % old test set
    ids=[]; poses=[]; xPoses=[]; t= 3;
    if t==1
       ids = [11:40]; poses = [1 2 3 4 6 7 9]; xPoses = [5 8 10];
    elseif t == 2
       ids = [11:40]; poses = [1 2 3 4 6 7 8 9]; xPoses = [5 10];
    elseif t == 3
        ids = [11:40]; poses = [1 2 3 4 5 6 7 8 9]; xPoses = [10];
    elseif t == 4
        ids = [1:20, 31:40]; poses = [1 2 3 4 6 7 8 9 10]; xPoses = [5];
    elseif t == 5
        ids = [6:10, 16:40]; poses = [1 2 4 5 6 7 9 10]; xPoses = [3 8];
    else
        ids = [6:10, 16:40]; poses = [1 2 4 5 6 9 10]; xPoses = [3 7 8];
    end    
  end
  % const
  nPerson=length(ids);
  nPose  =length(poses);
  nXPose =length(xPoses);

  % var
  n=0; nBad=0; nBad1=0; nBad2=0; nBad3=0;
  st=cputime; 
  for j=1:nPerson
     qId = ids(j);      % querying person id     
     for k=1:nXPose
       qPose = xPoses(k);
       n=n+1;
       [recId1(n), nnId1(n), fdaId1(n), knlId1(n), recErr1(n), fdaErr1(n), knlErr1(n), m1(n)]=multiModeFaceRecognition(Fm1, ids, poses, qId, qPose, wt1, R1);
       [recId2(n), nnId2(n), fdaId2(n), knlId2(n), recErr2(n), fdaErr2(n), knlErr2(n), m2(n)]=multiModeFaceRecognition(Fm2, ids, poses, qId, qPose, wt2, R2);
       [recId3(n), nnId3(n), fdaId3(n), knlId3(n), recErr3(n), fdaErr3(n), knlErr3(n), m3(n)]=multiModeFaceRecognition(Fm3, ids, poses, qId, qPose, wt3, R3);      
       qIds(n) = qId;  
           
       % check if all model is bad
       if recId1(n) == -2  
          nBad1=nBad1+1;  
       end
       if recId2(n) == -2  nBad2=nBad2+1; 
          nBad2=nBad2+1;  
       end
       if recId3(n) == -2  
          nBad3=nBad3+1; 
       end
        
       % combine results
       if recId1(n) == -2 | recId2(n) == -2 | recId3(n) == -2 
         nBad=nBad+1;
         recId(n)=-2; recErr=inf;  
         if printExec=='y'       
             fprintf('\n [%d %s] %d:%d: recId=[%d: %d %d %d], err=[%1.4f %1.4f %1.4f] ', 0, '-:---', qId, qPose, -2,recId1(n), recId2(n), recId3(n), recErr1(n),recErr2(n),recErr3(n));
         else
             fprintf('\n [%d %d]', qId, qPose);
         end           
       else   
         % combine models
         recIds = [recId1(n) recId2(n) recId3(n)];
         modelErrs=[recErr1(n), recErr2(n), recErr3(n)];                  
         [minErr, mink]=min(modelErrs);            
         recId(n)=recIds(mink);  

         % force full face model if a tie on min err 
         if recErr3(n) == minErr
            recId(n) = recId3(n); mink=3;
         end
         % process symb
         if recId(n) == qId
            symb(1)='+';
         else
            symb(1)='-';
         end  
         symb(2)=':';
         if recId1(n) == qId
           symb(3) = '+';
         else
           symb(3) = '-';
         end
         if recId2(n) == qId
           symb(4) = '+';
         else
           symb(4) = '-';
         end
         if recId3(n) == qId
           symb(5) = '+';
         else
           symb(5) = '-';
         end
         if printExec=='y'       
             fprintf('\n [%d %s] %d:%d: recId=[%d: %d %d %d], err=[%1.4f %1.4f %1.4f] ', mink, symb, qId, qPose, recId(n),recId1(n), recId2(n), recId3(n), recErr1(n),recErr2(n),recErr3(n));
         else
             fprintf('\n [%d %d]', qId, qPose);
         end
       end
     end % for k
  end % for j
  ct = cputime-st;
  ct = ct/n;

  % rec rate
  nOk = n-nBad; nOk1 = n-nBad1; nOk2 = n-nBad2; nOk3 = n-nBad3;
  t0=recId-qIds; r0=find(t0==0); n0=length(r0);
  t1=recId1-qIds; r1=find(t1==0); n1=length(r1);
  t2=recId2-qIds; r2=find(t2==0); n2=length(r2);
  t3=recId3-qIds; r3=find(t3==0); n3=length(r3);
  t4=nnId1-qIds; r4=find(t4==0); n4=length(r4);
  t5=nnId3-qIds; r5=find(t5==0); n5=length(r5);
  recCnt  = [n0, n1, n2, n3 n4 n5];
  %recRate = [n0/nOk, n1/nOk1, n2/nOk2, n3/nOk3, n4/n, n5/n];
  recRate = [n0/nOk, n1/n, n2/n, n3/n, n4/n, n5/n];
  if printExec=='y'       
     fprintf('\n nOk=%d, [n0..n5]=[%d %d %d %d %d], ', nOk, n0, n1, n2, n3, n4, n5);
  end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -