You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AForge.Video.DirectShow时RTSP视频无法在PictureBox显示

问题:AForge.Video.DirectShow无法通过RTSP URL加载摄像头实时视频

我尝试使用AForge.Video.DirectShow实现摄像头RTSP URL的实时监控,代码如下:

private VideoCaptureDevice videoSource;
public camtest3()
{
    InitializeComponent();
}

private void camtest3_Load(object sender, EventArgs e)
{
    // 创建VideoCaptureDevice实例,传入RTSP URL
    videoSource = new VideoCaptureDevice("rtsp://IP:554/av0_1");

    // 注册NewFrame事件处理器以捕获每一帧视频
    videoSource.NewFrame += new NewFrameEventHandler(VideoCaptureDevice_NewFrame);

    // 开始捕获视频
    videoSource.Start();
}

private void VideoCaptureDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    // 在名为pictureBox1的PictureBox控件中显示视频帧
    pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}

通过断点调试发现,程序从未执行到pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();这一行。代码运行无报错,但PictureBox中始终无法显示视频。

已安装的NuGet库:
已安装的AForge相关NuGet库

内容的提问来源于stack exchange,提问作者Wajadtuha GST

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 06:53:11