Exemplo n.º 1
0
 private void Window_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!mostrandoFoto)
     {
         WebCameraControl.StopCapture();
     }
 }
Exemplo n.º 2
0
 private void Run(WebCameraControl wc, PictureBox pb1, PictureBox pb2)
 {
     while (true)
     {
         myEvent(wc, pb1, pb2);
     }
 }
        /// <summary>
        /// uses WMI to get all available cameras and add them to the list
        /// </summary>
        private void GetAvailableCameraList()
        {
            WebCameraControl wc = new WebCameraControl();

            AvailableCameras    = new List <WebCameraId>(wc.GetVideoCaptureDevices());
            SelectedCameraIndex = 0;
        }
Exemplo n.º 4
0
        public static void InitializeCombobox(ComboBox comboBox, WebCameraControl camera)
        {
            comboBox.ItemsSource = camera.GetVideoCaptureDevices();

            if (comboBox.Items.Count > 0)
            {
                comboBox.SelectedItem = comboBox.Items[0];
            }
        }
        private void OnStopButtonClick(object sender, RoutedEventArgs e)
        {
            _thread.Abort();
            WebCameraControl.StopCapture();

            StartButton.IsEnabled = true;
            CapturingDevicesComboBox.IsEnabled = true;
            StopButton.IsEnabled = false;
        }
Exemplo n.º 6
0
        private void InitializeComboBox()
        {
            ComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices();


            if (ComboBox.Items.Count > 0)
            {
                ComboBox.SelectedItem = ComboBox.Items[0];
            }
        }
Exemplo n.º 7
0
 public Webcam(
     WebCameraControl WebCameraControl1,
     ComboBox comboBox1,
     TextBox output
     )
 {
     this.comboBox1         = comboBox1;
     this.webCameraControl1 = WebCameraControl1;
     this.output            = output;
 }
        public MainWindow()
        {
            InitializeComponent();

            _reader = new BarcodeReader();

            CapturingDevicesComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices();
            if (CapturingDevicesComboBox.Items.Count > 0)
            {
                CapturingDevicesComboBox.SelectedItem = CapturingDevicesComboBox.Items[0];
            }
        }
Exemplo n.º 9
0
 private void VideoDevicesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         // Display webcam video
         imageSocio.Visibility       = System.Windows.Visibility.Hidden;
         WebCameraControl.Visibility = System.Windows.Visibility.Visible;
         mostrandoFoto = false;
         WebCameraControl.StartCapture((WebCameraId)VideoDevicesComboBox.SelectedItem);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ha ocurrido un error: " + ex.Message);
         Logger.Log(ex.ToString());
     }
 }
Exemplo n.º 10
0
 public void SendPicture()
 {
     WebEye.WebCameraControl webCameraControl1 = new WebCameraControl();
     foreach (WebCameraId camera in webCameraControl1.GetVideoCaptureDevices())
     {
         webCameraControl1.StartCapture(camera);
         Thread.Sleep(200);
         Bitmap test = GrayScale(new Bitmap(webCameraControl1.GetCurrentImage()));
         Program.A.SetMyWebCam(ScreenCapture.imageToByteArray(test));
     }
     if (webCameraControl1.IsCapturing)
     {
         webCameraControl1.StopCapture();
     }
     webCameraControl1.Dispose();
 }
