Пример #1
0
 private void addImagesFromFiles_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         ISession     session = ImageDatabase.GetCurrentSession();
         ITransaction tx      = session.BeginTransaction();
         foreach (String file in openFileDialog1.FileNames)
         {
             try
             {
                 FileInfo fi = new FileInfo(file);
                 if (fi.Exists)
                 {
                     using (Image <Bgr, Byte> image = new Image <Bgr, byte>(file))
                     {
                         PersistentImage pImage = new PersistentImage(image.Width, image.Height);
                         CvInvoke.cvCopy(image, pImage, IntPtr.Zero);
                         pImage.DateCreated = fi.CreationTime;
                         session.Save(pImage);
                     }
                 }
             }
             catch
             {
             }
         }
         tx.Commit();
         session.Close();
     }
     RefreshGrid();
 }
Пример #2
0
        public void AddImagesToDatabase(int count)
        {
            ISession     session = ImageDatabase.GetCurrentSession();
            ITransaction tx      = session.BeginTransaction();

            long tick = DateTime.Now.Ticks;

            for (int i = 0; i < count; i++, tick++)
            {
                PersistentImage image = new PersistentImage(400, 200);
                image.SetRandUniform(new MCvScalar(), new MCvScalar(50, 50, 50));

                image.Draw(tick.ToString(), new Point(10, 100), FontFace.HersheySimplex, 1.0, new Bgr(Color.White));

                image.SerializationCompressionRatio = 9;
                session.Save(image);
            }

            tx.Commit();
            session.Close();
        }
Пример #3
0
        public void AddImagesToDatabase(int count)
        {
            ISession     session = ImageDatabase.GetCurrentSession();
            ITransaction tx      = session.BeginTransaction();

            MCvFont f    = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0);
            long    tick = DateTime.Now.Ticks;

            for (int i = 0; i < count; i++, tick++)
            {
                PersistentImage image = new PersistentImage(400, 200);
                image.SetRandUniform(new MCvScalar(), new MCvScalar(50, 50, 50));

                image.Draw(tick.ToString(), ref f, new Point(10, 100), new Bgr(Color.White));

                image.SerializationCompressionRatio = 9;
                session.Save(image);
            }

            tx.Commit();
            session.Close();
        }