Esempio n. 1
0
        private void btnCamera_Click(object sender, EventArgs e)
        {
            DeleteCapture();
            var hEvent = IntPtr.Zero;
            int index  = comboBoxCamera.SelectedIndex;

            camera = cameraDevice.Create(index, this.pictureBox1, hEvent);
            MethodInvoker invoked_method = (() =>
            {
                if (null != pictureBox1.Image)
                {
                    pictureBox1.Image.Dispose();
                }
                if (null != camera)
                {
                    var img = camera.SnapShot().ToBMP();
                    this.pictureBox1.Image = img;
                }
            });

            unsafe
            {
                camera.SampleEvent = (time, buf, size) =>
                {
                    BeginInvoke((MethodInvoker)invoked_method);
                };
            }
            camera.ResetSampleEvent();
            setSize(camera.Width, camera.Height);
            camera.Start();
        }
Esempio n. 2
0
 private void btnCamera_Click(object sender, EventArgs e)
 {
     DeleteCapture();
     var hEvent = IntPtr.Zero;
     int index = comboBoxCamera.SelectedIndex;
     camera = cameraDevice.Create(index, this.pictureBox1, hEvent);
     MethodInvoker invoked_method = (() =>
                         {
                             if (null != pictureBox1.Image) pictureBox1.Image.Dispose();
                             if (null != camera)
                             {
                                 var img = camera.SnapShot().ToBMP();
                                 this.pictureBox1.Image = img;
                             }
                         });
     unsafe
     {
         camera.SampleEvent = (time, buf, size) =>
         {
             BeginInvoke((MethodInvoker)invoked_method);
         };
     }
     camera.ResetSampleEvent();
     setSize(camera.Width, camera.Height);
     camera.Start();
 }
Esempio n. 3
0
        public void Run()
        {
            CameraCapture.Start();
            Started = true;

            var keyHandler = new KeyHandler();

            keyHandler.KeyEvent += keyHandler_KeyEvent;
            keyHandler.WaitForExit();

            Stop();
        }
Esempio n. 4
0
        private async Task UpdatePreviewState()
        {
            if (!_cameraCapture.IsPreviewActive)
            {
                await _cameraCapture.Start();

                BeginTracking();
            }
            else
            {
                await _cameraCapture.Stop();

                CanvasFaceDisplay.Children.Clear();
            }
        }
Esempio n. 5
0
        public async Task PreviewStart()
        {
            if (!cameraCapture.IsInitialized)
            {
                await cameraCapture.Initialize(captureElement);
            }

            if (!cameraCapture.IsPreviewActive)
            {
                await cameraCapture.Start();
            }

            IsPreviewActive = cameraCapture.IsPreviewActive;

            UpdateProcessing();
        }
Esempio n. 6
0
        private async Task UpdatePreviewState()
        {
            await cameraCapture.Initialize(CaptureElementPreview);

            if (cameraCapture.IsInitialized)
            {
                if (!cameraCapture.IsPreviewActive)
                {
                    await cameraCapture.Start();

                    BeginProcessing();
                }
                else
                {
                    await cameraCapture.Stop();
                }
            }
        }