gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 20:01:33 25 4
gpt4 key购买 nike

我在 C# 中使用 emgu cv。

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

最佳答案

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

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;
}
}
}

关于c# - 如何从 emgu cv 中的网络摄像头获取视频流?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18727747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com