【问题标题】:AForge.Video.DirectShow bitmap arg ArgumentExceptionAForge.Video.DirectShow 位图参数 ArgumentException
【发布时间】:2013-08-07 14:34:56
【问题描述】:

我正在尝试开发一个简单的应用程序,我可以在其中加载视频文件,然后将其逐帧显示在我的屏幕上。

要加载视频文件,我使用以下代码:

FileVideoSource fileVideo = new FileVideoSource(myVideoSource);
fileVideo.NewFrame += fileVideo_NewFrame;
fileVideo.Start();

然后,在fileVideo_NewFrame,我像这样捕获每一帧:

 if (SynchronizationContext.Current != uiContext)
 {
        uiContext.Post(delegate { fileVideo_NewFrame(sender, eventArgs);}, null);
        return;
 }

 Bitmap bitmap = eventArgs.Frame;
 PictureBoxvideo.Image = new Bitmap(bitmap);

 bitmap.Dispose();

但我收到了System.ArgumentException(非常明确......)。如果我在fileVideo 上停止调试,我可以看到:

位图似乎没有填充值。

知道为什么视频加载不正常吗?

感谢您的帮助!

【问题讨论】:

    标签: directshow aforge imaging


    【解决方案1】:

    我可以使用here 发布的解决方案来解决它。

    FileVideoSource fileVideo = new FileVideoSource(dialog.FileName);
    AsyncVideoSource asyncVideoSource = new AsyncVideoSource(fileVideo);
    asyncVideoSource.NewFrame += asyncVideoSource_NewFrame;
    asyncVideoSource.Start();
    
    private void asyncVideoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Image temp = PictureBoxvideo.Image;
        Bitmap bitmap = eventArgs.Frame;
        PictureBoxvideo.Image = new Bitmap(bitmap);
        if (temp!= null) temp.Dispose();
        bitmap.Dispose();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      • 2019-02-26
      相关资源
      最近更新 更多