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); }
private Dictionary <EmotionsType, double> CalculateEmotionsWeights() { Dictionary <EmotionsType, double> weights = new Dictionary <EmotionsType, double>(); //Calculate weights foreach (EmotionsType emoType in Enum.GetValues(typeof(EmotionsType))) { weights[emoType] = 0; for (int i = 0; i < _EmotionsInformation.Count; i++) { var emotions = _EmotionsInformation[i].Emotions; for (int j = 0; j < emotions.Count; j++) { weights[emoType] += EmoUtils.GetEmoScore(emotions[j], emoType) * 1000; } } } //Calculate sum double sum = 0; var keys = weights.Keys; foreach (var key in keys) { sum += weights[key]; } //Normalize weight foreach (var key in keys.ToList()) { double val = weights[key]; weights[key] = val / sum; } return(weights); }