Esempio n. 1
0
        public string GetUrlPhotoWithEmotion(EmotionsType type)
        {
            string url             = string.Empty;
            double maxEmotionScore = 0;

            for (int i = 0; i < _EmotionsInformation.Count; i++)
            {
                EmoInfo emotInf             = _EmotionsInformation[i];
                double  currentEmotionScore = 0;
                int     facesCount          = emotInf.Emotions.Count;
                //если человек на фотографии не один - продолжаем дальше
                if (facesCount > 1)
                {
                    continue;
                }
                for (int j = 0; j < emotInf.Emotions.Count; j++)
                {
                    currentEmotionScore += EmoUtils.GetEmoScore(emotInf.Emotions[j], type);
                }
                if (currentEmotionScore > maxEmotionScore)
                {
                    maxEmotionScore = currentEmotionScore;
                    url             = emotInf.ImageUrl;
                }
            }
            return(url);
        }
Esempio n. 2
0
        public static string GetEmotionLabel(EmotionsType type)
        {
            switch (type)
            {
            default:
            case EmotionsType.Happiness:
                return("Happiness");

            case EmotionsType.Fear:
                return("Fear");

            case EmotionsType.Anger:
                return("Anger");

            case EmotionsType.Contempt:
                return("Contempt");

            case EmotionsType.Disgust:
                return("Disgust");

            case EmotionsType.Neutral:
                return("Neutral");

            case EmotionsType.Sadness:
                return("Sadness");

            case EmotionsType.Surprise:
                return("Surprise");
            }
        }
Esempio n. 3
0
        public static string GetEmotionColor(EmotionsType type)
        {
            switch (type)
            {
            default:
            case EmotionsType.Happiness:
                return("#f1c40f");

            case EmotionsType.Fear:
                return("#34495e");

            case EmotionsType.Anger:
                return("#c0392b");

            case EmotionsType.Contempt:
                return("#f39c12");

            case EmotionsType.Disgust:
                return("#7f8c8d");

            case EmotionsType.Neutral:
                return("#27ae60");

            case EmotionsType.Sadness:
                return("#9b59b6");

            case EmotionsType.Surprise:
                return("#3498db");
            }
        }
Esempio n. 4
0
        public static float GetEmoScore(Emotion emotion, EmotionsType type)
        {
            switch (type)
            {
            default:
            case EmotionsType.Happiness:
                return(emotion.Scores.Happiness);

            case EmotionsType.Fear:
                return(emotion.Scores.Fear);

            case EmotionsType.Anger:
                return(emotion.Scores.Anger);

            case EmotionsType.Contempt:
                return(emotion.Scores.Contempt);

            case EmotionsType.Disgust:
                return(emotion.Scores.Disgust);

            case EmotionsType.Neutral:
                return(emotion.Scores.Neutral);

            case EmotionsType.Sadness:
                return(emotion.Scores.Sadness);

            case EmotionsType.Surprise:
                return(emotion.Scores.Surprise);
            }
        }
Esempio n. 5
0
        private Dictionary <EmotionsType, double> CreateData(ProfileInfo info)
        {
            Dictionary <EmotionsType, double> emotionLikeWeight
                = new Dictionary <EmotionsType, double>();
            List <EmoInfo> emoInfo = info.EmotionsInformation;

            for (int i = 0; i < emoInfo.Count; i++)
            {
                for (int j = 0; j < Enum.GetValues(typeof(EmotionsType)).Length; j++)
                {
                    var faces = emoInfo[i].Emotions;
                    for (int k = 0; k < faces.Count; k++)
                    {
                        EmotionsType emoType = (EmotionsType)j;
                        if (!emotionLikeWeight.ContainsKey(emoType))
                        {
                            emotionLikeWeight.Add(emoType, 0);
                        }
                        emotionLikeWeight[emoType] =
                            EmoUtils.GetEmoScore(faces[k], emoType) * emoInfo[i].LikesCount;
                    }
                }
            }
            return(emotionLikeWeight);
        }
Esempio n. 6
0
 //Returns weight of emotion in profile (sum = 1)
 public double GetEmotionWeight(EmotionsType type)
 {
     return(_EmotionsWeights[type]);
 }