Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从emgu cv中的网络摄像头获取视频流?_C#_Webcam_Emgucv - Fatal编程技术网

C# 如何从emgu cv中的网络摄像头获取视频流?

C# 如何从emgu cv中的网络摄像头获取视频流?,c#,webcam,emgucv,C#,Webcam,Emgucv,我在c#中使用emgu cv 我需要知道如何从emgu cv中的网络摄像头(默认网络摄像头)获取视频流?不确定您想对数据做什么,但这将从摄像头获取单个帧(并在WinForm上的pictureBox中显示) 您可以使用以下代码制作用于捕获和显示视频流的应用程序: public class CameraCapture { private Capture capture; //takes images from camera as image frames private bool

我在c#中使用emgu cv


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

不确定您想对数据做什么,但这将从摄像头获取单个帧(并在WinForm上的pictureBox中显示)


您可以使用以下代码制作用于捕获和显示视频流的应用程序:

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;
        }
    }
}
公共类摄像机捕捉
{
private Capture Capture;//将相机中的图像作为图像帧进行拍摄
私人bool captureInProgress;
私有void ProcessFrame(对象发送方、事件args arg)
{
Image ImageFrame=capture.QueryFrame();//第1行
CamImageBox.Image=ImageFrame;//第2行
}
私有void Form1\u加载(对象发送方、事件参数e)
{
如果(捕获==null)
{
尝试
{
捕获=新捕获();
}
捕获(NullReferenceExcpt)
{
MessageBox.Show(除消息外);
}
}
如果(捕获!=null)
{
if(captureInProgress)
{//如果相机正在获取帧,则停止捕获并设置按钮文本
//用于恢复捕获的“启动”
btnStart.Text=“开始!”//
Application.Idle-=ProcessFrame;
}
其他的
{
//如果相机未获取帧,则启动“捕获并设置”按钮
//用于暂停捕获的“停止”文本
btnStart.Text=“停止”;
Application.Idle+=ProcessFrame;
}
captureInProgress=!captureInProgress;
}
}
}

出于兴趣。请使用谷歌或至少访问图书馆的官方网站:查看以下3个链接:*、*、和*
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;
        }
    }
}