如何在emgu cv中从网络摄像头获取video流?
我在c#中使用emgu cv。
我需要知道如何从emgu cv中的网络摄像头(默认网络摄像头)获取video流?
您可以使用以下代码制作应用程序以捕获和显示video流:
public class CameraCapture { private Capture capture; //takes images from camera as image frames private bool captureInProgress; private void ProcessFrame(object sender, EventArgs arg) { Image ImageFrame = capture.QueryFrame(); //line 1 CamImageBox.Image = ImageFrame; //line 2 } private void Form1_Load(object sender, EventArgs e) { if (capture == null) { try { capture = new Capture(); } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } } if (capture != null) { if (captureInProgress) { //if camera is getting frames then stop the capture and set button Text // "Start" for resuming capture btnStart.Text = "Start!"; // Application.Idle -= ProcessFrame; } else { //if camera is NOT getting frames then start the capture and set button // Text to "Stop" for pausing capture btnStart.Text = "Stop"; Application.Idle += ProcessFrame; } captureInProgress = !captureInProgress; } } }
不确定你想要对数据做什么,但是这将从相机中获得一个帧(并在WinForm上的pictureBox中显示)
private void Form1_Load(object sender, EventArgs e) { var capture = new Emgu.CV.Capture(); using (var nextFrame = capture.QueryFrame()) { if (nextFrame != null) { pictureBox1.Image = nextFrame.ToBitmap(); } } }
- 未针对动态generics类型解析方法
- RavenDB:如何将session.Query转换为session.Advanced.DocumentQuery?
- Unity.AutoRegistration ?? 基于会议的注册统一
- C#从SQL服务器中删除字符串中的NewLine字符
- 域服务与WCF服务?
- 如何从String 中仅选择隐藏文件夹?
- Xamarin.Forms HTTPS和自签名证书问题
- 流畅的NHibernate – 如何一对一地映射子类?
- System.Text.Encoding.GetEncoding(“iso-8859-1”)抛出PlatformNotSupportedException?