Esempio n. 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);
            }
        }
        private async Task GetUpcomingMoviesAsync(bool fromPagination = false)
        {
            try
            {
                RunningOperation = true;
                if (fromPagination == false)
                {
                    await GetGenre();
                }
                var response = await APIHelper.GetUpcomingMovies(Page);

                if (response.Error != null)
                {
                    await _dialogService.DisplayAlertAsync("ArcTouch - Movies", response.Error.Message, "Cancel");
                }
                else
                {
                    if (response.Response.results.Count > 0)
                    {
                        HasMorePages = true;
                        foreach (var item in response.Response.results)
                        {
                            item.movieImage = APIHelper.GetMovieImage(item.backdrop_path);
                            if (item.genre_ids.Length > 0 && Genders.Count > 0)
                            {
                                item.genderDescription = Genders.Where(x => x.id == item.genre_ids[0]).Select(x => x.name).FirstOrDefault();
                            }
                            UpcomingMovies.Add(item);
                        }
                    }
                    else
                    {
                        HasMorePages = false;
                    }
                }
                RunningOperation = false;
            }
            catch (Exception ex)
            {
                await _dialogService.DisplayAlertAsync("ArcTouch - Movies", ex.Message, "Cancel");
            }
            finally
            {
                RunningOperation = false;
            }
        }
Esempio n. 3
0
        private async void SendCommandTapped(object obj)
        {
            try
            {
                if (!IsBusy)
                {
                    IsBusy = true;
                    bool result = await _pushService.SendPushNotifications(new PushMessageDto
                    {
                        Ages         = Ages.Where(x => x.Selected).Select(x => x.Value).ToList(),
                        Image        = Image,
                        Genders      = Genders.Where(x => x.Selected).Select(x => x.Value).ToList(),
                        Date         = DateTime.Now,
                        Description  = Message,
                        SelectRandom = Random,
                        Tag          = Tags.Where(x => x.Selected).Select(x => x.Value).ToList(),
                        Title        = $"Notificación enviada por {_userService.GetLastUser().Username}"
                    });

                    if (result)
                    {
                        Clean();
                    }
                    else
                    {
                        await _dialogService.DisplayAlertAsync("Error", "No se pudo enviar la notificación", "Cerrar");
                    }
                }
            }
            catch (Exception e)
            {
                await _dialogService.DisplayAlertAsync("Error", e.Message, "Cerrar");
            }
            finally
            {
                IsBusy = false;
            }
        }
        private Gender GetGender(string description)
        {
            var search = Genders.Where(a => a.GenderReadable.Equals(description));

            return(!search.Count().Equals(1) ? null : search.First());
        }