无法在 Emgu 中创建捕获
当我尝试在 C# 中使用 Emgu 从 avi 文件捕获视频时,出现空引用异常。
Capture capture = new Capture("somepath.avi")
我的操作系统上安装了 K-Lite 编解码器。 这是堆栈跟踪:
> at Emgu.CV.Capture..ctor(String fileName)
>
> at HelloWorld.Program.Main() in D:\5th year stuff\1st Semester\Computer
> Vision\libemgucv-2.1.0.793-win64\Emgu.CV.Example\HelloWorld\Program.cs:line
> 30
>
> at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
>
> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>
> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>
> at System.Threading.ThreadHelper.ThreadStart()
I’m getting the null-reference-exception when I try to capture video from avi file using Emgu in C#.
Capture capture = new Capture("somepath.avi")
I have the K-Lite Codec installed on my OS.
Here's the stack trace:
> at Emgu.CV.Capture..ctor(String fileName)
>
> at HelloWorld.Program.Main() in D:\5th year stuff\1st Semester\Computer
> Vision\libemgucv-2.1.0.793-win64\Emgu.CV.Example\HelloWorld\Program.cs:line
> 30
>
> at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
>
> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>
> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>
> at System.Threading.ThreadHelper.ThreadStart()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仔细检查您的 avi 文件是否与 opencv 兼容。您应该使用 mencoder 并使用正确的编解码器对其进行转换,如此处所述。
一种受支持的编解码器是原始 I420 编解码器。您可以使用此命令使用 mencoder 将 avi 转换为 I420 格式
Double check that your avi file is compatible with opencv. you should use mencoder and convert it using a proper codec as explained here.
One supported codec is the raw I420 one. You can convert you avi to I420 one with mencoder using this command
我也遇到了同样的问题。我使用名为 FFmpeg 的视频编解码器将 .MOV 文件转换为 .AVI,当我将 opencv_ffmpeg.dll 添加到我的项目中时,它起作用了。该dll位于Emgu包的bin目录中。尝试找出您的 .avi 文件使用的编解码器,并检查是否有该编解码器的 dll。将dll复制到项目目录中,记得将文件的“复制本地”属性设置为“如果较新则复制”,看看是否有效。我使用了一个名为“Pazera Free Mov to Avi”的软件来转换具有不同编解码器选项的视频文件。
I was having the same problem. I converted a .MOV file to .AVI using a video codec called FFmpeg and when I added the opencv_ffmpeg.dll to my project it worked. The dll was in the bin directory of the Emgu package. Try to figure out what codec your .avi file is using and check if there is a dll for that codec. Copy the dll to the project directory, remeber to set "Copy if newer" to the "Copy local" property of the file and see if it works. I used a software called "Pazera Free Mov to Avi" to convert the video files with different codec options.