无法从 Emgucv 中的文件创建捕获

Unable to create capture from file in Emgucv

if (_capture == null)
        {
            try
            {
                _capture = new Capture("video1.mpg");
            }
            catch (NullReferenceException ex)
            {   //show errors if there is any
                MessageBox.Show(ex.Message);
            }
        }

video1.mpg 文件在 bin 文件夹中。 我已经使用 any-video-converter 将 avi 文件转换为 MPEG-1 格式。 但是这种格式仍然不起作用。我也试过 mencoder。但仍然是同样的错误。

Unable to create capture from video1.mpg

如何兼容emgu Capture?

首先您需要将 Vedio 文件转换为 .avi format.and 使用其他工具转换所需的 vedio 文件。您现在使用的工具可能是演示版,这就是为什么它可能无法正确隐藏它的原因......然后尝试以下代码:

   string nameOfFile = @"D:\somefile.avi";// your vedio path
Capture _capture = new Capture(name);
      try
        {
            _capture = new Capture(nameOfFile);
        }
        catch (NullReferenceException ex)
        {   //show errors if there is any
            MessageBox.Show(ex.Message);
        }

将视频转换为 i420 格式。

Download this converter.

执行转换的命令:

mencoder inputVideo.avi -ovc raw -vf format=i420 -o convertedVideo.avi

这 convertedVideo.avi 现在可以捕获了。