/// <summary> /// Checks the people in database. /// </summary> private void CheckPeopleInDatabase() { foreach (var person in SelectedGroup.GroupPersons) { var dbPerson = _db.GetPerson(person.Person.PersonId); if (dbPerson == null) { _db.AddPerson(person.Person.PersonId, person.Person.Name, person.Person.UserData); } } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void btnSave_Click(object sender, RoutedEventArgs e) { var file = new PictureFile { DateAdded = DateTime.Now, FilePath = _selectedFilePath, IsConfirmed = true }; db.AddFile(file, _scanGroup.Group.LargePersonGroupId); for (var ix = 0; ix < DetectedFaces.Count; ix++) { var face = DetectedFaces[ix]; var person = new PicturePerson { DateAdded = DateTime.Now, PersonId = face.PersonId, PictureFileId = file.Id, LargePersonGroupId = _scanGroup.Group.LargePersonGroupId, FaceJSON = Newtonsoft.Json.JsonConvert.SerializeObject(face), IsConfirmed = true }; db.AddPerson(person); if (face.AddToGroup) { var contentControl = face.ContextBinder.Parent as ContentControl; var parentGrid = contentControl.Parent as Grid; var croppedImage = parentGrid.Children[1] as Image; var filePath = face.ImageFile.ToString().Replace("file:///", ""); filePath = filePath.Replace('\\', '/'); var fileName = $"DbId-{person.Id}_" + System.IO.Path.GetFileName(filePath); // unique file name, into training folder var newFilePath = System.IO.Path.Combine(face.PersonSourcePath, fileName); CropToSquare(filePath, newFilePath, face.Left, face.Top, face.Width, face.Height); await AddFaceToLargePersonGroup(_scanGroup.Group.LargePersonGroupId, newFilePath, face.PersonId); } } GetNextFile(); }