// Update is called once per frame void Update() { // Pull in the most recent emotional state for each of the modalities if (useFacialEmotion) { currentFacialEmotion = facialAnalyzer.getCurrentEmotions(); currentFacialEmotion2 = facialAnalyzer2.getCurrentEmotions(); currentFACS = facialAnalyzer.getCurrentFACS(); currentFACS2 = facialAnalyzer2.getCurrentFACS(); // Debug.Log("got facial emotion struct"); } if (useWordSentimentEmotion) { currentWordSentimentEmotion = wordAnalyzer.getCurrentEmotions(); } if (useVocalToneEmotion) { currentVocalEmotion = vocalAnalyzer.getVocalToneResults(); } //Set mood tracker attributes CalculateMoodTrackerGeometry(); }
///////////////////////////////////////// SET/CALCULATE CUMULATIVE EMOTION START //////////////////////////////////////////////////// // Returns a final emotion based on the emotion input types that are specified using a simple weighted average. public void calculateCumulativeEmotion() { EmotionStruct emotionSum = new EmotionStruct(); int numEmotionModes = 0; if (useFacialEmotion) { EmotionStruct facialEmotions = facialAnalyzer.getCurrentEmotions(); emotionSum.joy += facialEmotions.joy; emotionSum.sadness += facialEmotions.sadness; emotionSum.anger += facialEmotions.anger; emotionSum.fear += facialEmotions.fear; emotionSum.disgust += facialEmotions.disgust; emotionSum.surprise += facialEmotions.surprise; numEmotionModes++; } if (useWordSentimentEmotion) { Debug.Log("Need to implement emotion from word sentiment."); } if (useVocalToneEmotion) { Debug.Log("Need to implement emotion from vocal tone."); } if (numEmotionModes > 0) { currentCumulativeEmotion.joy = emotionSum.joy / (float)numEmotionModes; currentCumulativeEmotion.sadness = emotionSum.sadness / (float)numEmotionModes; currentCumulativeEmotion.anger = emotionSum.anger / (float)numEmotionModes; currentCumulativeEmotion.fear = emotionSum.fear / (float)numEmotionModes; currentCumulativeEmotion.disgust = emotionSum.disgust / (float)numEmotionModes; currentCumulativeEmotion.surprise = emotionSum.surprise / (float)numEmotionModes; } }