public static async Task DeletePersonAsync(string strPersonGroupId, Guid uidPersonId) { try { await fsClient.DeletePersonAsync(strPersonGroupId, uidPersonId); } catch (Exception e) { //Add Handling here. not really needed unless you need to ensure deletion. maybe someday I'll add some :) //throw; return; } }
/// <summary> Function which submits a frame to the Face API. </summary> /// <param name="frame"> The video frame to submit. </param> /// <returns> A <see cref="Task{LiveCameraResult}"/> representing the asynchronous API call, /// and containing the faces returned by the API. </returns> public async Task UploadFaces() { _faceClient = new FaceAPI.FaceServiceClient(Properties.Settings.Default.FaceAPIKey, Properties.Settings.Default.FaceAPIHost); var groups = await _faceClient.ListPersonGroupsAsync(); var exists = false; foreach (var group in groups) { if (group.PersonGroupId.Equals(_groupId)) { exists = true; break; } } if (exists) { var persons = await _faceClient.ListPersonsAsync(_groupId); foreach (var person in persons) { await _faceClient.DeletePersonAsync(_groupId, person.PersonId); } } else { await _faceClient.CreatePersonGroupAsync(_groupId, "AtosEmployees"); } var iterator = 0; foreach (string dir in Directory.GetDirectories("C:\\Temp\\Pics")) { var folderName = dir.Split('\\')[3]; CreatePersonResult person = await _faceClient.CreatePersonAsync(_groupId, "Person " + iterator ++ + " " + folderName); foreach (string imagePath in Directory.GetFiles(dir)) { using (Stream s = File.OpenRead(imagePath)) { try { //await Task.Delay(5000); Properties.Settings.Default.UploadStatus = String.Format("Uploading {0}: {1}", iterator, imagePath); await _faceClient.AddPersonFaceAsync(_groupId, person.PersonId, s); } catch (FaceAPIException fae) { var finishedAt = ""; } //await Task.Delay(5000); } } } }