public static string SummarizeEmotion(EmotionScores scores) { var bestEmotion = Aggregation.GetDominantEmotion(scores); return(string.Format("{0}: {1:N1}", bestEmotion.Item1, bestEmotion.Item2)); }
public static string SummarizeEmotion(Microsoft.ProjectOxford.Common.Contract.EmotionScores scores) { var bestEmotion = Aggregation.GetDominantEmotion(scores); return(string.Format("{0}: {1}%", bestEmotion.Item1, (int)(bestEmotion.Item2 * 100))); }
public static string SummarizeEmotion(Emotion scores) { var bestEmotion = Aggregation.GetDominantEmotion(scores); return(string.Format("{0}: {1:N1}", bestEmotion.Key, bestEmotion.Value)); }
internal static TextBlock SummarizeAllAttributes(TextBlock tb, FaceAPI.Face[] faces, AtosEmployee[] celebrityNames, Tag[] tags, EmotionScores[] emotionScores) { tb.Inlines.Clear(); var header = "Hi!"; if (celebrityNames != null && celebrityNames.Length > 0) { header = "Hi, " + celebrityNames[0].FirstName + " " + celebrityNames[0].LastName; tb.Inlines.Add(new Run(header) { FontSize = 24 }); tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("Your email is {0}", celebrityNames[0].Email)); if (_latestEmail != celebrityNames[0].Email) { _latestEmail = celebrityNames[0].Email; list = ExchangeManipulator.ExchangeHandler.GetCalendarInfo(celebrityNames[0].Email); } tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("You next meetings are:")); foreach (var item in list) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("{0} from {1} to {2}", item.Status, item.StartDate.ToShortTimeString(), item.EndDate.ToShortTimeString())); } } else { header = "Who the duck are you?"; tb.Inlines.Add(new Run(header) { FontSize = 24 }); } if (faces != null && faces.Length > 0) { var face = faces[0]; if (face.FaceAttributes != null) { tb.Inlines.Add(new LineBreak()); var gender = face.FaceAttributes.Gender; tb.Inlines.Add(String.Format("You are {0}", gender)); tb.Inlines.Add(new LineBreak()); var age = face.FaceAttributes.Age; tb.Inlines.Add(String.Format("I think you are {0} years old", age)); tb.Inlines.Add(new LineBreak()); var facialHair = face.FaceAttributes.FacialHair; if (facialHair.Beard > 0.5) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I think I see a beard ({0}%)", facialHair.Beard * 100)); } if (facialHair.Moustache > 0.5) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I think I see a moustache ({0}%)", facialHair.Moustache * 100)); } if (facialHair.Sideburns > 0.5) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("Do I see sideburns? ({0}%)", facialHair.Sideburns * 100)); } var makeUp = face.FaceAttributes.Makeup; if (makeUp.EyeMakeup) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I think I see some eye makeup")); } if (makeUp.LipMakeup) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I think I see a lipstick")); } tb.Inlines.Add(new LineBreak()); var hair = face.FaceAttributes.Hair; if (hair.Bald > 0.5) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I think you're bald ({0}%)", hair.Bald * 100)); } else { if (hair.HairColor.Count() > 0) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("Your hair color is {0}", hair.HairColor[0].Color.ToString())); } } var glasses = face.FaceAttributes.Glasses; var glassesText = ""; switch (glasses) { case FaceAPI.Glasses.NoGlasses: glassesText = "no glasses"; break; case FaceAPI.Glasses.ReadingGlasses: glassesText = "reading glasses"; break; case FaceAPI.Glasses.Sunglasses: glassesText = "sunglasses"; break; case FaceAPI.Glasses.SwimmingGoggles: glassesText = "swimming goggles"; break; } tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("Your are wearing {0}", glassesText)); var smile = face.FaceAttributes.Smile; if (smile > 0.5) { tb.Inlines.Add(new LineBreak()); tb.Inlines.Add(String.Format("I see a smile! ({0}%)", smile * 100)); } if (face.FaceAttributes.Emotion != null) { tb.Inlines.Add(new LineBreak()); var emotion = Aggregation.SummarizeEmotion(face.FaceAttributes.Emotion); var emotionPair = Aggregation.GetDominantEmotion(face.FaceAttributes.Emotion); tb.Inlines.Add(String.Format("You major emotion is ")); switch (emotionPair.Item1) { case "Anger": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Red }); break; case "Happiness": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Green }); break; case "Sadness": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Blue }); break; case "Surprise": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Orange }); break; case "Disgust": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Brown }); break; case "Fear": tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Gray }); break; default: tb.Inlines.Add(new Run(emotion) { Foreground = Brushes.Black }); break; } } } } //tb.Inlines.Add(new Run("the TextBlock control ") { FontWeight = FontWeights.Bold }); //tb.Inlines.Add("using "); //tb.Inlines.Add(new Run("inline ") { FontStyle = FontStyles.Italic }); //tb.Inlines.Add(new Run("text formatting ") { Foreground = Brushes.Blue }); //tb.Inlines.Add("from "); //tb.Inlines.Add(new Run("Code-Behind") { TextDecorations = TextDecorations.Underline }); //tb.Inlines.Add("."); //List<string> attrs = new List<string>(); //if (attr.Gender != null) attrs.Add(attr.Gender); //if (attr.Age > 0) attrs.Add(attr.Age.ToString()); //if (attr.HeadPose != null) //{ // // Simple rule to estimate whether person is facing camera. // bool facing = Math.Abs(attr.HeadPose.Yaw) < 25; // attrs.Add(facing ? "facing camera" : "not facing camera"); //} ////if (attr.FacialHair != null) attrs.Add("Your beard score: " + attr.FacialHair.Beard); return(tb); }