C#使用Emgu.CV.dll进行图像处理---使用EmguCV获取摄像头和读取视频
using System.Windows.Forms; using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.UI; using Emgu.CV.Structure; namespace ConsoleApp { class Program { static void Main(string[] args) { TestEmguCV3(); //TestDTU4G(); //TestTcpListenerSocket(); //TestInterlocked(); Console.Read(); } #region EmguCV使用EmguCV获取摄像头和从视频中获取帧 public static void TestEmguCV3() { Console.WriteLine($"Emgu CV3+C#图像处理(四):使用EmguCV获取摄像头、读取视频"); #region EmguCV获取摄像头 ////获取摄像头 //ImageViewer viewer = new ImageViewer(); ////捕获 //Emgu.CV.Capture capture = new Emgu.CV.Capture(); //Application.Idle += new EventHandler(delegate (object sender, EventArgs e) //{ // //获得的图像 // viewer.Image = capture.QueryFrame(); //}); ////显示 //viewer.ShowDialog(); //Console.WriteLine($"EmguCV3Emgu"); #endregion #region EmguCV读取视频 //读取视频 ImageViewer viewer = new ImageViewer(); //读取视频 Emgu.CV.Capture capture = new Emgu.CV.Capture(@"F:\Test\video\123.wmv"); //视频帧率 Console.WriteLine("Frame rate = " + capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps)); Application.Idle += new EventHandler(delegate (object sender, EventArgs e) { //获得的图像 viewer.Image = capture.QueryFrame(); }); viewer.ShowDialog(); #endregion } #endregion } }