示例#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);
                }
            }
        }
        public async Task Test_AnalyseFaceFunction_Returns_Valid_Response_That_Is_Not_Null()
        {
            var faceApi              = new AzureFaceApi("");
            var storageApi           = new AzureStorageApi("");
            var function             = new EmojiMatchFunctionAnalyseFace(faceApi, storageApi);
            var faceAnalysisResponse = await function.AnalyseFaceFunction("tom.jpg", _logger);

            Assert.IsNotNull(faceAnalysisResponse);
        }
示例#3
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);
                }
            }
        }