private void toolStripButtonStop_Click(object sender, EventArgs e) { if (VideoState != VideoState.Stopped) { capture.Stop(); VideoState = VideoState.Stopped; } UpdateUI(); }
private void Button1_Click(object sender, EventArgs e) { if (!IsRunning) { if (capture.CaptureSource == VideoCapture.CaptureModuleType.Camera && capture.IsOpened) { tokenSource = new CancellationTokenSource(); currentFrame = new Image <Bgr, byte>(capture.Width, capture.Height); processedFrame = new Image <Bgr, byte>(capture.Width, capture.Height); processedResizedFrame = new Image <Gray, byte>(capture.Width / 2, capture.Height / 2); //imagesQueue = new ConcurrentQueue<Image<Bgr, byte>>(); //imagesCircQueue = new CircularQueue<Image<Bgr, byte>>(10); imagesCircQ = new CircularImagesQueue(10, new Size(capture.Width, capture.Height)); oImageUtils = new ImageUtils(); capture.Start(); darkImage = SaveDarkFieldImage("darkfield.bmp"); oImageUtils.SetDarkFieldImage(darkImage); swGlobal = Stopwatch.StartNew(); StartImageProcessing(); button1.Text = "Stop"; IsRunning = true; AlertService.Init(); eyeWatcher = new EyeWatcher(ref eyeRatios, 1000); eyeWatcher.evBlinkDetected += OnReceivedMessage; AlertService.evAlert += OnReceivedMessage; } else { IsRunning = false; OnReceivedMessage("Camera was not initialized", EventArgs.Empty); button1.Text = "Start"; capture.Stop(); AlertService.CloseAlertService(); if (eyeWatcher != null) { eyeWatcher.CloseEyeWatcher(); } } } else { tokenSource.Cancel(); IsRunning = false; button1.Text = "Start"; capture.Stop(); AlertService.CloseAlertService(); eyeWatcher.CloseEyeWatcher(); } }
private bool LoadVideo() { String szExe = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; m_szExeDir = new Uri(System.IO.Path.GetDirectoryName(szExe)).LocalPath; m_szLeftVideo = Path.Combine(new string[] { m_szExeDir, "data", "left.mp4" }); m_szRightVideo = Path.Combine(new string[] { m_szExeDir, "data", "right.mp4" }); if (!File.Exists(m_szLeftVideo) || !File.Exists(m_szRightVideo)) { return(false); } Emgu.CV.VideoCapture lCap = new Emgu.CV.VideoCapture(m_szLeftVideo); Emgu.CV.VideoCapture rCap = new Emgu.CV.VideoCapture(m_szRightVideo); if (!lCap.IsOpened || !rCap.IsOpened) { return(false); } m_imgLeft = lCap.QueryFrame(); m_imgRight = rCap.QueryFrame(); m_szLeftImg = new Size(m_imgLeft.Cols, m_imgLeft.Rows); m_szRightImg = new Size(m_imgRight.Cols, m_imgRight.Rows); lCap.Stop(); rCap.Stop(); //DrawLeftImage(ref m_imgLeft); return(true); }
private void StopCaptureButton(object sender, EventArgs e) { capture.ImageGrabbed -= ImageReceived; if (capture != null) { capture.Stop(); } stop_capture.Enabled = false; start_capture.Enabled = true; }
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); }