示例#1
0
        public void Test()
        {
            var provider = new Db4oProvider("faces.db4o");

            Func<Frame, string> f1 = f => f.Guid.ToString() + ".jpg";
            Func<Portrait, string> f2 = p => p.Guid.ToString() + ".jpg";

            var repository = new Damany.PortraitCapturer.DAL.Providers.LocalDb4oProvider(
                                    @".\");

            var frame = new Frame(Data.GetFrame());
            var mockCamera = new Damany.Cameras.DirectoryFilesCamera(@"c:\", "*.jpg");
            mockCamera.Id = 3;
            frame.CapturedFrom = mockCamera;

            repository.SaveFrame(frame);

            var fromDb = repository.GetFrame(frame.Guid);

            Assert.AreEqual(fromDb.Guid, frame.Guid);

            var portrait = new Portrait(Data.GetPortrait());
            portrait.FaceBounds = new OpenCvSharp.CvRect(0, 0, 100, 100);
            portrait.CapturedFrom = mockCamera;

            repository.SavePortrait(portrait);

            var portraitFromDb = repository.GetPortrait(portrait.Guid);
            Assert.AreEqual(portraitFromDb.Guid, portrait.Guid);
        }
        private static Damany.PortraitCapturer.DAL.IDataProvider InitializeDatabase()
        {
            System.IO.Directory.CreateDirectory(root_dir);
            System.IO.Directory.CreateDirectory(image_dir);

            var storePath = System.IO.Path.Combine(root_dir, "images.db4o");

            storageProvider = new Damany.PortraitCapturer.DAL.Providers.Db4oProvider(storePath);
            storageProvider.StartServer();

            return(storageProvider);
        }
 void Stop()
 {
     if (storageProvider != null)
     {
         Damany.PortraitCapturer.DAL.Providers.Db4oProvider db4o
             = storageProvider as Damany.PortraitCapturer.DAL.Providers.Db4oProvider;
         if (db4o != null)
         {
             db4o.StopServer();
         }
     }
 }
        private static Damany.PortraitCapturer.DAL.IDataProvider InitializeDatabase()
        {
            System.IO.Directory.CreateDirectory(root_dir);
            System.IO.Directory.CreateDirectory(image_dir);

            var storePath = System.IO.Path.Combine(root_dir, "images.db4o");
            storageProvider = new Damany.PortraitCapturer.DAL.Providers.Db4oProvider(storePath);
            storageProvider.StartServer();

            return storageProvider;
        }