Ignore:
Timestamp:
07/29/2009 03:49:34 PM (10 years ago)
Author:
dave
Message:

Benchmark testing added for the eigen face recognition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • foam/trunk/eigentools/src/main.cpp

    r94 r96  
     1// Copyright (C) 2009 foam 
     2// 
     3// This program is free software; you can redistribute it and/or modify 
     4// it under the terms of the GNU General Public License as published by 
     5// the Free Software Foundation; either version 2 of the License, or 
     6// (at your option) any later version. 
     7// 
     8// This program is distributed in the hope that it will be useful, 
     9// but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11// GNU General Public License for more details. 
     12// 
     13// You should have received a copy of the GNU General Public License 
     14// along with this program; if not, write to the Free Software 
     15// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
     16 
    117#define CV_NO_BACKWARD_COMPATIBILITY 
    218 
     
    3349double scale = 1; 
    3450 
    35 int w=50; 
    36 int h=80; 
    37 //int w=20; 
    38 //int h=30; 
     51//int w=50; 
     52//int h=80; 
     53int w=20; 
     54int h=30; 
    3955 
    4056PCA pca(w*h); 
     
    4662        glob_t g; 
    4763         
    48         glob("../data/images/faces/spacek-large/*.png",GLOB_PERIOD,NULL,&g); 
     64        glob("../data/images/faces/dave/*.png",GLOB_PERIOD,NULL,&g); 
    4965        for (unsigned int n=0; n<g.gl_pathc; n++) 
    5066        { 
     
    6278} 
    6379 
    64 void TestPCA() 
    65 { 
    66         //Recalc(); 
    67         //FILE *f=fopen("spacek-50x80.pca", "wb"); 
    68         //pca.Save(f); 
    69          
    70         FILE *f=fopen("../data/eigenspaces/spacek-50x80.pca", "rb"); 
     80PCA LoadPCA(string filename) 
     81{ 
     82        PCA pca(1); 
     83        FILE *f=fopen(filename.c_str(), "rb"); 
    7184        pca.Load(f); 
    7285        fclose(f); 
     86        return pca; 
     87} 
     88 
     89void TestPCA() 
     90{ 
     91        //Recalc(); 
     92        //FILE *f=fopen("davelight-20x30.pca", "wb"); 
     93        //pca.Save(f); 
     94        pca = LoadPCA("../data/eigenspaces/spacek-20x30.pca"); 
     95         
     96        PCA davelight = LoadPCA("davelight-20x30.pca"); 
     97        //pca.Mult(davelight); 
     98        pca = davelight; 
    7399         
    74100        pca.Compress(0,100); 
     
    79105 
    80106} 
     107 
    81108 
    82109 
     
    298325         
    299326        static float t=0; 
    300          
    301         for (unsigned int i=0; i<30; i++) 
    302         { 
    303                 camera.Blit(Image(w,h,1,(pca.GetEigenTransform().GetRowVector(i)*50)/((i+1) * 1)+pca.GetMean() 
    304                         ),(i%10)*(w+2),0+(i/10)*(h+2)); 
     327        cerr<<sin(t)<<endl; 
     328        for (unsigned int i=0; i<100; i++) 
     329        { 
     330                camera.Blit(Image(w,h,1,(pca.GetEigenTransform().GetRowVector(i)*50*sin(t))/((i+1) * 1)+pca.GetMean() 
     331                        ),(i%30)*(w+2),0+(i/30)*(h+2)); 
    305332        } 
    306333         
Note: See TracChangeset for help on using the changeset viewer.