Esempio n. 1
0
 private void start()
 {
     try
     {
         _capture.SetInterval(new TimeSpan(0, 0, 0, 0, 500));
         _capture.Start();
         _capture.OnFrameCaptured += _capture_OnFrameCaptured;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Connect to the webcam and detect QR codes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            _webCamera                = WebCamera.GetDefaultDevice();
            connect_button.Enabled    = false;
            disconnect_button.Enabled = true;

            if (_webCamera != null)
            {
                //Setup webcam.
                _mediaConnector.Connect(_webCamera, _imageProvider);
                _videoViewer.SetImageProvider(_imageProvider);
                _webCamera.Start();
                _videoViewer.Start();
                state_textbox.Text        = @"ONLINE";
                detectStatus_textbox.Text = @"SØGER EFTER QR KODE";

                try
                {
                    _barcodeReader.DetectionOccurred += BarcodeReaderOnDetectionOccurred;

                    _imageProcesserHandler.AddProcesser(_barcodeReader);
                    _frameCapture.SetInterval(5);
                    _mediaConnector.Connect(_webCamera, _frameCapture);
                    _mediaConnector.Connect(_frameCapture, _imageProcesserHandler);
                    _frameCapture.Start();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(@"Der opstod en fejl: " + ex.Message);
                }
            }

            else
            {
                MessageBox.Show(@"Kunne ikke finde et webcam. Sørg for, at det er 
                installeret korrekt og sat til og prøv så igen", @"Der opstod en fel!");
            }
        }