private void frameProcessing() { _capture = new Capture(_file); totalFrameCount = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount); progressBar1.Maximum = (int)totalFrameCount; timer.Start(); _capture.ImageGrabbed += ProcessFrame; if (timer.ElapsedMilliseconds == 1000) _capture.Stop(); }
private void 关闭相机ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.camp != null) { camp.Close(); } task.Abort(); capture.ImageGrabbed -= Capture_ImageGrabbed; capture.Stop(); capture.Dispose(); }
public bool GetVideoData(System.Windows.Forms.PictureBox picturebox1, System.Windows.Forms.PictureBox picturebox2) { CameraHasData = false; frm.SetText(frm.Controls["textBoxImageY"], "0"); frm.SetText(frm.Controls["textBoxDeg"], "0"); frm.SetText(frm.Controls["textBoxImageX"], "0"); capture.Start(); int cappturecounter = 1; while (!CameraHasData || cappturecounter <= 20) { GetCameraXY(picturebox1, picturebox2); cappturecounter++; } capture.Stop(); return(true); }
private void getFrame(object sender, EventArgs arg) { try { m = capture.QueryFrame(); displayImage(m.Bitmap); if (!detectWorker.IsBusy) { if (!detectWorker.CancellationPending) { detectWorker.RunWorkerAsync(); } } } catch (NullReferenceException e) { Application.Idle -= getFrame; capture.Stop(); MessageBox.Show(e.Message); } }
public async void StartCapture() { // Can only access the first camera without CL Eye SDK if (_camera.TrackerId == 0 && !_camera.Design) { _capture = new Capture(_camera.TrackerId); _ctsCameraCalibration = new CancellationTokenSource(); CancellationToken token = _ctsCameraCalibration.Token; _capture.Start(); try { // needed to avoid bitmapsource access violation? _captureTask = Task.Run(() => { while (!token.IsCancellationRequested) { ImageGrabbed(); } }, token); await _captureTask; } catch (OperationCanceledException) { } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } finally { _capture.Stop(); _capture.Dispose(); } } }