async void OnIdentifyUser(object sender, RoutedEventArgs e) { await this.cameraDisplay.TakePhotoAsync(); // We ask Oxford to detect, it will store the face for 24 hours and // will give us an Id to use. var detectedFaceId = await this.DetectFirstFaceInCapturedPhotoAsync(); if (detectedFaceId != Guid.Empty) { var personGroupId = await this.CreateOrGetPersonGroupAsync("MyPeople"); var results = await this.faceClient.IdentifyAsync( personGroupId, new Guid[] { detectedFaceId }, 1); // only 1 candidate being asked for if ((results == null) || (results.First().Candidates.Length == 0)) { await this.MessageDialog("no results", "that didn't work - got zero results"); } else { var candidate = results.First().Candidates[0]; var name = await AccountMap.GetNameForGuidAsync(candidate.PersonId); this.cameraDisplay.ShowLegend($"We think this is {name}"); await Task.Delay(TimeSpan.FromSeconds(5)); } this.cameraDisplay.ResetVisuals(); } }
async void OnSubmitFaceForUser(object sender, RoutedEventArgs e) { await this.cameraDisplay.TakePhotoAsync(); // We can have many groups of up to 1000 members but we just hard-code // a single group called 'MyPeople'. var personGroupId = await this.CreateOrGetPersonGroupAsync( "MyPeople"); // We then go to grab an id for a person with the right name in that // group. var personName = this.txtPersonName.Text; var personId = await this.CreateOrGetPersonAsync( personGroupId, personName); await AccountMap.SetNameForGuidAsync(personId, personName); // We then register this face as belonging to that person in that // group. var result = await this.faceClient.AddPersonFaceAsync( personGroupId.ToString(), personId, this.cameraDisplay.CapturedPhotoStream.AsStreamForRead()); this.cameraDisplay.ResetVisuals(); }