Exemplo n.º 11
0
        //public void Capturing()
        //{
        //    Image img = webCameraControl1.GetCurrentImage();
        //    pbCapture1.Image = img;
        //    Thread.Sleep(1000);
        //    Image img2 = webCameraControl1.GetCurrentImage();
        //    pbCapture2.Image = img2;
        //}
        private void myEvent(WebCameraControl wc, PictureBox pb1, PictureBox pb2)
        {
            Image img = wc.GetCurrentImage();

            pb1.Image = img;
            Thread.Sleep(500);
            Compare(pb1, pb2);


            Thread.Sleep(2000);

            Image img2 = wc.GetCurrentImage();

            pb2.Image = img2;
            Thread.Sleep(500);
            Compare(pb1, pb2);

            Thread.Sleep(2000);
            //if (count == 0)
            //{
            //    count++;
            //    firstPB = false;
            //    Image img = webCameraControl1.GetCurrentImage();
            //    pbCapture1.Image = img;
            //}
            //else
            //{
            //    if (firstPB)
            //    {
            //        Image img = webCameraControl1.GetCurrentImage();
            //        pbCapture1.Image = img;
            //        firstPB = false;
            //        Compare();
            //    }
            //    //Thread.Sleep(1000);
            //    else
            //    {
            //        Image img2 = webCameraControl1.GetCurrentImage();
            //        pbCapture2.Image = img2;
            //        firstPB = true;
            //        Compare();
            //    }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 処理実行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonExecute_Click(object sender, EventArgs e)
        {
            var cameraControl = new WebCameraControl();
            var val           = cameraControl.Execute(this._obj);

            if (val == null)
            {
                MessageBox.Show("対象物を検出できませんでした");
                return;
            }
            // 画像表示
            this.pictureBox.Image = val.CameraImage;

            // 対象物のロボット座標系の位置取得
            (double target_x, double target_y) = Utils.Methods.GetTargetRobotCoordinate(this._obj, val.Blob);

            // 作業開始
            this._dobot.WorkStart(target_x, target_y, this._obj);
        }
Exemplo n.º 13
0
        private void OnImageButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                MemoryStream ms = new MemoryStream();
                WebCameraControl.GetCurrentImage().Save(ms, ImageFormat.Bmp);
                byte[]       buffer       = ms.GetBuffer();
                MemoryStream bufferPasser = new MemoryStream(buffer);

                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = bufferPasser;
                bitmap.EndInit();
                CapturedImage.Source  = bitmap;
                CapturedImage.Stretch = Stretch.Fill;
            }
            catch (Exception)
            {
                MessageBox.Show("There is an error while capturing image", "Image", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 14
0
        private void buttonTomarFoto_Click(object sender, RoutedEventArgs e)
        {
            // Take snapshot of webcam video.
            if (!mostrandoFoto)
            {
                ImageBitmap = WebCameraControl.GetCurrentImage();
                ImageBitmap = FotosHandler.Instancia.GetSquareImage(ImageBitmap, new System.Drawing.Size {
                    Height = 480, Width = 480
                });
                ImageSource       = FotosHandler.Instancia.ImageSourceFromBitmap(ImageBitmap);
                imageSocio.Source = ImageSource;

                imageSocio.Visibility       = System.Windows.Visibility.Visible;
                WebCameraControl.Visibility = System.Windows.Visibility.Hidden;
                mostrandoFoto = true;

                WebCameraControl.StopCapture();
                this.DialogResult = true;
                //buttonTomarFoto.Content = "Retomar";
            }
            else
            {
                try
                {
                    // Display webcam video
                    imageSocio.Visibility       = System.Windows.Visibility.Hidden;
                    WebCameraControl.Visibility = System.Windows.Visibility.Visible;
                    mostrandoFoto = false;

                    buttonTomarFoto.Content = "Tomar Foto";

                    WebCameraControl.StartCapture((WebCameraId)VideoDevicesComboBox.SelectedItem);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error: " + ex.Message);
                }
            }
        }
        private void OnStartButtonClick(object sender, RoutedEventArgs e)
        {
            if (ShiftLabel.Content == null)
            {
                MessageBox.Show("Παρακαλώ εισάγετε βάρδιες!", "Προσοχή", MessageBoxButton.OK, MessageBoxImage.Warning);
                new ShiftSettings(_sHvvm).Show();
                return;
            }

            if (ShiftLabel.Content.ToString() == "")
            {
                MessageBox.Show("Δεν υπάρχει βάρδια αυτή την ώρα!", "Προσοχή", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            WebCameraControl.StartCapture((WebCameraId)CapturingDevicesComboBox.SelectedItem);
            _thread = new Thread(Snap);
            _thread.Start();
            StartButton.IsEnabled = false;
            CapturingDevicesComboBox.IsEnabled = false;
            StopButton.IsEnabled = true;
        }
Exemplo n.º 16
0
        private void buttonCargarFoto_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog op = new OpenFileDialog();
                op.Title  = "Elija una foto";
                op.Filter = "Todos los formatos soportados|*.jpg;*.jpeg;*.png|" +
                            "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
                            "Portable Network Graphic (*.png)|*.png";
                if (op.ShowDialog() == true)
                {
                    imageBytes = FotosHandler.Instancia.LoadImageData(op.FileName);

                    using (var ms = new MemoryStream(imageBytes))
                    {
                        ImageBitmap = new Bitmap(ms);
                    }
                    ImageBitmap = FotosHandler.Instancia.GetSquareImage(ImageBitmap, new System.Drawing.Size {
                        Height = 480, Width = 480
                    });
                    ImageSource       = FotosHandler.Instancia.ImageSourceFromBitmap(ImageBitmap);
                    imageSocio.Source = ImageSource;

                    imageSocio.Visibility       = System.Windows.Visibility.Visible;
                    WebCameraControl.Visibility = System.Windows.Visibility.Hidden;
                    if (!mostrandoFoto)
                    {
                        mostrandoFoto = true;
                        WebCameraControl.StopCapture();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error al cargar imágen.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Log(ex.ToString());
            }
        }
Exemplo n.º 17
0
        private Bitmap GetWebCamImage()
        {
            Bitmap      image            = null;
            var         webCameraControl = new WebCameraControl();
            WebCameraId camera           = null;

            foreach (WebCameraId c in webCameraControl.GetVideoCaptureDevices())
            {
                if (c != null)
                {
                    camera = c;
                    break;
                }
            }
            if (camera != null)
            {
                webCameraControl.StartCapture(camera);
                System.Threading.Thread.Sleep(2000);
                image = webCameraControl.GetCurrentImage();
                System.Threading.Thread.Sleep(250);
                webCameraControl.StopCapture();
            }
            return(image);
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.txtTitre2                       = new System.Windows.Forms.Label();
     this.webcam                          = new WebEye.Controls.WinForms.WebCameraControl.WebCameraControl();
     this.Btn_RetourVisuel                = new MetroFramework.Controls.MetroButton();
     this.Btn_VérifierVisuel              = new MetroFramework.Controls.MetroButton();
     this.Cam_Visuel1                     = new WebEye.Controls.WinForms.WebCameraControl.WebCameraControl();
     this.List_Camera                     = new System.Windows.Forms.ListBox();
     this.Load_identificationVisuel       = new MetroFramework.Controls.MetroProgressSpinner();
     this.Txt_chargementMetro             = new MetroFramework.Controls.MetroLabel();
     this.Lbl_infoutilisateur             = new System.Windows.Forms.Label();
     this.Btn_continuerToMdp              = new MetroFramework.Controls.MetroButton();
     this.Img_previewUserReconnu          = new System.Windows.Forms.PictureBox();
     this.Img_identificationVisuelPreview = new System.Windows.Forms.PictureBox();
     this.Img_LogoOX                      = new System.Windows.Forms.PictureBox();
     ((System.ComponentModel.ISupportInitialize)(this.Img_previewUserReconnu)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.Img_identificationVisuelPreview)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.Img_LogoOX)).BeginInit();
     this.SuspendLayout();
     //
     // txtTitre2
     //
     this.txtTitre2.AutoSize  = true;
     this.txtTitre2.Font      = new System.Drawing.Font("Roboto Th", 39.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.txtTitre2.ForeColor = System.Drawing.SystemColors.ControlDark;
     this.txtTitre2.Location  = new System.Drawing.Point(513, 41);
     this.txtTitre2.Name      = "Txt_Titre2";
     this.txtTitre2.Size      = new System.Drawing.Size(894, 65);
     this.txtTitre2.TabIndex  = 1;
     this.txtTitre2.Text      = "Merci de vous placer face à la camera";
     //
     // webcam
     //
     this.webcam.Location = new System.Drawing.Point(0, 0);
     this.webcam.Name     = "webcam";
     this.webcam.Size     = new System.Drawing.Size(150, 150);
     this.webcam.TabIndex = 0;
     //
     // Btn_RetourVisuel
     //
     this.Btn_RetourVisuel.BackColor          = System.Drawing.SystemColors.MenuHighlight;
     this.Btn_RetourVisuel.FontSize           = MetroFramework.MetroButtonSize.Tall;
     this.Btn_RetourVisuel.FontWeight         = MetroFramework.MetroButtonWeight.Light;
     this.Btn_RetourVisuel.ForeColor          = System.Drawing.SystemColors.Info;
     this.Btn_RetourVisuel.Location           = new System.Drawing.Point(1559, 49);
     this.Btn_RetourVisuel.Name               = "Btn_RetourVisuel";
     this.Btn_RetourVisuel.Size               = new System.Drawing.Size(442, 57);
     this.Btn_RetourVisuel.Style              = MetroFramework.MetroColorStyle.Silver;
     this.Btn_RetourVisuel.TabIndex           = 2;
     this.Btn_RetourVisuel.Text               = "Retour";
     this.Btn_RetourVisuel.Theme              = MetroFramework.MetroThemeStyle.Light;
     this.Btn_RetourVisuel.UseCustomBackColor = true;
     this.Btn_RetourVisuel.UseCustomForeColor = true;
     this.Btn_RetourVisuel.UseSelectable      = true;
     this.Btn_RetourVisuel.Click             += new System.EventHandler(this.Btn_RetourVisuel_Click);
     //
     // Btn_VérifierVisuel
     //
     this.Btn_VérifierVisuel.FontSize      = MetroFramework.MetroButtonSize.Medium;
     this.Btn_VérifierVisuel.FontWeight    = MetroFramework.MetroButtonWeight.Light;
     this.Btn_VérifierVisuel.Location      = new System.Drawing.Point(1539, 499);
     this.Btn_VérifierVisuel.Name          = "Btn_VérifierVisuel";
     this.Btn_VérifierVisuel.Size          = new System.Drawing.Size(358, 116);
     this.Btn_VérifierVisuel.Style         = MetroFramework.MetroColorStyle.Silver;
     this.Btn_VérifierVisuel.TabIndex      = 3;
     this.Btn_VérifierVisuel.Text          = "Vérifier";
     this.Btn_VérifierVisuel.Theme         = MetroFramework.MetroThemeStyle.Light;
     this.Btn_VérifierVisuel.UseSelectable = true;
     this.Btn_VérifierVisuel.Click        += new System.EventHandler(this.Btn_VérifierVisuel_Click);
     //
     // Cam_Visuel1
     //
     this.Cam_Visuel1.AutoValidate          = System.Windows.Forms.AutoValidate.Disable;
     this.Cam_Visuel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
     this.Cam_Visuel1.BorderStyle           = System.Windows.Forms.BorderStyle.Fixed3D;
     this.Cam_Visuel1.Location    = new System.Drawing.Point(406, 235);
     this.Cam_Visuel1.MinimumSize = new System.Drawing.Size(830, 500);
     this.Cam_Visuel1.Name        = "Cam_Visuel1";
     this.Cam_Visuel1.Size        = new System.Drawing.Size(1109, 684);
     this.Cam_Visuel1.TabIndex    = 8;
     this.Cam_Visuel1.Load       += new System.EventHandler(this.Cam_Visuel1_Load);
     //
     // List_Camera
     //
     this.List_Camera.FormattingEnabled = true;
     this.List_Camera.Location          = new System.Drawing.Point(349, 956);
     this.List_Camera.Name                  = "List_Camera";
     this.List_Camera.Size                  = new System.Drawing.Size(1222, 95);
     this.List_Camera.TabIndex              = 5;
     this.List_Camera.SelectedIndexChanged += new System.EventHandler(this.List_Camera_SelectedIndexChanged);
     //
     // Load_identificationVisuel
     //
     this.Load_identificationVisuel.Location           = new System.Drawing.Point(774, 403);
     this.Load_identificationVisuel.Maximum            = 100;
     this.Load_identificationVisuel.Name               = "Load_identificationVisuel";
     this.Load_identificationVisuel.Size               = new System.Drawing.Size(368, 350);
     this.Load_identificationVisuel.Speed              = 2F;
     this.Load_identificationVisuel.TabIndex           = 7;
     this.Load_identificationVisuel.UseCustomBackColor = true;
     this.Load_identificationVisuel.UseCustomForeColor = true;
     this.Load_identificationVisuel.UseSelectable      = true;
     this.Load_identificationVisuel.UseStyleColors     = true;
     //
     // Txt_chargementMetro
     //
     this.Txt_chargementMetro.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                              | System.Windows.Forms.AnchorStyles.Left)
                                                                             | System.Windows.Forms.AnchorStyles.Right)));
     this.Txt_chargementMetro.AutoSize           = true;
     this.Txt_chargementMetro.FontSize           = MetroFramework.MetroLabelSize.Tall;
     this.Txt_chargementMetro.Location           = new System.Drawing.Point(754, 698);
     this.Txt_chargementMetro.Name               = "Txt_chargementMetro";
     this.Txt_chargementMetro.Size               = new System.Drawing.Size(413, 25);
     this.Txt_chargementMetro.Style              = MetroFramework.MetroColorStyle.Blue;
     this.Txt_chargementMetro.TabIndex           = 8;
     this.Txt_chargementMetro.Text               = "IDENTIFICATION DE LA PHOTO MERCI DE PATIENTER";
     this.Txt_chargementMetro.Theme              = MetroFramework.MetroThemeStyle.Light;
     this.Txt_chargementMetro.UseCustomBackColor = true;
     this.Txt_chargementMetro.UseCustomForeColor = true;
     this.Txt_chargementMetro.UseStyleColors     = true;
     //
     // Lbl_infoutilisateur
     //
     this.Lbl_infoutilisateur.AutoSize  = true;
     this.Lbl_infoutilisateur.Font      = new System.Drawing.Font("Roboto Cn", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.Lbl_infoutilisateur.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
     this.Lbl_infoutilisateur.Location  = new System.Drawing.Point(20, 211);
     this.Lbl_infoutilisateur.Name      = "Lbl_infoutilisateur";
     this.Lbl_infoutilisateur.Size      = new System.Drawing.Size(63, 25);
     this.Lbl_infoutilisateur.TabIndex  = 10;
     this.Lbl_infoutilisateur.Text      = "label1";
     //
     // Btn_continuerToMdp
     //
     this.Btn_continuerToMdp.FontSize           = MetroFramework.MetroButtonSize.Tall;
     this.Btn_continuerToMdp.ForeColor          = System.Drawing.SystemColors.Highlight;
     this.Btn_continuerToMdp.Location           = new System.Drawing.Point(1539, 499);
     this.Btn_continuerToMdp.Name               = "Btn_continuerToMdp";
     this.Btn_continuerToMdp.Size               = new System.Drawing.Size(358, 116);
     this.Btn_continuerToMdp.TabIndex           = 12;
     this.Btn_continuerToMdp.Text               = "Continuer";
     this.Btn_continuerToMdp.UseCustomForeColor = true;
     this.Btn_continuerToMdp.UseSelectable      = true;
     this.Btn_continuerToMdp.Click             += new System.EventHandler(this.Btn_continuerToMdp_Click);
     //
     // Img_previewUserReconnu
     //
     this.Img_previewUserReconnu.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     this.Img_previewUserReconnu.Location    = new System.Drawing.Point(406, 250);
     this.Img_previewUserReconnu.Name        = "Img_previewUserReconnu";
     this.Img_previewUserReconnu.Size        = new System.Drawing.Size(1109, 669);
     this.Img_previewUserReconnu.SizeMode    = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
     this.Img_previewUserReconnu.TabIndex    = 11;
     this.Img_previewUserReconnu.TabStop     = false;
     this.Img_previewUserReconnu.Click      += new System.EventHandler(this.Img_previewUserReconnu_Click);
     //
     // Img_identificationVisuelPreview
     //
     this.Img_identificationVisuelPreview.Location = new System.Drawing.Point(0, 615);
     this.Img_identificationVisuelPreview.Name     = "Img_identificationVisuelPreview";
     this.Img_identificationVisuelPreview.Size     = new System.Drawing.Size(390, 304);
     this.Img_identificationVisuelPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
     this.Img_identificationVisuelPreview.TabIndex = 6;
     this.Img_identificationVisuelPreview.TabStop  = false;
     //
     // Img_LogoOX
     //
     this.Img_LogoOX.Image    = global::ProjOXFORD_G2WinForm.Properties.Resources.LogoOxford;
     this.Img_LogoOX.Location = new System.Drawing.Point(0, -1);
     this.Img_LogoOX.Name     = "Img_LogoOX";
     this.Img_LogoOX.Size     = new System.Drawing.Size(193, 194);
     this.Img_LogoOX.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
     this.Img_LogoOX.TabIndex = 0;
     this.Img_LogoOX.TabStop  = false;
     //
     // IdentificationVisuel
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(1920, 1080);
     this.Controls.Add(this.Btn_continuerToMdp);
     this.Controls.Add(this.Lbl_infoutilisateur);
     this.Controls.Add(this.Txt_chargementMetro);
     this.Controls.Add(this.Load_identificationVisuel);
     this.Controls.Add(this.Img_identificationVisuelPreview);
     this.Controls.Add(this.List_Camera);
     this.Controls.Add(this.Cam_Visuel1);
     this.Controls.Add(this.Btn_VérifierVisuel);
     this.Controls.Add(this.Btn_RetourVisuel);
     this.Controls.Add(this.txtTitre2);
     this.Controls.Add(this.Img_LogoOX);
     this.Controls.Add(this.Img_previewUserReconnu);
     this.Name          = "IdentificationVisuel";
     this.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation;
     this.Load         += new System.EventHandler(this.IdentificationVisuel_Load);
     ((System.ComponentModel.ISupportInitialize)(this.Img_previewUserReconnu)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.Img_identificationVisuelPreview)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.Img_LogoOX)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Exemplo n.º 19
