Murhaf Fares
Murhaf Fares

Reputation: 11

Unable to create capture in Emgu

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()

Upvotes: 1

Views: 5282

Answers (2)

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.

Upvotes: 0

Luca Del Tongo
Luca Del Tongo

Reputation: 2702

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

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

Upvotes: 2

Related Questions