<s> from SimpleCV import * <EOL> import time <EOL> cam = Camera ( <NUM_LIT:0> ) <EOL> names = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> outfile = "<STR_LIT>" <EOL> waitTime = <NUM_LIT:10> <EOL> def getFaceSet ( cam , myStr = "<STR_LIT>" ) : <EOL> iset = ImageSet ( ) <EOL> count = <NUM_LIT:0> <EOL> disp = Display ( ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> while disp . isNotDone ( ) : <EOL> img = cam . getImage ( ) <EOL> fs = img . findHaarFeatures ( '<STR_LIT>' ) <EOL> if ( fs is not None ) : <EOL> fs = fs . sortArea ( ) <EOL> face = fs [ - <NUM_LIT:1> ] . crop ( ) . resize ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> fs [ - <NUM_LIT:1> ] . draw ( ) <EOL> iset . append ( face ) <EOL> count = count + <NUM_LIT:1> <EOL> img . drawText ( myStr , <NUM_LIT:20> , <NUM_LIT:20> , color = Color . RED , fontsize = <NUM_LIT:32> ) <EOL> img . save ( disp ) <EOL> disp . quit ( ) <EOL> return iset <EOL> getFaceSet ( cam , "<STR_LIT>" ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> labels = [ ] <EOL> imgs = [ ] <EOL> for name in names : <EOL> myStr = "<STR_LIT>" + name <EOL> iset = getFaceSet ( cam , myStr ) <EOL> imgs += iset <EOL> labels += [ name for i in range ( <NUM_LIT:0> , len ( iset ) ) ] <EOL> time . sleep ( waitTime ) <EOL> f = FaceRecognizer ( ) <EOL> print f . train ( imgs , labels ) <EOL> f . save ( outfile ) <EOL> disp = Display ( ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> while disp . isNotDone ( ) : <EOL> img = cam . getImage ( ) <EOL> fs = img . findHaarFeatures ( '<STR_LIT>' ) <EOL> if ( fs is not None ) : <EOL> fs = fs . sortArea ( ) <EOL> face = fs [ - <NUM_LIT:1> ] . crop ( ) . resize ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> fs [ - <NUM_LIT:1> ] . draw ( ) <EOL> name , confidence = f . predict ( face ) <EOL> img . drawText ( name , <NUM_LIT:30> , <NUM_LIT:30> , fontsize = <NUM_LIT:64> ) <EOL> img . save ( disp ) </s>
