private async void CreateGroupAsync() { GroupIdentityObject groupId = new GroupIdentityObject(); if (groupId.SetGroupName(TxtGroupName.Text)) { try { _(String.Format("Attempting to create group: {0} with ID {1}", groupId.GroupName, groupId.GroupId)); await faceServiceClient.CreatePersonGroupAsync(groupId.GroupId, groupId.GroupName); GroupModel group = new GroupModel(); group.groupId = groupId.GroupId; group.name = groupId.GroupName; using (var db = dbFactory.Open()) { db.Insert(group); } DataTable result = LoadGroupsData(); GridGroupModel.ItemsSource = result.DefaultView; _("Done."); }catch (FaceAPIException e) { _(e.Message); } } else { MessageBox.Show("Name can't be blank!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
// Create a new PersonGroup in which new users will be added public async void createNewGroup(String groupId, String groupName) { await faceServiceClient.DeletePersonGroupAsync(groupId); await faceServiceClient.CreatePersonGroupAsync(groupId, groupName); }
/// <summary> /// Create a new PersonGroup, then proceed to send pictures of each listed user, uploading them from given directory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnCreateGroup_Click(object sender, EventArgs e) { try { _groupId = txtGroupName.Text.ToLower().Replace(" ", ""); try { await faceServiceClient.DeletePersonGroupAsync(_groupId); } catch { } await faceServiceClient.CreatePersonGroupAsync(_groupId, txtGroupName.Text); foreach (var u in listUsers.Items) { CreatePersonResult person = await faceServiceClient.CreatePersonAsync(_groupId, u.ToString()); foreach (string imagePath in Directory.GetFiles(txtImageFolder.Text + "\\" + u.ToString())) { using (Stream s = File.OpenRead(imagePath)) { await faceServiceClient.AddPersonFaceAsync(_groupId, person.PersonId, s); } } await Task.Delay(1000); } MessageBox.Show("Group successfully created"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private async Task <string> CreatePersonGroup(string personGroupId, string personGroupName) { await faceServiceClient.CreatePersonGroupAsync(personGroupId, personGroupName).ConfigureAwait(false); var personGroup = await faceServiceClient.GetPersonGroupAsync(personGroupId).ConfigureAwait(false); return(personGroup.Name); }
public async Task LoadData() { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "Speakers"); await TrainFacialRecognizitionAsync(personGroupId, "Darrell", Server.MapPath("~/Images/Darrell/")); await TrainFacialRecognizitionAsync(personGroupId, "Ben", Server.MapPath("~/Images/Ben/")); await TrainFacialRecognizitionAsync(personGroupId, "Ciro", Server.MapPath("~/Images/Ciro/")); await TrainFacialRecognizitionAsync(personGroupId, "Eugene", Server.MapPath("~/Images/Eugene/")); }
private async Task CreatePersonGroup(string groupName, string groupId) { var group = await fsClient.GetPersonGroupAsync(groupId); if (group == null) { await fsClient.CreatePersonGroupAsync(groupId, groupName); } }
private async void SetupPersonGroup() { const string lilianImageDir = @"Assets\PersonGroup\Lilian\"; try { //if (faceServiceClient.) <-- need to check if it exists first await faceServiceClient.CreatePersonGroupAsync(personGroup, personGroup); } catch (Exception ex) { Debug.WriteLine(ex.Message); return; } // Define Users CreatePersonResult lilian = await faceServiceClient.CreatePersonAsync( personGroup, "Lilian" ); foreach (string imagePath in Directory.GetFiles(lilianImageDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { // Detect faces in the image and add to Lilian await faceServiceClient.AddPersonFaceAsync( personGroup, lilian.PersonId, s); } } //Train model try { await faceServiceClient.TrainPersonGroupAsync(personGroup); } catch (Exception ex) { Debug.WriteLine(ex.Message); } TrainingStatus trainingStatus = null; while (true) { trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroup); if (trainingStatus.Status.ToString() != "running") { break; } await Task.Delay(1000); } }
public async Task CreateGroupAsync() { var groups = await faceClient.ListPersonGroupsAsync(); if (groups.Any(e => e.PersonGroupId == PERSON_GROUP_ID)) { await faceClient.DeletePersonGroupAsync(PERSON_GROUP_ID); } await faceClient.CreatePersonGroupAsync(PERSON_GROUP_ID, "My Friends"); }
private async Task <PersonGroup> GetPersonGroupOrCreateAsync(string groupId) { var groups = await _client.ListPersonGroupsAsync(); if (groups.Any(x => x.PersonGroupId == groupId)) { return(groups.Single(x => x.PersonGroupId == groupId)); } await _client.CreatePersonGroupAsync(groupId, groupId); return(await GetPersonGroupAsync(groupId)); }
private async void GenerateFaceGroupID() { try { //Generate New Owner Face Group string groupID = Guid.NewGuid().ToString(); await faceServiceClient.CreatePersonGroupAsync(groupID, "HorusSecurity"); faceGroupID = groupID; } catch (Exception) { } }
private async void createPersonGroup() { try { await faceServiceClient.CreatePersonGroupAsync(this.personGroupId, personGroupName); } catch (FaceAPIException f) { if (f.ErrorCode != "PersonGroupExists") { MessageBox.Show(f.ErrorCode, f.ErrorMessage); return; } } }
private async Task CreatePersonGroup() { try { await _faceServiceClient.CreatePersonGroupAsync(personGroupId, "My Friends"); Console.WriteLine("Response: Success. Group \"{0}\" created", "My Friends"); } catch (FaceAPIException ex) { Console.WriteLine("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } Console.WriteLine("CreatePersonGroupAsync"); }
public async void CreatePersons() { // Create an empty PersonGroup string personGroupId = "myfriends"; //await faceClient.PersonGroup.CreateAsync(personGroupId, "My Friends"); await faceClient.CreatePersonGroupAsync(personGroupId, "My Friends"); //await faceClient.DeletePersonGroupAsync(personGroupId); // Define Anna var dad = await faceClient.CreatePersonAsync(personGroupId, "Dad"); var mom = await faceClient.CreatePersonAsync(personGroupId, "mom"); var girl = await faceClient.CreatePersonAsync(personGroupId, "girl"); //CreatePersonResult friend1 = await faceClient.PersonGroupPerson.CreateAsync( // // Id of the PersonGroup that the person belonged to // personGroupId, // // Name of the person // "Anna" //); // Define Bill and Clare in the same way // Directory contains image files of Anna string dadDir = $@"{urlBaseData}\PersonGroup\Family1-Dad"; string momDir = $@"{urlBaseData}\PersonGroup\Family1-Mom"; string girlDad = $@"{urlBaseData}\PersonGroup\Family1-Daughter"; await AddFaceToPerson(personGroupId, dad, dadDir); await AddFaceToPerson(personGroupId, mom, momDir); await AddFaceToPerson(personGroupId, girl, girlDad); await faceClient.TrainPersonGroupAsync(personGroupId); await WaitForTrainedPersonGroup(personGroupId); string familyPerson = $@"{urlBaseData}\identification1.jpg"; await IdentifyPersons(personGroupId, familyPerson); // Do the same for Bill and Clare }
public async void TestMethodAsync() { try { await faceServiceClient.CreatePersonGroupAsync(personGroupId, personGroupId); // Define Anna CreatePersonResult friend1 = await faceServiceClient.CreatePersonAsync( // Id of the person group that the person belonged to personGroupId, // Name of the person "Anna Simmons" ); // Directory contains image files of the person string friend1ImageDir = @"D:\Pictures\Anna"; foreach (string imagePath in Directory.GetFiles(friend1ImageDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { // Detect faces in the image and add to Anna await faceServiceClient.AddPersonFaceAsync( personGroupId, friend1.PersonId, s); } } // Do the same for Bill and Clare await faceServiceClient.TrainPersonGroupAsync(personGroupId); TrainingStatus trainingStatus = null; while (true) { trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId); if (!(trainingStatus.Status.Equals("running"))) { break; } await Task.Delay(1000); } } catch (Exception e) { } }
private async void btnCreateGroup_Click(object sender, RoutedEventArgs e) { // Create an empty person group try { await faceServiceClient.CreatePersonGroupAsync(txtPersonGroupID.Text, txtPersonGroupName.Text); } catch (FaceAPIException f) { txtMessage.Text = "Response status: " + f.ErrorMessage; } catch (Exception ex) { txtMessage.Text = ex.Message; } }
private async void BtnLoadToTrainer_Click(object sender, RoutedEventArgs e) { if (groupName == "" || personName == "") { MessageBox.Show("Blank group or person name"); return; } _(String.Format("Creating group {0}...", groupId)); try { await faceServiceClient.CreatePersonGroupAsync(groupId, groupName); } catch (FaceAPIException eCreatePersonGroupAsync) { _(String.Format("{0}", eCreatePersonGroupAsync.ErrorMessage)); } _("Creating person " + personName + "..."); try { CreatePersonResult person = await faceServiceClient.CreatePersonAsync(groupId, personName); foreach (String imagePath in imagePaths) { using (Stream s = File.OpenRead(imagePath)) { try { _(String.Format("Processing {0}...", imagePath)); await faceServiceClient.AddPersonFaceAsync(groupId, person.PersonId, s); } catch (FaceAPIException eAddPersonFaceAsync) { _(eAddPersonFaceAsync.ErrorMessage); } } } _("Done."); } catch (FaceAPIException eCreatePerson) { _(eCreatePerson.ErrorMessage); } }
public async void AddPresons(string friend1ImageDi) { try { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "Athmane"); // Define Anna CreatePersonResult friend1 = await faceServiceClient.CreatePersonAsync( // Id of the person group that the person belonged to personGroupId, // Name of the person "Makour" ); const string friend1ImageDir = @"C:\Users\Athmane\Pictures\moi";//@"C:\Users\Athmane\Pictures\test";//"C:\Users\Athmane\Downloads\Cognitive-Face-Windows-master\Cognitive-Face-Windows-master\Data\PersonGroup\Family1-Mom"; foreach (string imagePath in Directory.GetFiles(friend1ImageDir, "*.JPEG")) { using (Stream s = File.OpenRead(imagePath)) { // Detect faces in the image and add to Anna await faceServiceClient.AddPersonFaceAsync( personGroupId, friend1.PersonId, s); } } await faceServiceClient.TrainPersonGroupAsync(personGroupId); TrainingStatus trainingStatus = null; while (true) { trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId); if (trainingStatus.Status != Status.Running) { break; } await Task.Delay(1000); } } catch (Exception ec) { return; } }
/// <summary> /// 초기화 /// </summary> public async void Init() { if (_init) { return; } //사람그룹 목록을 조회한 후에 var list = await faceServiceClient.ListPersonGroupsAsync(); //myFriends란 아이디를 가지고 있지 않다면, 사람그룹을 생성한다. if (list.All(p => p.PersonGroupId != _personGroupId)) { await faceServiceClient.CreatePersonGroupAsync(_personGroupId, "My Friends"); } _init = true; }
public async Task <bool> CreateGroupAsync() { try { var groups = await faceClient.ListPersonGroupsAsync(); if (groups.Any(e => e.PersonGroupId == Constants.PERSON_GROUP_ID)) { await faceClient.DeletePersonGroupAsync(Constants.PERSON_GROUP_ID); } await faceClient.CreatePersonGroupAsync(Constants.PERSON_GROUP_ID, Constants.PERSON_GROUP_ID); return(true); } catch (Exception ex) { return(false); } }
private async Task ensurePersonGroup(string id, string name) { try { PersonGroup grp = await faceServiceClient.GetPersonGroupAsync(id); } catch (FaceAPIException ex) { if (HttpStatusCode.NotFound == ex.HttpStatus) { await WaitCallLimitPerSecondAsync(); await faceServiceClient.CreatePersonGroupAsync(id, name); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task <PersonGroup> EnsurePersonGroupExits(IList <PersonGroup> personGroups) { var newGroupId = Guid.NewGuid(); var foundGroup = personGroups.Where(x => x.Name == GroupData.HeroVillanGroupName).FirstOrDefault(); if (personGroups.Count() == 0 || foundGroup == null) { //create new PersonGroup await faceServiceClient.CreatePersonGroupAsync(newGroupId.ToString(), GroupData.HeroVillanGroupName); foundGroup = new PersonGroup { Name = GroupData.HeroVillanGroupName, PersonGroupId = newGroupId.ToString() }; personGroups.Add(foundGroup); } return(foundGroup); }
private async void addPersonGroupButton_Click(object sender, EventArgs e) { if (personGroupSelector.Text.Length != 0) { if (personGroupSelector.Text.Length > 0) { #if USE_OPENCV if (!Directory.Exists("Data/" + personGroupSelector.Text)) { Directory.CreateDirectory("Data/" + personGroupSelector.Text); } #else await faceServiceClient.CreatePersonGroupAsync(personGroupSelector.Text.ToLower(), personGroupSelector.Text); #endif personGroups = await GetPersonGroups(); personSelector.SelectedIndex = -1; if (personGroupSelector.Items.Count > 0) { personGroupSelector.Text = personGroupSelector.Items[0].ToString(); } else { personGroupSelector.Text = ""; } personGroupSelector.Items.Clear(); foreach (PersonGroup personGroup in personGroups) { personGroupSelector.Items.Add(personGroup.Name); } personSelector.Enabled = true; persons = null; personSelector.Items.Clear(); } } addPersonGroupButton.Enabled = false; }
private async void btnTrain_ClickAsync(object sender, EventArgs e) { bool GroupExist; try { // Create an empty PersonGroup await faceServiceClient.GetPersonGroupAsync(personGroupId); GroupExist = true; } catch (Exception ex) { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "my group"); } lblState.Text = "please wait it's in training phase ...."; for (int index = 0; index < listBox1.Items.Count; index++) { string p = new DirectoryInfo(listBox1.Items[index].ToString()).Name; await RegisterNameAsync(p, listBox1.Items[index].ToString(), personGroupId); } await TrainAsync(personGroupId); }
/// <summary> /// Tab2 Create a person group in section 'Define Person Group' /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void DefinePersonGroupButton_Click(object sender, RoutedEventArgs e) { bool flag1 = string.IsNullOrWhiteSpace(Tab2PersonGroupIdTextBox.Text); bool flag2 = string.IsNullOrWhiteSpace(Tab2PersonGroupNameTextBox.Text); if (flag1) { MessageBox.Show("Please input the person group id"); Tab2PersonGroupIdTextBox.Focus(); } if (flag2) { MessageBox.Show("Please input the person group name"); Tab2PersonGroupNameTextBox.Focus(); } if (!flag1 && !flag2) { string personGroupId = Tab2PersonGroupIdTextBox.Text; string personGroupName = Tab2PersonGroupNameTextBox.Text; await faceServiceClient.CreatePersonGroupAsync(personGroupId, personGroupName); MessageBox.Show("Succeed define person group"); } }
public async Task <bool> CreateWhitelistFromFolderAsync(string whitelistId, StorageFolder whitelistFolder = null, IProgress <int> progress = null) { bool isSuccess = true; double progressCnt = 0; WhitelistId = whitelistId; _whitelist = new FaceApiWhitelist(WhitelistId); try { // whitelist folder default to picture library if (whitelistFolder == null) { whitelistFolder = await KnownFolders.PicturesLibrary.GetFolderAsync("WhiteList"); } _whitelistFolder = whitelistFolder; // detele person group if already exists try { // An exception throwed if the person group doesn't exist await _faceApiClient.GetPersonGroupAsync(whitelistId); UpdateProgress(progress, ++progressCnt); await _faceApiClient.DeletePersonGroupAsync(whitelistId); UpdateProgress(progress, ++progressCnt); Debug.WriteLine("Deleted old group"); } catch (FaceAPIException fe) { if (fe.ErrorCode == "PersonGroupNotFound") { Debug.WriteLine("The person group doesn't exist"); } else { throw fe; } } await _faceApiClient.CreatePersonGroupAsync(WhitelistId, "White List"); UpdateProgress(progress, ++progressCnt); await BuildWhiteListAsync(progress, progressCnt); } catch (FaceAPIException fe) { isSuccess = false; Debug.WriteLine("FaceAPIException in CreateWhitelistFromFolderAsync : " + fe.ErrorMessage); } catch (Exception e) { isSuccess = false; Debug.WriteLine("Exception in CreateWhitelistFromFolderAsync : " + e.Message); } // progress to 100% UpdateProgress(progress, 100); return(isSuccess); }
////통신 //public static void sendImage() //{ // //클라이언트 소켓 생성 // Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // System.Diagnostics.Debug.WriteLine("소켓생성성공"); // //서버와 연결 // String IP = "192.168.24.233"; // mySocket.Connect(IP, 11111); // System.Diagnostics.Debug.WriteLine("소켓생성성공"); // //파일의 엶 // String name = webCam.GetImageName(); // System.Diagnostics.Debug.WriteLine("파일열기성공"); // FileStream fileStr = new FileStream(name, FileMode.Open, FileAccess.Read); // //파일 크기를 가져옴 // int fileLength = (int)fileStr.Length; // System.Diagnostics.Debug.WriteLine("파일크기 가져오기 성공"); // //파일크기를 서버에 전송하기 위해 바이트 배열로 변환 // byte[] buffer = BitConverter.GetBytes(fileLength); // System.Diagnostics.Debug.WriteLine("변환성공"); // //파일을 보낼 횟수 // int count = fileLength / 1024 + 1; // //파일을 읽기 위해 BinaryRead 객체 생성 // BinaryReader reader = new BinaryReader(fileStr); // System.Diagnostics.Debug.WriteLine("객체 생성성공"); // //파일송신작업 // for(int i=0; i < count; i++) // { // //파일을 읽음 // buffer = reader.ReadBytes(1024); // //읽은 파일을 서버로 전송 // mySocket.Send(buffer); // } // System.Diagnostics.Debug.WriteLine("서버전송성공"); // //종료작업 // reader.Close(); // mySocket.Close(); //} //Define people for the person group and detect,add person private async Task CreatePersonGroup() { System.Diagnostics.Debug.WriteLine("그룹만들기 시작"); //Call the Face API. try { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "Approved_People"); System.Diagnostics.Debug.WriteLine("그룹만들기"); // Define Bill CreatePersonResult friend1 = await faceServiceClient.CreatePersonAsync( //Id of the person group that the person belonged to personGroupId, // Name of the person "Bill"); System.Diagnostics.Debug.WriteLine("Bill 추가"); //Define Clare CreatePersonResult friend2 = await faceServiceClient.CreatePersonAsync( //Id of the person group that the person belonged to personGroupId, //Name of the person "Clare"); System.Diagnostics.Debug.WriteLine("Clare 추가"); //Define 연경 CreatePersonResult friend3 = await faceServiceClient.CreatePersonAsync( //id of the person group that the person belonged to personGroupId, //name of the person "YeonKyeong"); System.Diagnostics.Debug.WriteLine("연경 추가"); foreach (string imagePath in Directory.GetFiles(friend1ImagerDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { await faceServiceClient.AddPersonFaceAsync( personGroupId, friend1.PersonId, s); } System.Diagnostics.Debug.WriteLine("Bill에 얼굴추가"); }//Bill foreach (string imagePath in Directory.GetFiles(friend2ImagerDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { await faceServiceClient.AddPersonFaceAsync( personGroupId, friend2.PersonId, s); } System.Diagnostics.Debug.WriteLine("Clare에 얼굴추가"); }//Clare foreach (string imagePath in Directory.GetFiles(friend3ImagerDir, "*.jpg")) { using (Stream s = File.OpenRead(imagePath)) { await faceServiceClient.AddPersonFaceAsync( personGroupId, friend3.PersonId, s); } System.Diagnostics.Debug.WriteLine("연경에 얼굴추가"); }//연경 } //Catch and display Face API errors. catch (FaceAPIException f) { MessageBox.Show(f.ErrorMessage, f.ErrorCode); System.Diagnostics.Debug.WriteLine("그룹만들기 FaceAPIException=" + f); } //Catch and display all other errors. catch (Exception e) { MessageBox.Show(e.Message, "Error"); System.Diagnostics.Debug.WriteLine("그룹만들기 오류 Exception=" + e); } }
/// <summary> /// Create a new person group /// </summary> public async void create() { await faceServiceClient.CreatePersonGroupAsync(szPersonGroupID, "Face Api"); Debug.WriteLine("Person group created: " + szPersonGroupID); }
private async void button1_Click(object sender, RoutedEventArgs e) { personGroupId = "1"; try { await faceServiceClient.DeletePersonGroupAsync(personGroupId); } catch (Microsoft.ProjectOxford.Face.FaceAPIException exc) { Debug.WriteLine(exc.ErrorCode); } try { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "PG"); } catch (Microsoft.ProjectOxford.Face.FaceAPIException exc) { Debug.WriteLine(exc.ErrorCode); } String[] listOfPersons = { "person1" }; CreatePersonResult[] person = new CreatePersonResult[listOfPersons.Length]; string[] personImageDir = new string[listOfPersons.Length]; for (int i = 0; i < listOfPersons.Length; i++) { person[i] = await faceServiceClient.CreatePersonAsync(personGroupId, listOfPersons[i]); FolderPicker folderPicker = new FolderPicker(); folderPicker.FileTypeFilter.Add(".jpg"); folderPicker.FileTypeFilter.Add(".jpeg"); folderPicker.FileTypeFilter.Add(".png"); folderPicker.FileTypeFilter.Add(".bmp"); folderPicker.ViewMode = PickerViewMode.Thumbnail; StorageFolder photoFolder = await folderPicker.PickSingleFolderAsync(); if (photoFolder == null) { return; } var files = await photoFolder.GetFilesAsync(); foreach (var file in files) { var inputStream = await file.OpenReadAsync(); Stream stream = inputStream.AsStreamForRead(); await faceServiceClient.AddPersonFaceAsync(personGroupId, person[i].PersonId, stream); } } await faceServiceClient.TrainPersonGroupAsync(personGroupId); TrainingStatus trainingStatus = null; while (true) { trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId); if (!trainingStatus.Status.Equals("running")) { break; } await Task.Delay(1000); } }
private async void Create_Click(object sender, RoutedEventArgs e) { await faceServiceClient.CreatePersonGroupAsync(personGroupId, "My Friends"); Console.WriteLine("Group created"); }
private async Task <bool> add_person_async(string person_group_id) { try { // Check if group already exist // If yes => delete PersonGroup[] person_groups = await face_service_client.ListPersonGroupsAsync(); foreach (PersonGroup pg in person_groups) { if (pg.PersonGroupId == person_group_id) { await face_service_client.DeletePersonGroupAsync(person_group_id); } } // Create group await face_service_client.CreatePersonGroupAsync(person_group_id, person_group_id); // Get all directory in "person dir" foreach (string person_name_dir_path in preson.get_all_person_dir()) { // Get only last directory string dir_person_name = person_name_dir_path.Split(Path.DirectorySeparatorChar).Last();//.Replace("_",""); //Create person with current groupe CreatePersonResult cpr = await face_service_client.CreatePersonAsync(person_group_id, dir_person_name); // TODO Add "*.id" file //add_person_id_file(person_name_dir_path, cpr.PersonId.ToString()); // Get all photos foreach (string person_photo in Directory.EnumerateFiles(person_name_dir_path, "*.*", SearchOption.AllDirectories).Where(n => Path.GetExtension(n) != ".id").ToList()) { if (File.Exists(person_photo)) { Debug.WriteLine($"Add person photo: {person_photo}"); //TODO // PROGRESS update_progress("Add person", $"Process person: {dir_person_name.Split('_')[0]}", ++progress); using (Stream stream = File.OpenRead(person_photo)) { // If the person photo containe no face => throw error try { // Detect faces in the image and add to Anna await face_service_client.AddPersonFaceAsync(person_group_id, cpr.PersonId, stream); } catch { Console.WriteLine("Person photo containe no face"); } } } } } // PROGRESS update_progress("Training group", $"Process group: {person_group_id}", progress); // Training person group await face_service_client.TrainPersonGroupAsync(person_group_id); TrainingStatus trainingStatus = null; while (true) { trainingStatus = await face_service_client.GetPersonGroupTrainingStatusAsync(person_group_id); if (trainingStatus.Status.ToString() != "running") { break; } await Task.Delay(1000); } Debug.WriteLine("Training ok"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } return(true); }