private async Task <Boolean> DetectFaceAndRegister(string personGroupId, Microsoft.ProjectOxford.Face.Contract.CreatePersonResult personResult) { Boolean done; /* * var filePicker = new FileOpenPicker(); * filePicker.ViewMode = PickerViewMode.Thumbnail; * filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; * filePicker.FileTypeFilter.Add(".jpg"); * filePicker.FileTypeFilter.Add(".jpeg"); * filePicker.FileTypeFilter.Add(".png"); * var file = await filePicker.PickSingleFileAsync(); * if (file == null || !file.IsAvailable) return false; */ // This is where we want to save to. var storageFolder = KnownFolders.SavedPictures; // Create the file that we're going to save the photo to. var file = await storageFolder.CreateFileAsync("contact.jpg", CreationCollisionOption.ReplaceExisting); // Update the file with the contents of the photograph. await _mediaCapture.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreateJpeg(), file); using (var s = await file.OpenStreamForReadAsync()) { await faceServiceClient.AddPersonFaceAsync(personGroupId, personResult.PersonId, s); } done = true; return(done); }
private async Task AddFaceToPerson(string personGroupId, Microsoft.ProjectOxford.Face.Contract.CreatePersonResult person, string friendImageDir) { foreach (string imagePath in Directory.GetFiles(friendImageDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { // Detect faces in the image and add to Anna await faceClient.AddPersonFaceAsync(personGroupId, person.PersonId, s); //await faceClient.PersonGroupPerson.AddFaceFromStreamAsync( // personGroupId, ana.PersonId, s); } } }
public async Task <Boolean> AddPersonToGroup(string personGroupId, string personName) { Boolean added = false; try { await faceServiceClient.GetPersonGroupAsync(personGroupId); Microsoft.ProjectOxford.Face.Contract.CreatePersonResult personResult = await faceServiceClient.CreatePersonAsync(personGroupId, personName); Boolean detect = await DetectFaceAndRegister(personGroupId, personResult); added = true; } catch (Exception ex) { } return(added); }