示例#1
0
        //Populate DetectionInfo with face recognition Attributes
        public DetectionInfo(Image <Bgr, byte> image, ICollection <Rectangle> rectangles, ICollection <Face> faces)
        {
            InitData();
            Image      = image;
            Rectangles = rectangles;
            Faces      = faces;

            if (faces.Any())
            {
                PersonCount = Faces.Count;
                //Gestion des genres
                Genders     = faces.Select(gender => gender.FaceAttributes.Gender).ToList();
                MaleCount   = Genders.Where(g => g == "male").Count();
                FemaleCount = Genders.Where(g => g == "female").Count();
                //Calcul de l'age moyen
                AgeAverage = faces.Select(age => age.FaceAttributes.Age).ToList().Average();
                //Calcul du nombre de sourire
                Smiles     = faces.Select(age => age.FaceAttributes.Smile).ToList();
                SmileCount = Smiles.Where(s => s >= 0.5).Count();
                //Calcul du nombre de "poilus" (moustache ou barbe)
                FacialHair = faces.Select(age => age.FaceAttributes.FacialHair).ToList();
                foreach (var f in FacialHair)
                {
                    if (f.Beard > 0.3 || f.Moustache > 0.3)
                    {
                        HearyCount++;
                    }
                }
                //calcul du nombre de porteur de lunettes de vue et solaire
                Glasses             = faces.Select(g => g.FaceAttributes.Glasses).ToList();
                SunGlassesCount     = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.Sunglasses).Count();
                ReadingGlassesCount = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.ReadingGlasses).Count();
                //Accessoires : non gérés
                Accessories = faces.Select(age => age.FaceAttributes.Accessories).ToList();
                //Ventilation des emotions selon les 4 grandes tendances
                Emotions = faces.Select(age => age.FaceAttributes.Emotion).ToList();
                foreach (var e in Emotions)
                {
                    if (GetEmotion(e) == "Happiness")
                    {
                        EmotionHappyCount++;
                    }
                    if (GetEmotion(e) == "Anger")
                    {
                        EmotionAngerCount++;
                    }
                    if (GetEmotion(e) == "Disgust")
                    {
                        EmotionDisgustCount++;
                    }
                    if (GetEmotion(e) == "Neutral")
                    {
                        EmotionNeutralCount++;
                    }
                }
                //Calcul du ratio de "happy" par rapport au nombre de personnes
                HappyRatio = Math.Round((((double)EmotionHappyCount / (double)faces.Count)) * 100, 2);
            }
        }
示例#2
0
        private void UpdateGlassesCount()
        {
            int availableGlasses = Glasses.Where(x => x.IsEmpty).Count();

            GlasOnShelf.Text = $"Det finns {availableGlasses} lediga glas.";
        }