Пример #1
0
        public void SaveNewCamera(Camera camera)
        {
            if (camera == null)
            {
                throw new ArgumentException(nameof(camera));
            }

            _context.Cameras.Add(camera);

            _context.SaveChanges();
        }
        public void ProcessScannedImages(User user)
        {
            var directiory = new DirectoryInfo(FileSystemPaths.ScannerOutput + user.Name);
            var files      = directiory.GetFiles("*.png");

            var photos = new List <byte[]>();

            foreach (var photo in files)
            {
                photos.Add(File.ReadAllBytes(FileSystemPaths.ScannerOutput + user.Name + "/" + photo.Name));
            }

            _context.Users.Add(user);

            var userImages = new List <UserFaceImage>();

            foreach (var image in photos)
            {
                var userImage = new UserFaceImage
                {
                    FaceImage = new FaceImage
                    {
                        Face = image
                    },
                    UserId = user.Id
                };

                userImages.Add(userImage);
            }

            _context.UserFaceImages.AddRange(userImages);

            _context.SaveChanges();
        }
Пример #3
0
        public static void SeedDatabase(KataskopeyaContext context)
        {
            if (!context.Users.Any())
            {
                //var directory = new DirectoryInfo(FileSystemPaths.DebugFolder + "photosDataset");
                //var files = directory.GetFiles("*.png");

                //var myFiles = files.Where(x => x.Name.Contains("myPhoto"));

                //var myPhotos = new List<byte[]>();

                //foreach (var photo in myFiles)
                //{
                //    myPhotos.Add(File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + $"photosDataset/{photo.Name}"));
                //}

                var user = new User
                {
                    Name     = "Creator",
                    Password = "******",
                    Age      = 23,
                };

                context.Users.Add(user);

                //foreach (var image in myPhotos)
                //{
                //    var userFaceImage = new UserFaceImage
                //    {
                //        FaceImage = new FaceImage
                //        {
                //            Face = image
                //        },
                //        UserId = user.Id
                //    };

                //    context.UserFaceImages.Add(userFaceImage);
                //}

                context.SaveChanges();
            }
        }