using Emgu.CV;
using Emgu.CV.Structure;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private VideoCapture capture;
private bool isProcess = false;
private void button1_Click(object sender, EventArgs e)
{
if (capture != null)
{
if (isProcess)
{
Application.Idle -= new EventHandler(ProcessFram);
this.startBtn.Text = "Stop";
}
else
{
Application.Idle += new EventHandler(ProcessFram);
this.startBtn.Text = "Start";
}
isProcess = !isProcess;
}
else
{
try {
capture = new VideoCapture();
}
catch (NullReferenceException expt)
{
MessageBox.Show(expt.Message);
}
}
}
private void ProcessFram(object sender, EventArgs arg)
{
Mat mat1 = capture.QueryFrame();
Mat mat2=new Mat();
CvInvoke.Flip(mat1, mat2, Emgu.CV.CvEnum.FlipType.Horizontal);
imageBox1.Image = mat2;
Image<Bgr, byte> image = mat2.ToImage<Bgr, byte>();
pictureBox1.Image = image.ToBitmap();
}
}
交流QQ群:
456197310