Exemple #1
0
        private async void TakePicture_Click(object sender, RoutedEventArgs e)
        {
            if (currentPerson == null)
            {
                Debug.WriteLine("Creating person in group.");

                var userData = new UserData(App.Settings.Values["userID"].ToString(), App.Settings.Values["Token"].ToString());
                var id       = await FaceApiService.CreatePersonInGroupAsync(personGroupId, viewModel.UserName, userData);

                Debug.WriteLine("Person created with ID: " + id);

                currentPerson = new OxfordPerson()
                {
                    personId = id,
                    name     = viewModel.UserName,
                    userData = JsonConvert.SerializeObject(userData).EncodeBase64()
                };
            }

            var stream = await capturePhotoStreamAsync();

            if (stream != null)
            {
                var image = new BitmapImage();
                await image.SetSourceAsync(stream);

                photo.Source = image;

                var faceId = await FaceApiService.AddPersonFaceAsync(personGroupId, currentPerson.personId, stream);

                Debug.WriteLine($"Face added to person {currentPerson.personId} with ID: {faceId}");

                stream.Dispose();
            }
            else
            {
                viewModel.OxfordStatus = "Unable to capture the photo.";
            }
        }