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(); }
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(); }
public void Run() { CameraCapture.Start(); Started = true; var keyHandler = new KeyHandler(); keyHandler.KeyEvent += keyHandler_KeyEvent; keyHandler.WaitForExit(); Stop(); }
private async Task UpdatePreviewState() { if (!_cameraCapture.IsPreviewActive) { await _cameraCapture.Start(); BeginTracking(); } else { await _cameraCapture.Stop(); CanvasFaceDisplay.Children.Clear(); } }
public async Task PreviewStart() { if (!cameraCapture.IsInitialized) { await cameraCapture.Initialize(captureElement); } if (!cameraCapture.IsPreviewActive) { await cameraCapture.Start(); } IsPreviewActive = cameraCapture.IsPreviewActive; UpdateProcessing(); }
private async Task UpdatePreviewState() { await cameraCapture.Initialize(CaptureElementPreview); if (cameraCapture.IsInitialized) { if (!cameraCapture.IsPreviewActive) { await cameraCapture.Start(); BeginProcessing(); } else { await cameraCapture.Stop(); } } }