如何在Emgu CV中从网络摄像头获取视频流? [英] How to get video stream from webcam in emgu cv?

查看:385
本文介绍了如何在Emgu CV中从网络摄像头获取视频流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#中使用emgu cv。

I'm using emgu cv in c#.

我需要知道如何从emgu cv中的网络摄像头(默认网络摄像头)中获取视频流? / p>

I need to know How I can get the video stream from my webcam(default webcam)in emgu cv?

推荐答案

您可以使用以下代码制作一个应用来捕获和显示视频流:

You can use the following code to make an app to capture and display video stream:

public class CameraCapture
{
    private Capture capture;  //takes images from camera as image frames
    private bool captureInProgress;

    private void ProcessFrame(object sender, EventArgs arg)
    {
        Image<Bgr, Byte> 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;
        }
    }
}

这篇关于如何在Emgu CV中从网络摄像头获取视频流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