Ejemplo n.º 1
0
        private async void Button_OpenFile(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker
            {
                ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            StorageFile photo = await picker.PickSingleFileAsync();

            if (photo != null)
            {
                var api     = new AzureFaceApi();
                var emotion = await api.UploadFaceAndGetEmotions(photo);

                if (emotion != null)
                {
                    EmotionModel = new EmotionModel(emotion, photo.Path);
                }
            }
        }
Ejemplo n.º 2
0
        private async void Button_OpenCamera(object sender, RoutedEventArgs e)
        {
            var capture = new CameraCaptureUI();

            capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
            capture.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);

            StorageFile photo = await capture.CaptureFileAsync(CameraCaptureUIMode.Photo);

            if (photo != null)
            {
                var     api     = new AzureFaceApi();
                Emotion emotion = await api.UploadFaceAndGetEmotions(photo);

                if (emotion != null)
                {
                    var emo = new EmotionModel(emotion, photo.Path);
                    EmotionModel = emo;
                    CameraView.AddEmotionModelToView(EmotionModel);
                }
            }
        }