protected virtual void OnExpressivEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (this.ExpressivEmoStateUpdated != null) { this.ExpressivEmoStateUpdated(this, e); } }
static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; if (e.userId != 0) return; // Get info from UserID 0 float timeFromStart = es.GetTimeFromStart(); file.Write(timeFromStart + ","); Console.WriteLine("Time: " + timeFromStart); EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus(); file.Write(signalStrength + ","); Int32 chargeLevel = 0; Int32 maxChargeLevel = 0; es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel); file.Write(chargeLevel + ","); file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3) + ","); file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7) + ","); file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1) + ","); // Pz file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8) + ","); file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4) + ","); file.WriteLine(""); }
protected virtual void OnCognitivEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (this.CognitivEmoStateUpdated != null) { this.CognitivEmoStateUpdated(this, e); } }
protected virtual void OnEmoEngineEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (this.EmoEngineEmoStateUpdated != null) { this.EmoEngineEmoStateUpdated(this, e); } }
static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); //Console.WriteLine("new emostate {0}", timeFromStart); }
static void engine_FacialExpressionEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); EdkDll.IEE_FacialExpressionAlgo_t[] expAlgoList = { EdkDll.IEE_FacialExpressionAlgo_t.FE_BLINK, EdkDll.IEE_FacialExpressionAlgo_t.FE_CLENCH, EdkDll.IEE_FacialExpressionAlgo_t.FE_SUPRISE, EdkDll.IEE_FacialExpressionAlgo_t.FE_FROWN, EdkDll.IEE_FacialExpressionAlgo_t.FE_HORIEYE, EdkDll.IEE_FacialExpressionAlgo_t.FE_NEUTRAL, EdkDll.IEE_FacialExpressionAlgo_t.FE_SMILE, EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_LEFT, EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_RIGHT }; Boolean[] isExpActiveList = new Boolean[expAlgoList.Length]; Boolean isBlink = es.FacialExpressionIsBlink(); Boolean isLeftWink = es.FacialExpressionIsLeftWink(); Boolean isRightWink = es.FacialExpressionIsRightWink(); Boolean isEyesOpen = es.FacialExpressionIsEyesOpen(); Boolean isLookingUp = es.FacialExpressionIsLookingUp(); Boolean isLookingDown = es.FacialExpressionIsLookingDown(); Single leftEye = 0.0F; Single rightEye = 0.0F; Single x = 0.0F; Single y = 0.0F; es.FacialExpressionGetEyelidState(out leftEye, out rightEye); es.FacialExpressionGetEyeLocation(out x, out y); Single eyebrowExtent = es.FacialExpressionGetEyebrowExtent(); Single smileExtent = es.FacialExpressionGetSmileExtent(); Single clenchExtent = es.FacialExpressionGetClenchExtent(); EdkDll.IEE_FacialExpressionAlgo_t upperFaceAction = es.FacialExpressionGetUpperFaceAction(); Single upperFacePower = es.FacialExpressionGetUpperFaceActionPower(); EdkDll.IEE_FacialExpressionAlgo_t lowerFaceAction = es.FacialExpressionGetLowerFaceAction(); Single lowerFacePower = es.FacialExpressionGetLowerFaceActionPower(); for (int i = 0; i < expAlgoList.Length; ++i) { isExpActiveList[i] = es.FacialExpressionIsActive(expAlgoList[i]); } expLog.Write( "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},", timeFromStart, isBlink, isLeftWink, isRightWink, isEyesOpen, isLookingUp, isLookingDown, leftEye, rightEye, x, y, eyebrowExtent, smileExtent, upperFaceAction, upperFacePower, lowerFaceAction, lowerFacePower); for (int i = 0; i < expAlgoList.Length; ++i) { expLog.Write("{0},", isExpActiveList[i]); } expLog.WriteLine(""); expLog.Flush(); }
static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; scoreMedidation = es.AffectivGetMeditationScore(); //Console.WriteLine(scoreMedidation); scoreExcitement = es.AffectivGetExcitementShortTermScore(); //Console.WriteLine(scoreExcitement); scoreEngage = es.AffectivGetEngagementBoredomScore(); //Console.WriteLine("meditation: " + es.AffectivGetMeditationScore()); //Console.WriteLine("Excitement: " + es.AffectivGetExcitementShortTermScore()); //Console.WriteLine("Frustration: " + es.AffectivGetFrustrationScore()); }
static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); Int32 headsetOn = es.GetHeadsetOn(); EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus(); Int32 chargeLevel = 0; Int32 maxChargeLevel = 0; es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel); }
void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { if (e.userId == 0) { EmoState es = e.emoState; Console.WriteLine("User " ,e.userId, ": ", es.GetTimeFromStart()); } else if( e.userId == 1) { EmoState es = e.emoState; Console.WriteLine("User ", e.userId, ": ", es.GetTimeFromStart()); } }
static void engine_MentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); EdkDll.IEE_MentalCommandAction_t cogAction = es.MentalCommandGetCurrentAction(); Single power = es.MentalCommandGetCurrentActionPower(); Boolean isActive = es.MentalCommandIsActive(); cogLog.WriteLine( "{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive); cogLog.Flush(); if(enableLoger) Console.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive); }
static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { eState = e.emoState; elapsed = eState.GetTimeFromStart(); if ((elapsed > 5) && (!allow)) { allow = true; } if (eState.GetWirelessSignalStatus() == EdkDll.EE_SignalStrength_t.NO_SIGNAL) { allow = false; } }
void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { var excitementShortTermScore = e.emoState.AffectivGetExcitementShortTermScore(); var excitementLongTermScore = e.emoState.AffectivGetExcitementLongTermScore(); var engagementBoredomScore = e.emoState.AffectivGetEngagementBoredomScore(); var frustrationScore = e.emoState.AffectivGetFrustrationScore(); var meditationScore = e.emoState.AffectivGetMeditationScore(); var @event = new AffectivEmoStateUpdated( e.userId, excitementShortTermScore, excitementLongTermScore, engagementBoredomScore, frustrationScore, meditationScore); Store(@event); }
void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction(); Single power = es.CognitivGetCurrentActionPower(); Boolean isActive = es.CognitivIsActive(); if (cogAction == EdkDll.EE_CognitivAction_t.COG_LIFT && isActive == true && power > 0.5) { cog = 1; } else if (cogAction == EdkDll.EE_CognitivAction_t.COG_DROP && isActive == true && power > 0.5) { cog = 2; } else if (cogAction == EdkDll.EE_CognitivAction_t.COG_PUSH && isActive == true && power > 0.5) { cog = 3; } else if (cogAction == EdkDll.EE_CognitivAction_t.COG_PULL && isActive == true && power > 0.5) { cog = 4; } else if (cogAction == EdkDll.EE_CognitivAction_t.COG_LEFT && isActive == true && power > 0.5) { cog = 5; } else if (cogAction == EdkDll.EE_CognitivAction_t.COG_RIGHT && isActive == true && power > 0.5) { cog = 6; } cogLog.WriteLine( "{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive); cogLog.Flush(); }
static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); Int32 headsetOn = es.GetHeadsetOn(); EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus(); Int32 chargeLevel = 0; Int32 maxChargeLevel = 0; es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel); engineLog.Write( "{0},{1},{2},{3},{4},", timeFromStart, headsetOn, signalStrength, chargeLevel, maxChargeLevel); engineLog.WriteLine(""); engineLog.Flush(); }
static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); }
/// <summary> /// Handler for FacialExpressionEmoStateUpdated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnFacialExpressionEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (FacialExpressionEmoStateUpdated != null) FacialExpressionEmoStateUpdated(this, e); }
protected void EmoEngineEmoStateUpdatedCB(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; //Update connexion status lock(syncLock) { mEmoState = es; mIsHeadsetOn = es.GetHeadsetOn() != 0; mCQ = es.GetContactQualityFromAllChannels(); mSignalStrength = es.GetWirelessSignalStatus(); es.GetBatteryChargeLevel(out mBatteryCharge, out mBatteryMaxCharge); mTimeFromStart = es.GetTimeFromStart(); } }
void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { var action = e.emoState.CognitivGetCurrentAction(); var power = e.emoState.CognitivGetCurrentActionPower(); var isActive = e.emoState.CognitivIsActive(); var @event = new CognitivEmoStateUpdated(e.userId, action.ToString(), power, isActive); Store(@event); }
/// <summary> /// Handler for MentalCommandEmoStateUpdated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnMentalCommandEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (MentalCommandEmoStateUpdated != null) MentalCommandEmoStateUpdated(this, e); }
void engine_ExpressivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { var clenchExtent = e.emoState.ExpressivGetClenchExtent(); var eyebrowExtent = e.emoState.ExpressivGetEyebrowExtent(); float leftEyelid, rightEyelid; e.emoState.ExpressivGetEyelidState(out leftEyelid, out rightEyelid); float leftEyeLocation, rightEyeLocation; e.emoState.ExpressivGetEyeLocation(out leftEyeLocation, out rightEyeLocation); var lowerFaceAction = e.emoState.ExpressivGetLowerFaceAction(); var lowerFaceActionPower = e.emoState.ExpressivGetLowerFaceActionPower(); var smileExtent = e.emoState.ExpressivGetSmileExtent(); var upperFaceAction = e.emoState.ExpressivGetUpperFaceAction(); var upperFaceActionPower = e.emoState.ExpressivGetUpperFaceActionPower(); var isBlinking = e.emoState.ExpressivIsBlink(); var isEyesOpen = e.emoState.ExpressivIsEyesOpen(); var isLeftWink = e.emoState.ExpressivIsLeftWink(); var isRightWink = e.emoState.ExpressivIsRightWink(); var isLookingDown = e.emoState.ExpressivIsLookingDown(); var isLookingLeft = e.emoState.ExpressivIsLookingLeft(); var isLookingRight = e.emoState.ExpressivIsLookingRight(); var isLookingUp = e.emoState.ExpressivIsLookingUp(); var @event = new ExpressivEmoStateUpdated( e.userId, clenchExtent, eyebrowExtent, leftEyelid, rightEyelid, leftEyeLocation, rightEyeLocation, lowerFaceAction.ToString(), lowerFaceActionPower, smileExtent, upperFaceAction.ToString(), upperFaceActionPower, isBlinking, isEyesOpen, isLeftWink, isRightWink, isLookingDown, isLookingLeft, isLookingRight, isLookingUp); Store(@event); }
/// <summary> /// Processes EmoEngine events until there is no more events or maximum processing time has elapsed /// </summary> /// <param name="maxTimeMilliseconds">maximum processing time in milliseconds</param> public void ProcessEvents(Int32 maxTimeMilliseconds) { Stopwatch st = new Stopwatch(); st.Start(); while (EdkDll.EE_EngineGetNextEvent(hEvent) == EdkDll.EDK_OK) { if (maxTimeMilliseconds != 0) { if (st.ElapsedMilliseconds >= maxTimeMilliseconds) break; } UInt32 userId = 0; EdkDll.EE_EmoEngineEventGetUserId(hEvent, out userId); EmoEngineEventArgs args = new EmoEngineEventArgs(userId); EdkDll.EE_Event_t eventType = EdkDll.EE_EmoEngineEventGetType(hEvent); switch (eventType) { case EdkDll.EE_Event_t.EE_UserAdded: OnUserAdded(args); break; case EdkDll.EE_Event_t.EE_UserRemoved: OnUserRemoved(args); break; case EdkDll.EE_Event_t.EE_EmoStateUpdated: EmoState curEmoState = new EmoState(); errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(hEvent, curEmoState.GetHandle())); EmoStateUpdatedEventArgs emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, curEmoState); OnEmoStateUpdated(emoStateUpdatedEventArgs); if (!curEmoState.EmoEngineEqual(lastEmoState[userId])) { emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState)); OnEmoEngineEmoStateUpdated(emoStateUpdatedEventArgs); } if (!curEmoState.AffectivEqual(lastEmoState[userId])) { emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState)); OnAffectivEmoStateUpdated(emoStateUpdatedEventArgs); } if (!curEmoState.CognitivEqual(lastEmoState[userId])) { emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState)); OnCognitivEmoStateUpdated(emoStateUpdatedEventArgs); } if (!curEmoState.ExpressivEqual(lastEmoState[userId])) { emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState)); OnExpressivEmoStateUpdated(emoStateUpdatedEventArgs); } lastEmoState[userId] = (EmoState)curEmoState.Clone(); break; case EdkDll.EE_Event_t.EE_CognitivEvent: EdkDll.EE_CognitivEvent_t cogType = EdkDll.EE_CognitivEventGetType(hEvent); switch(cogType){ case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted: OnCognitivTrainingStarted(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded: OnCognitivTrainingSucceeded(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed: OnCognitivTrainingFailed(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted: OnCognitivTrainingCompleted(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased: OnCognitivTrainingDataErased(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected: OnCognitivTrainingRejected(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset: OnCognitivTrainingReset(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted: OnCognitivAutoSamplingNeutralCompleted(args); break; case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated: OnCognitivSignatureUpdated(args); break; default: break; } break; case EdkDll.EE_Event_t.EE_ExpressivEvent: EdkDll.EE_ExpressivEvent_t expEvent = EdkDll.EE_ExpressivEventGetType(hEvent); switch (expEvent) { case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted: OnExpressivTrainingStarted(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded: OnExpressivTrainingSucceeded(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed: OnExpressivTrainingFailed(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted: OnExpressivTrainingCompleted(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased: OnExpressivTrainingDataErased(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected: OnExpressivTrainingRejected(args); break; case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset: OnExpressivTrainingReset(args); break; default: break; } break; case EdkDll.EE_Event_t.EE_InternalStateChanged: OnInternalStateChanged(args); break; default: break; } } }
/// <summary> /// Handler for ExpressivEmoStateUpdated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnExpressivEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (ExpressivEmoStateUpdated != null) ExpressivEmoStateUpdated(this, e); }
/// <summary> /// Handler for EmoEngineEmoStateUpdated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnEmoEngineEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (EmoEngineEmoStateUpdated != null) EmoEngineEmoStateUpdated(this, e); }
void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { es = e.emoState; elapsed = es.GetTimeFromStart(); UpdateSensorContactQuality(es); SignalStatus = es.GetWirelessSignalStatus().ToString(); MainUptime.Content = ConvertToTime(es.GetTimeFromStart()); Uptime.Content = ConvertToTime(es.GetTimeFromStart()); es.GetBatteryChargeLevel(out BatteryLevel, out MaxBatteryLevel); SamplingRate.Content = samplingRate.ToString(); BufferSize.Content = bufferSize.ToString(); EdkDll.EE_DataGetBufferSizeInSec(out bufferSize); EdkDll.EE_DataGetSamplingRate(userID, out samplingRate); EdkDll.EE_ExpressivAlgo_t lowerFaceAction, upperFaceAction; bool expressivIsBlink, expressivIsEyesOpen, expressivIsLeftWink, expressivIsLookingDown, expressivIsLookingLeft, expressivIsLookingRight, expressivIsLookingUp, expressivIsRightWink; float lowerFaceActionPower, upperFaceActionPower; float leftEye, rightEye; #region Expressiv #region Lower Face Action lowerFaceAction = es.ExpressivGetLowerFaceAction(); lowerFaceActionPower = es.ExpressivGetLowerFaceActionPower(); switch (lowerFaceAction) { case EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH: ClearExpressivLowerFaceCircles(); break; case EdkDll.EE_ExpressivAlgo_t.EXP_LAUGH: ClearExpressivLowerFaceCircles(); LaughRect.Fill = Brushes.Green; LaughRect1.Fill = Brushes.Green; break; case EdkDll.EE_ExpressivAlgo_t.EXP_NEUTRAL: ClearExpressivLowerFaceCircles(); break; case EdkDll.EE_ExpressivAlgo_t.EXP_SMILE: ClearExpressivLowerFaceCircles(); SmileRect.Fill = Brushes.Green; SmileRect1.Fill = Brushes.Green; break; case EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT: ClearExpressivLowerFaceCircles(); SmirkLeftRect.Fill = Brushes.Green; SmirkLeftRect1.Fill = Brushes.Green; break; case EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT: ClearExpressivLowerFaceCircles(); SmirkRightRect.Fill = Brushes.Green; SmirkRightRect1.Fill = Brushes.Green; break; default: break; } #region Clench Extent float clenchExtent = es.ExpressivGetClenchExtent(); Clench.Content = toPercentString(clenchExtent); Clench1.Content = toPercentString(clenchExtent); if (clenchExtent < 0.20) { ClenchRect.Fill = Brushes.Black; } else if (clenchExtent < 0.40) { ClenchRect.Fill = Brushes.Red; } else if (clenchExtent < 0.60) { ClenchRect.Fill = Brushes.Orange; } else if (clenchExtent < 0.80) { ClenchRect.Fill = Brushes.Yellow; } else { ClenchRect.Fill = Brushes.Green; } #endregion Clench Extent #region Smile Extent float smileExtent = es.ExpressivGetSmileExtent(); Smile.Content = toPercentString(smileExtent); Smile1.Content = toPercentString(smileExtent); if (smileExtent < 0.20) { SmileRect.Fill = Brushes.Black; } else if (smileExtent < 0.40) { SmileRect.Fill = Brushes.Red; } else if (smileExtent < 0.60) { SmileRect.Fill = Brushes.Orange; } else if (smileExtent < 0.80) { SmileRect.Fill = Brushes.Yellow; } else { SmileRect.Fill = Brushes.Green; } #endregion Smile Extent //LowerFaceAction.Content = lowerFaceAction.ToString(); #endregion Lower Face Action #region Middle Face Action es.ExpressivGetEyelidState(out leftEye, out rightEye); expressivIsBlink = es.ExpressivIsBlink(); if (expressivIsBlink) { ClearExpressivUpperFaceCircles(); BlinkRect.Fill = Brushes.Green; BlinkRect1.Fill = Brushes.Green; } expressivIsEyesOpen = es.ExpressivIsEyesOpen(); if (expressivIsEyesOpen) { //MiddleFaceAction.Content = "Eyes Open"; BlinkRect.Fill = Brushes.Black; BlinkRect1.Fill = Brushes.Black; } else { BlinkRect.Fill = Brushes.Green; BlinkRect1.Fill = Brushes.Green; //MiddleFaceAction.Content = "Eyes Closed"; } expressivIsLeftWink = es.ExpressivIsLeftWink(); if (expressivIsLeftWink) { ClearExpressivUpperFaceCircles(); WinkLeftRect.Fill = Brushes.Green; WinkLeftRect1.Fill = Brushes.Green; } expressivIsRightWink = es.ExpressivIsRightWink(); if (expressivIsRightWink) { ClearExpressivUpperFaceCircles(); WinkRightRect.Fill = Brushes.Green; WinkRightRect1.Fill = Brushes.Green; } expressivIsLookingDown = es.ExpressivIsLookingDown(); if (expressivIsLookingDown) { //MessageBox.Show("I am looking down"); } expressivIsLookingLeft = es.ExpressivIsLookingLeft(); if (expressivIsLookingLeft) { //MessageBox.Show("I am looking left"); // Emotiv SDK is wrong } expressivIsLookingRight = es.ExpressivIsLookingRight(); if (expressivIsLookingRight) { //MessageBox.Show("I am looking right"); // Emotiv SDK is wrong } expressivIsLookingUp = es.ExpressivIsLookingUp(); if (expressivIsLookingUp) { //MessageBox.Show("I am looking up"); } float eyeXCoordinate, eyeYCoordinate; es.ExpressivGetEyeLocation(out eyeXCoordinate, out eyeYCoordinate); if (eyeXCoordinate > 0) { //MessageBox.Show("Looking Right"); } else if (eyeXCoordinate<0) { //MessageBox.Show("Looking Left"); // sometimes it works } if (eyeYCoordinate > 0) { MessageBox.Show("Looking Up"); // not working } else if (eyeYCoordinate < 0) { MessageBox.Show("Looking Down"); // not working } #endregion Middle Face Action #region Upper Face Action upperFaceAction = es.ExpressivGetUpperFaceAction(); upperFaceActionPower = es.ExpressivGetUpperFaceActionPower(); switch (upperFaceAction) { case EdkDll.EE_ExpressivAlgo_t.EXP_EYEBROW: ClearExpressivUpperFaceCircles(); break; case EdkDll.EE_ExpressivAlgo_t.EXP_FURROW: ClearExpressivUpperFaceCircles(); FurrowRect.Fill = Brushes.Green; FurrowRect1.Fill = Brushes.Green; break; case EdkDll.EE_ExpressivAlgo_t.EXP_NEUTRAL: ClearExpressivUpperFaceCircles(); break; default: break; } #region Eyebrow Extent float eyebrowExtent = es.ExpressivGetEyebrowExtent(); Eyebrow.Content = toPercentString(eyebrowExtent); Eyebrow1.Content = toPercentString(eyebrowExtent); if (eyebrowExtent < 0.20) { EyebrowRect.Fill = Brushes.Black; EyebrowRect1.Fill = Brushes.Black; } else if (eyebrowExtent < 0.40) { EyebrowRect.Fill = Brushes.Red; EyebrowRect1.Fill = Brushes.Red; } else if (eyebrowExtent < 0.60) { EyebrowRect.Fill = Brushes.Orange; EyebrowRect1.Fill = Brushes.Orange; } else if (eyebrowExtent < 0.80) { EyebrowRect.Fill = Brushes.Yellow; EyebrowRect1.Fill = Brushes.Yellow; } else { EyebrowRect.Fill = Brushes.Green; EyebrowRect1.Fill = Brushes.Green; } #endregion Eyebrow Extent //UpperFaceAction.Content = upperFaceAction.ToString(); #endregion Upper Face Action // Must be removed #region Robots #region OWI535 Robotic Arm //if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH) //{ // OWI535RoboticArm.GrippersClose(1000); //} //else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT) //{ // OWI535RoboticArm.ArmRotateLeft(1000); //} //else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT) //{ // OWI535RoboticArm.ArmRotateRight(1000); //} //else if (es.ExpressivGetEyebrowExtent() > 0.10) //{ // OWI535RoboticArm.ArmStop(); //} //else if (es.ExpressivIsRightWink()) //{ // OWI535RoboticArm.GrippersOpen(1000); //} #endregion OWI535 Robotic Arm #region R2D2 if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH) { //R2D2.MoveForward(); int iRobotVelocity = getiRobotVelocity(); iRobotMoveForward(iRobotVelocity); } else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT) { //R2D2.MoveLeft(); int iRobotVelocity = getiRobotVelocity(); iRobotTurnLeft(iRobotVelocity); } else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT) { //R2D2.MoveRight(); int iRobotVelocity = getiRobotVelocity(); iRobotTurnRight(iRobotVelocity); } else if (es.ExpressivGetEyebrowExtent() > 0.10) { //R2D2.Stop(); iRobotStop(); } #endregion R2D2 #endregion Robots #endregion Expressiv #region Affectiv AffectiveEngagementBoredom = es.AffectivGetEngagementBoredomScore(); // Get Engagement/Boredom Score. AffectivExcitementLong = es.AffectivGetExcitementLongTermScore(); // Get Excitement Long Term Score. AffectivExcitementShort = es.AffectivGetExcitementShortTermScore(); // Get Excitement Short Term Score. AffectivFrustration = es.AffectivGetFrustrationScore(); // Get Frustration Score. AffectivMeditation = es.AffectivGetMeditationScore(); // Get Meditation Score. #endregion Affectiv #region Cognitiv EdkDll.EE_CognitivAction_t EEGAction; EEGAction = es.CognitivGetCurrentAction(); double cognitivpower = es.CognitivGetCurrentActionPower(); double cognitivpowerPercent = cognitivpower * 100; UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(CognitivPowerProgressBar.SetValue); Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, cognitivpowerPercent }); cognitivPower.Content = (Convert.ToInt32(cognitivpowerPercent)).ToString() + " %"; bool cognitivIsNoisy; cognitivIsNoisy = es.CognitivIsActive(); if (cognitivIsNoisy) { cognitivIsActive.Content = "Noisy"; } else { cognitivIsActive.Content = "Ok"; } // Get Cognitiv Action switch (EEGAction) { case EdkDll.EE_CognitivAction_t.COG_DISAPPEAR: cognitivIsState.Content = "Dissapear"; break; case EdkDll.EE_CognitivAction_t.COG_DROP: MessageBox.Show("Drop"); cognitivIsState.Content = "Drop"; break; case EdkDll.EE_CognitivAction_t.COG_LEFT: cognitivIsState.Content = "Left"; break; case EdkDll.EE_CognitivAction_t.COG_LIFT: cognitivIsState.Content = "Lift"; break; case EdkDll.EE_CognitivAction_t.COG_NEUTRAL: cognitivIsState.Content = "Neutral"; break; case EdkDll.EE_CognitivAction_t.COG_PULL: cognitivIsState.Content = "Pull"; break; case EdkDll.EE_CognitivAction_t.COG_PUSH: cognitivIsState.Content = "Push"; if (cognitivpower > 0.2) { //R2D2.MoveBack(); int iRobotVelocity = getiRobotVelocity(); iRobotMoveForward(iRobotVelocity); //OWI535RoboticArm.Handshake(); } break; case EdkDll.EE_CognitivAction_t.COG_RIGHT: cognitivIsState.Content = "Right"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_CLOCKWISE: cognitivIsState.Content = "Rotate Clockwise"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_COUNTER_CLOCKWISE: cognitivIsState.Content = "Rotate Counter Clockwise"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_FORWARDS: cognitivIsState.Content = "Rotate Forwards"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_LEFT: cognitivIsState.Content = "Rotate Left"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_REVERSE: cognitivIsState.Content = "Rotate Reverse"; break; case EdkDll.EE_CognitivAction_t.COG_ROTATE_RIGHT: cognitivIsState.Content = "Rotate Right"; break; default: break; } #endregion Cognitiv }
void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; if (es.GetHeadsetOn() == 1) { isConnected = true; } else { isConnected = false; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { //System.Diagnostics.Debug.WriteLine("engine_EmoStateUpdating"); EmoState es = e.emoState; //System.Diagnostics.Debug.WriteLine("AffectivGetExcitementShortTermScore: " + es.AffectivGetExcitementShortTermScore()); System.Diagnostics.Debug.WriteLine("AffectivGetEngagementBoredomScore:" + es.AffectivGetEngagementBoredomScore()); //concentrationLabel.Content = "" + es.AffectivGetEngagementBoredomScore(); //System.Diagnostics.Debug.WriteLine("AffectivGetFrustrationScore: " + es.AffectivGetFrustrationScore()); //System.Diagnostics.Debug.WriteLine("AffectivGetMeditationScore: " + es.AffectivGetMeditationScore()); //System.Diagnostics.Debug.WriteLine("" + Environment.NewLine); // send the information via winAPI key_press //if (!((bool)checkBox1.IsChecked)) //{ sendConcentrationLevel(es); //} // send the information via sockets //else if((bool)checkBox1.IsChecked) //{ //asl.sendConcentrationLevelSockets(es); //} }
public void ProcessEvents(int maxTimeMilliseconds) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (EdkDll.EE_EngineGetNextEvent(this.hEvent) == 0) { if ((maxTimeMilliseconds != 0) && (stopwatch.ElapsedMilliseconds >= maxTimeMilliseconds)) { return; } uint pUserIdOut = 0; EdkDll.EE_EmoEngineEventGetUserId(this.hEvent, out pUserIdOut); EmoEngineEventArgs e = new EmoEngineEventArgs(pUserIdOut); switch (EdkDll.EE_EmoEngineEventGetType(this.hEvent)) { case EdkDll.EE_Event_t.EE_CognitivEvent: { switch (EdkDll.EE_CognitivEventGetType(this.hEvent)) { case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted: { this.OnCognitivTrainingStarted(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded: { this.OnCognitivTrainingSucceeded(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed: { this.OnCognitivTrainingFailed(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted: { this.OnCognitivTrainingCompleted(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased: { this.OnCognitivTrainingDataErased(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected: { this.OnCognitivTrainingRejected(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset: { this.OnCognitivTrainingReset(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted: { this.OnCognitivAutoSamplingNeutralCompleted(e); continue; } case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated: { this.OnCognitivSignatureUpdated(e); continue; } } continue; } case EdkDll.EE_Event_t.EE_ExpressivEvent: { switch (EdkDll.EE_ExpressivEventGetType(this.hEvent)) { case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted: { this.OnExpressivTrainingStarted(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded: { this.OnExpressivTrainingSucceeded(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed: { this.OnExpressivTrainingFailed(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted: { this.OnExpressivTrainingCompleted(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased: { this.OnExpressivTrainingDataErased(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected: { this.OnExpressivTrainingRejected(e); continue; } case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset: { this.OnExpressivTrainingReset(e); continue; } } continue; } case EdkDll.EE_Event_t.EE_InternalStateChanged: break; case EdkDll.EE_Event_t.EE_UserAdded: { this.OnUserAdded(e); continue; } case EdkDll.EE_Event_t.EE_UserRemoved: { this.OnUserRemoved(e); continue; } case EdkDll.EE_Event_t.EE_EmoStateUpdated: { EmoState emoState = new EmoState(); errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(this.hEvent, emoState.GetHandle())); EmoStateUpdatedEventArgs args2 = new EmoStateUpdatedEventArgs(pUserIdOut, emoState); this.OnEmoStateUpdated(args2); if (!emoState.EmoEngineEqual(this.lastEmoState[pUserIdOut])) { args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState)); this.OnEmoEngineEmoStateUpdated(args2); } if (!emoState.AffectivEqual(this.lastEmoState[pUserIdOut])) { args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState)); this.OnAffectivEmoStateUpdated(args2); } if (!emoState.CognitivEqual(this.lastEmoState[pUserIdOut])) { args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState)); this.OnCognitivEmoStateUpdated(args2); } if (!emoState.ExpressivEqual(this.lastEmoState[pUserIdOut])) { args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState)); this.OnExpressivEmoStateUpdated(args2); } this.lastEmoState[pUserIdOut] = (EmoState)emoState.Clone(); continue; } default: { continue; } } this.OnInternalStateChanged(e); } }
void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; //Console.WriteLine("{0} ; excitement: {1} ", e.userId, es.AffectivGetEngagementBoredomScore()); //EdkDll.EE_SignalStrength_t strength = es.GetWirelessSignalStatus(); //String dd = strength.ToString(); //int i = es.GetNumContactQualityChannels(); //es.GetContactQualityFromAllChannels(); if (es.GetHeadsetOn() == 1) { isConnected = true; this.timeFromStart = es.GetTimeFromStart(); this.numContactQualityChannels = es.GetNumContactQualityChannels(); this.contactQualityFromAllChannels = es.GetContactQualityFromAllChannels(); this.signalStrength = es.GetWirelessSignalStatus(); this.chargeLevel = 0; this.maxChargeLevel = 0; es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel); } else { isConnected = false; } }
/// <summary> /// Handler for AffectivEmoStateUpated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnAffectivEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (AffectivEmoStateUpdated != null) AffectivEmoStateUpdated(this, e); }
void CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { Rule rule = App.CurrentApp.Rules.FirstOrDefault(r => r.Headset == e.userId && r.Action == e.emoState.CognitivGetCurrentAction() && r.IRCode != null); if (rule != null && e.emoState.CognitivGetCurrentActionPower() >= rule.Threshold) { if (rule.IRCode != lastIRCode) { Status = "Sending IR Code: " + rule.IRCode.Name; App.CurrentApp.USBUIRTInterface.Controller.TransmitAsync(rule.IRCode.Code, CodeFormat.Pronto, 2, TimeSpan.Zero); lastIRCode = rule.IRCode; } } else { lastIRCode = null; } }
/// <summary> /// Handler for CognitivEmoStateUpdated event /// </summary> /// <param name="e">Contains metadata of the event, like userID</param> protected virtual void OnCognitivEmoStateUpdated(EmoStateUpdatedEventArgs e) { if (CognitivEmoStateUpdated != null) CognitivEmoStateUpdated(this, e); }