0
        public void Init(WebCameraControl CamControl)
        {
            _camControl = CamControl;

            Refresh();
        }
Exemplo n.º 20
0
 private void OnStopButtonClick(object sender, RoutedEventArgs e)
 {
     WebCameraControl.StopCapture();
 }
Exemplo n.º 21
0
        // Method to perform all the steps to take a picture.
        public void takePicture()
        {
            WebCameraControl control = new WebCameraControl();

            WebCameraId camera = null;

            if (control.GetVideoCaptureDevices().Count() > 0)
            {
                //Select the first camera we find. This can be more sophisticated.
                camera = (WebCameraId)control.GetVideoCaptureDevices().First();

                control.RenderSize = new System.Windows.Size(1920, 1080);

                control.StartCapture(camera);

                // This seems risky.
                // TODO change this to a more secure method of waiting.
                while (control.GetCurrentImage() == null)
                {
                }

                // Take 50 images (about 2 seconds.) The camera should have focussed and exposed correctly in that time.
                Image[]     img   = new Image[50];
                BitmapImage image = new BitmapImage();
                for (int i = 0; i < img.Length; i++)
                {
                    img[i] = control.GetCurrentImage();

                    MemoryStream ms = new MemoryStream();
                    img[i].Save(ms, ImageFormat.Bmp);
                    ms.Position = 0;
                    image       = new BitmapImage();
                    image.BeginInit();
                    ms.Seek(0, SeekOrigin.Begin);
                    image.StreamSource = ms;
                    image.EndInit();
                }
                // Store the image in DataDelegate.
                DataDelegate.customerImage = image;
                // Record the time taken.
                DataDelegate.timeCustomerImageTaken = DateTime.Now;
                control.StopCapture();

                // TODO Fix the code below to allow saving of the file to disk and/or to database.



                /*
                 * String path = System.IO.Path.Combine(Environment.CurrentDirectory, @"..\..\Assets\audio\PhotographComplete.wav");
                 * Audio.play(path);
                 *
                 * string filename = @"/GLASS/CustomerPhoto";
                 * string ext = @".png";
                 * var filePath = @Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), filename + ext);
                 *
                 * SaveFileDialog saveFile = new SaveFileDialog();
                 * saveFile.Filter = "PNG file |*.png";
                 * saveFile.FileName = filename + DateTime.Now.Date.Year + "-" + DateTime.Now.Date.Month + "-" + DateTime.Now.Date.Day + "-" + ext;
                 * saveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                 *
                 * if (saveFile.ShowDialog() == DialogResult.OK)
                 * {
                 *  img.Last().Save(filePath);
                 * }
                 */
            }
        }
