winform实时显示视频并截取图片,使用了emgucv
public void CaptureProcess(object sender, EventArgs arg) { frame = capture.QueryFrame(); imageBox_capture.Image = frame; } private void button_capture_start_Click(object sender, EventArgs e) { if (capture == null) { try { capture = new Capture(); } catch (NullReferenceException except) { MessageBox.Show(except.Message); } } if (capture != null) { if (capture_flag) { //Application.Idle = new EventHandler(CaptureProcess); capture_tick.Start(); button_capture_start.Text = "停止"; } else { //Application.Idle -= new EventHandler(CaptureProcess); capture_tick.Stop(); button_capture_start.Text = "开始"; } capture_flag = !capture_flag; } } private void button_capture_frame_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "BMP文件|*.bmp|JPG文件|*.jpg|JPEG文件|*.jpeg|所有文件|*.*"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { CvInvoke.cvSaveImage(saveFileDialog.FileName, this.frame, (IntPtr)0); } }
评论