Example #1
0
        private void AddEmotions(Microsoft.Azure.CognitiveServices.Vision.Face.Models.Emotion detectedEmotions)
        {
            emotions = new Emotion[8];

            var properties = detectedEmotions.GetType().GetProperties().ToList();

            properties.ForEach(property => {
                var index                  = properties.IndexOf(property);
                emotions[index].name       = property.Name;
                emotions[index].confidence = (double)property.GetValue(detectedEmotions, null);
            });
        }
 public static KeyValuePair <string, double>[] EmotionToRankedList(Face.Emotion emotion)
 {
     return(new KeyValuePair <string, double>[]
     {
         new KeyValuePair <string, double>("Anger", emotion.Anger),
         new KeyValuePair <string, double>("Contempt", emotion.Contempt),
         new KeyValuePair <string, double>("Disgust", emotion.Disgust),
         new KeyValuePair <string, double>("Fear", emotion.Fear),
         new KeyValuePair <string, double>("Happiness", emotion.Happiness),
         new KeyValuePair <string, double>("Neutral", emotion.Neutral),
         new KeyValuePair <string, double>("Sadness", emotion.Sadness),
         new KeyValuePair <string, double>("Surprise", emotion.Surprise)
     }
            .OrderByDescending(e => e.Value)
            .ToArray());
 }
Example #3
0
        private void AddEmotions(Microsoft.Azure.CognitiveServices.Vision.Face.Models.Emotion detectedEmotions)
        {
            emotions = new List <Emotion>(8);

            var properties = detectedEmotions.GetType().GetProperties().ToList();

            properties.ForEach(property =>
            {
                var index = properties.IndexOf(property);
                emotions.Add(new Emotion {
                    Id         = Guid.NewGuid().ToString(),
                    Name       = property.Name,
                    Confidence = (double)property.GetValue(detectedEmotions, null),
                    ImageId    = Id
                });
            });
        }
 /// <summary>
 /// Initializes a new instance of the FaceAttributes class.
 /// </summary>
 /// <param name="age">Age in years</param>
 /// <param name="gender">Possible gender of the face. Possible values
 /// include: 'male', 'female'</param>
 /// <param name="smile">Smile intensity, a number between [0,1]
 /// </param>
 /// <param name="facialHair">Properties describing facial hair
 /// attributes.</param>
 /// <param name="glasses">Glasses type if any of the face. Possible
 /// values include: 'noGlasses', 'readingGlasses', 'sunglasses',
 /// 'swimmingGoggles'</param>
 /// <param name="headPose">Properties indicating head pose of the
 /// face.</param>
 /// <param name="emotion">Properties describing facial emotion in form
 /// of confidence ranging from 0 to 1.</param>
 /// <param name="hair">Properties describing hair attributes.</param>
 /// <param name="makeup">Properties describing present makeups on a
 /// given face.</param>
 /// <param name="occlusion">Properties describing occlusions on a given
 /// face.</param>
 /// <param name="accessories">Properties describing any accessories on
 /// a given face.</param>
 /// <param name="blur">Properties describing any presence of blur
 /// within the image.</param>
 /// <param name="exposure">Properties describing exposure level of the
 /// image.</param>
 /// <param name="noise">Properties describing noise level of the
 /// image.</param>
 public FaceAttributes(double?age = default(double?), Gender?gender = default(Gender?), double?smile = default(double?), FacialHair facialHair = default(FacialHair), GlassesType?glasses = default(GlassesType?), HeadPose headPose = default(HeadPose), Emotion emotion = default(Emotion), Hair hair = default(Hair), Makeup makeup = default(Makeup), Occlusion occlusion = default(Occlusion), IList <Accessory> accessories = default(IList <Accessory>), Blur blur = default(Blur), Exposure exposure = default(Exposure), Noise noise = default(Noise))
 {
     Age         = age;
     Gender      = gender;
     Smile       = smile;
     FacialHair  = facialHair;
     Glasses     = glasses;
     HeadPose    = headPose;
     Emotion     = emotion;
     Hair        = hair;
     Makeup      = makeup;
     Occlusion   = occlusion;
     Accessories = accessories;
     Blur        = blur;
     Exposure    = exposure;
     Noise       = noise;
     CustomInit();
 }