Esempio n. 1
0
        private void timerCaptura_Tick(object sender, EventArgs e)
        {
            if (contador == 1)
            {
                this.Identificador++;

                Bitmap   Imgb = new Bitmap(screens2[comboBoxPantallas.SelectedIndex].WorkingArea.Width, screens2[comboBoxPantallas.SelectedIndex].WorkingArea.Height, PixelFormat.Format32bppArgb);
                Graphics graf = Graphics.FromImage(Imgb);

                graf.CopyFromScreen(screens2[comboBoxPantallas.SelectedIndex].WorkingArea.X, screens2[comboBoxPantallas.SelectedIndex].WorkingArea.Y, 0, 0, screens2[comboBoxPantallas.SelectedIndex].WorkingArea.Size, CopyPixelOperation.SourceCopy);

                pictureBoxImg.Image = Imgb;

                string imagesPath  = ConfigurationManager.AppSettings["images-path"];
                string desktopPath = string.Concat(imagesPath, "\\desktop\\", currentSession.TestName);
                string webcamPath  = string.Concat(imagesPath, "\\webcam\\", currentSession.TestName);
                Directory.CreateDirectory(desktopPath);
                Directory.CreateDirectory(webcamPath);

                long tiempoCaptura = DateTime.UtcNow.Ticks;

                string desktopScreenshot = string.Format(@"{0}\Escritorio-{1}.jpg", desktopPath, tiempoCaptura);
                Imgb.Save(desktopScreenshot, ImageFormat.Bmp);

                string webcamPicture = string.Format(@"{0}\WebCam-{1}.jpg", webcamPath, tiempoCaptura);
                pictureBoxWebCam.Image.Save(webcamPicture, ImageFormat.Png);

                ImagesDao imagesDao = new ImagesDao();
                imagesDao.InsertImages(currentSession.TestName, this.Seccion, this.Identificador, desktopScreenshot, webcamPicture);

                timerCaptura.Stop();
            }
            contador++;
        }
Esempio n. 2
0
        //If bulkLimit is 0, get all images
        private List <FaceImage> GetImages(int section, int bulkLimit)
        {
            List <FaceImage> images = new List <FaceImage>();

            try
            {
                ImagesDao imagesDao = new ImagesDao();
                images = imagesDao.GetImages(section);

                if (images.Count > 0 && bulkLimit > 0)
                {
                    return(images.GetRange(0, bulkLimit));
                }

                return(images);
            } catch (Exception e)
            {
                MessageBox.Show(e.Message);
                throw e;
            }
        }