gpt4 book ai didi

c# - Aforge.Video库的MJPEGStream函数示例

转载 作者:可可西里 更新时间:2023-11-01 11:20:58 27 4
gpt4 key购买 nike

有人可以给我一个完整的例子,使用这个用 VB.NET 或 C# 编写的库在 picturebox 中显示流的图像

最佳答案

这是一个非常非常简单的表单,它使用了 AForge.Video.MJPEGStream 类。

private MJPEGStream VideoStream = new MJPEGStream();

private void frmMain_Load(object sender, System.EventArgs e)
{
VideoStream.Source = "URL_HERE";
VideoStream.Login = "USERNAME_HERE";
VideoStream.Password = "PASSWORD_HERE";

VideoStream.Start();
}

private void frmMain_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
VideoStream.Stop();
}

private void VideoStream_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
{
Bitmap FrameData = new Bitmap(eventArgs.Frame);

pbStream.Image = FrameData;
}

private void VideoStream_VideoSourceError(object sender, AForge.Video.VideoSourceErrorEventArgs eventArgs)
{
Debug.WriteLine(eventArgs.Description);
}
public frmMain()
{
InitializeComponent();
this.FormClosing += new EventHandler(frmMain_FormClosing);
this.Load += new EventHandler(frmMain_Load);
VideoStream.NewFrame += new EventHandler(VideoStream_NewFrame);
VideoStream.VideoSourceError+= new EventHandler(VideoStream_VideoSourceError);
}

关于c# - Aforge.Video库的MJPEGStream函数示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10835779/

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