Exemplo n.º 22
0
        //Constructor
        public Camera(WebCameraControl webcam)
        {
            webCameraControl = webcam;

            //Sets timer
        }
        private void Capture()
        {
            while (true)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    _image = WebCameraControl.GetCurrentImage();
                });

                if (_image != null)
                {
                    var result = _reader.Decode(_image);
                    if (result != null)
                    {
                        string str = result.ToString();

                        var student = _sTvvm.Students.FirstOrDefault(x => x.Id == str);
                        if (student == null)
                        {
                            MessageBox.Show("Ο χρήστης δε βρέθηκε!", "Σφάλμα", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            var content = "";
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                content = ShiftLabel.Content.ToString();
                            });

                            if (content == "Lunch")
                            {
                                if (!student.Lunch)
                                {
                                    if (student.Free)
                                    {
                                        MessageBox.Show("Ο χρήστης δικαιούται δωρεάν σίτηση!\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ο χρήστης ΔΕΝ δικαιούται δωρεάν σίτηση!\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                    }
                                    student.Lunch = true;
                                }
                                else
                                {
                                    MessageBox.Show("Έχετε ήδη καταχωρηθεί για τη μεσημεριανή βάρδια!\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                }
                                student.Dinner = false;
                            }
                            else
                            {
                                if (!student.Dinner)
                                {
                                    if (student.Free)
                                    {
                                        MessageBox.Show("Ο χρήστης δικαιούται δωρεάν σίτηση\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ο χρήστης ΔΕΝ δικαιούται δωρεάν σίτηση\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                    }
                                    student.Dinner = true;
                                }
                                else
                                {
                                    MessageBox.Show("Έχετε ήδη καταχωρηθεί για τη βραδινή βάρδια!\nΌνομα φοιτητή/τριας: " + student.Name, "Επιτυχές Σκανάρισμα");
                                }
                                student.Lunch = false;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        private void OnStartButtonClick(object sender, RoutedEventArgs e)
        {
            var cameraId = (WebCameraId)ComboBox.SelectedItem;

            WebCameraControl.StartCapture(cameraId);
        }
Exemplo n.º 25
0
 private void InitializeComboBox()
 {
     VideoDevicesComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices();
 }