使用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库:
内容的提问来源于stack exchange,提问作者Wajadtuha GST
相关产品推荐
相关产品推荐

