示例#1
0
 private void FaceRecognitionWindow_OnFaceRecognised(Models.Person person, bool continueValidation)
 {
     CurrentUnknownFace.FaceOwner = person;
     Context.SaveChanges();
     if (continueValidation)
     {
         ShowRecognitionWindow(continueValidation);
     }
 }
示例#2
0
        private void ProcessPhoto(GalliumContext ctx, Photo photo)
        {
            Console.WriteLine($"Beginning processing of photo {photo.Name}");
            try
            {
                if (!photo.HasFacesChecked)
                {
                    photo.HasFacesChecked = true;

                    var faces = PhotoHelper.UploadToFaceApiAsync(photo.FullName).Result;

                    foreach (var face in faces)
                    {
                        var faceEntity = new Models.FaceApi.DetectedFace
                        {
                            HumanVerified = false,
                            FaceRectangle = face.FaceRectangle,
                            Photo         = photo,
                            FaceId        = face.FaceId
                        };
                        PhotoHelper.ExtractFaceFromPhoto(photo, faceEntity);
                        faceEntity.FaceFile = DirectoryHelper.GetFacePath(face.FaceId.ToString());
                        ctx.DetectedFaces.Add(faceEntity);
                    }
                    ctx.SaveChanges();
                }
            }
            catch (System.IO.IOException e) { Thread.Sleep(500); }
            catch (Exception e)
            {
                Thread.Sleep(5000);
            }
        }
示例#3
0
        private void ResetPostponedFaces()
        {
            var faces = Context.DetectedFaces.ToList();

            faces.ForEach(f =>
            {
                f.Postponed = false;
            });
            Context.SaveChanges();
        }
示例#4
0
 private void AddPhotosToDB(GalliumContext ctx, IList <Photo> photos)
 {
     foreach (var photo in photos)
     {
         if (!ctx.Photos.Where(p => p.FullName.Equals(photo.FullName)).Any())
         {
             ctx.Photos.Add(photo);
         }
     }
     ctx.SaveChanges();
 }
示例#5
0
        private void Button_AddDir_Click(object sender, RoutedEventArgs e)
        {
            VistaFolderBrowserDialog folder = new VistaFolderBrowserDialog();

            folder.ShowDialog();
            if (!String.IsNullOrEmpty(folder.SelectedPath))
            {
                bool alreadyAdded = ctx.Directories.Any(d => d.Path.Equals(folder.SelectedPath));
                if (!alreadyAdded)
                {
                    var path = new PhotoDirectories()
                    {
                        Path = folder.SelectedPath
                    };
                    ctx.Directories.Add(path);
                    directoriesList.Add(path);
                    ctx.SaveChanges();
                }
                else
                {
                    MessageBox.Show("Ścieżka jest już dodana bądź jest nieprawidłowa.");
                }
            }
        }
示例#6
0
        private async void PersonCreationWindow_OnPersonCreatedHandlerAsync(Person person)
        {
            var FaceClient = new FaceServiceClient(Constants.APIkey, Constants.APIUri);

            var creationResult = await FaceClient.CreatePersonInLargePersonGroupAsync(Constants.MainPersonGroupId, $"{person.Name}_{person.LastName}");

            Guid personId = creationResult.PersonId;

            person.RemoteGuid = personId;

            Context.Person.Add(person);
            Context.SaveChanges();

            UsernameList.ItemsSource = Context.Person.ToList();
        }
示例#7
0
 private void Gallery_Closed(object sender, EventArgs e)
 {
     ctx.SaveChanges();
     ctx.Dispose();
 }