// // MPT_Emotions1.m // GenderController // // Created by Andrew Salamon on 9/22/08. // Copyright 2008 Machine Perception Laboratory, University of California San Diego. All rights reserved. // #import "MPT_Emotions1.h" #import @interface MPT_Emotions1(PrivateMethods) -(void)makeNewEmotions; @end @implementation MPT_Emotions1 - (id)initWithBundle:(NSBundle *)_bundle { if( self = [super initWithBundle:_bundle] ) { [self makeNewEmotions]; } return self; } - (void)dealloc { delete emotions; [super dealloc]; } - (id)copyWithZone:(NSZone *)zone { id cp = [super copyWithZone:zone]; return cp; } - (void)makeThreadsafe { [super makeThreadsafe]; [self makeNewEmotions]; } - (NSString *)localizedName { return NSLocalizedStringFromTableInBundle(@"Emotion Detector", nil, [self bundle], @""); } - (NSString *)internalName { return @"emotion1"; } - (NSString *)step { return MPT_PluginStep_Results; } -(void)makeNewEmotions { emotions = new mpt::Emotions1; NSString *weightsPath = [[self bundle] pathForResource:@"emotions1" ofType:@"txt"]; // need to load the emotion weights if( [weightsPath length] > 0 ) emotions->readFromFile( [weightsPath UTF8String] ); else NSLog( @"Unable to read emotion weights file in Emotions1 plugin." ); } - (NSMutableDictionary *)processResults:(NSDictionary *)results usingController:(id)controller; { NSMutableDictionary *res = [NSMutableDictionary dictionary]; // edu.ucsd.mplab.plugins.CERT4_4_Weights: 1, 2, 4, 5, 9, 10, 12, 14, 15, 17, 20 // edu.ucsd.mplab.plugins.AdditonalAUs: 25, 17, 7, 6, 26, 15, 24, 23, 27, 18, 9, 28 NSDictionary *aus = [res objectForKey:@"edu.ucsd.mplab.plugins.CERT4_4_Weights"]; NSDictionary *addAUs = [res objectForKey:@"edu.ucsd.mplab.plugins.AdditonalAUs"]; std::vector inputs; // // Find the inputs we need and add them to a vector // need the following aus: 1 2 4 5 6 7 9 10 12 14 15 17 18 20 23 24 25 26 28 /* Main AUs (AU 1) Inner Brow Raise (AU 2) Outer Brow Raise (AU 4) Brow Lower (AU 5) Eye Widen (AU 9) Nose Wrinkle (AU 10) Lip Raise (AU 12) Lip Corner Pull (AU 14) Dimpler (AU 15) Lip Corner Depressor (AU 17) Chin Raise (AU 20) Lip stretch */ /* Additional AUs AU 25 AU 17 AU 7 AU 6 AU 26 AU 15 AU 24 AU 23 AU 27 AU 18 AU 9 AU 28 */ //call std::vector ans = emotions->calc( inputs ); return res; } @end