Ignore:
Timestamp:
09/11/2009 04:25:20 PM (11 years ago)
Author:
dave
Message:

added a load of tools for previewing eigenspaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • foam/trunk/python/expression.py

    r113 r114  
    55from faces import * 
    66         
    7 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    8  
    9 #build_expression_pca("../no-redist/yalefaces/processed/*.png",20,30,"expr.pca") 
     7# just try projecting onto vectors that seem 'happy' 
    108 
    119#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     10def print_weight(filename,param,pca,w,h): 
     11        i = Image(filename) 
     12        v = i.Scale(w,h).RGB2GRAY().ToFloatVector() 
     13        p = pca.Project(v) 
     14        print(p[param]) 
    1215 
    13 pca = PCA(1)     
    14 f = OpenFile("expr.pca", "rb") 
    15 pca.Load(f) 
    16 CloseFile(f) 
     16pca = load_pca("yalefaces-30x50.pca") 
     17w = 30 
     18h = 50 
     19filename = "../data/images/faces/dave/expression/normal.png" 
    1720 
    18 emotion_from_expression("../data/images/faces/dave/expression/normal.png",20,30,pca) 
     21print("normal=") 
     22print_weight("../data/images/faces/dave/expression/normal.png",13,pca,w,h) 
     23print("happy=") 
     24print_weight("../data/images/faces/dave/expression/happy.png",13,pca,w,h) 
     25print("angry=") 
     26print_weight("../data/images/faces/dave/expression/angry.png",13,pca,w,h) 
     27print("grimace=") 
     28print_weight("../data/images/faces/dave/expression/grimace.png",13,pca,w,h) 
Note: See TracChangeset for help on using the changeset viewer.