ERROR: initializer for 'Emgu.CV.CvInvoke' threw an exception

Ask questions on using Emgu CV with VB

ERROR: initializer for 'Emgu.CV.CvInvoke' threw an exception

Postby three_xtreme » Wed Sep 05, 2012 5:24 am

Greetings from the newbie

I am facing problems when trying to apply this application from this tutorial: http://www.youtube.com/watch?v=CTm0P-u0HKI

I've tried many solutions and debugging tips but still no luck.

When I try to click the button 'Initialize Tracking'

Image

it prompts me an error on this line :_capture = new Capture("LucaHead.wmv");

ERROR: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.

Image

I have checked the LucaHead.wmv is working perfectly and in the correct folder.
Anyone have any idea how to solve this problem?

Thanks

Adrian
three_xtreme
 
Posts: 5
Joined: Wed Sep 05, 2012 3:35 am

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby Chris_Johnson » Wed Sep 05, 2012 5:34 am

Hi,

What is the inner exception to the error?

Cheers,
Chris
Chris_Johnson
 
Posts: 548
Joined: Tue Sep 20, 2011 3:29 pm

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby three_xtreme » Fri Sep 07, 2012 1:24 am

Hello

Thanks for your reply.

This is the error. You can see it in the image link below:
http://postimage.org/image/8txisxybr/

Thanks

Adrian
three_xtreme
 
Posts: 5
Joined: Wed Sep 05, 2012 3:35 am

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby Chris_Johnson » Sat Sep 08, 2012 2:36 pm

HI,

Chance's are that the video is encoded with a codec that opencv doesn't support. You will need to click on the "View details..." option at the bottom of the error so the reason for the error is displayed. Within the screen that pops up scroll down to the inner exception and this will give you the cause. If you don't understand it put another screen shot up or post it here and I'll try and sort it.

Cheers,
Chris
Chris_Johnson
 
Posts: 548
Joined: Tue Sep 20, 2011 3:29 pm

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby three_xtreme » Wed Sep 12, 2012 5:22 am

Hi there.

Clicked the 'View Detail..' button and this is what it shows:

Exception snapshot:
{"The type initializer for 'Emgu.CV.CvInvoke' threw an exception."}

Here are the screen shots:
http://postimage.org/image/848xwvl8b/

http://postimage.org/image/7wpwe3znf/

Thank you so much, Chris.
three_xtreme
 
Posts: 5
Joined: Wed Sep 05, 2012 3:35 am

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby Chris_Johnson » Wed Sep 12, 2012 6:28 am

Hi,

Great an easy problem so don't worry the Inner exception gives you the key to your problem.

"Unable to load open_cvcore240.dll"

Now as your using 2.4 things have changed slightly from 2.3 you now require all (or at least a majority) of the opencv dlls in your ouptut directory (the bin folder by default). You can use the method here to add the dlls to your project http://file.emgu.com/wiki/index.php/Setting_up_EMGU_C_Sharp, but I apologise as this is outdated and for EMGU's 2.3 version. Details about the dlls required can be aquired here http://file.emgu.com/wiki/index.php/Download_And_Installation but heres the list:

For EMGU CV version >=2.4 cudart64_42_9.dll, cvextern.dll, npp64_42_9.dll, opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_flannXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_nonfreXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll, where XXX is the OpenCV version number.

Add them to your project and set there properties to "copy always".

This will solve your problem,

Cheers,
Chris,

P.S. the "Unable to load open_cvcore240.dll" will be thrown if even if you included that dll if you forget to add one of the others. This is because open_cvcore240.dll actually calls the other dlls internally. If they are not present that open_cvcore240.dll throws the error not the others.
Chris_Johnson
 
Posts: 548
Joined: Tue Sep 20, 2011 3:29 pm

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby three_xtreme » Tue Sep 18, 2012 4:38 am

Hi! Thanks for your great help.

I've tried the solution. Added the list of dll files by right click and then add existing items.
It get rid of the 'inner exception' error. However, it gives me another error 'NullReferenceException was unhandled-Unable to create capture from LucaHead.wmv' error.

Here are the screenshots of the new error:
http://postimage.org/image/n1vfij7ox/

http://postimage.org/image/6ocl5ntfl/

Do you have any idea how to get rid of this?

Thanks so much
three_xtreme
 
Posts: 5
Joined: Wed Sep 05, 2012 3:35 am

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby Chris_Johnson » Tue Sep 18, 2012 4:44 am

Hi,

I would expect that Opencv doesn't recognise the codec it's often a problem your best bet is to re-encode the video so that opencv can recognise it here is relevant page that will let you know how what can encode the video properly.

http://opencv.willowgarage.com/wiki/VideoCodecs
Cheers,
Chris
Chris_Johnson
 
Posts: 548
Joined: Tue Sep 20, 2011 3:29 pm

Re: ERROR: initializer for 'Emgu.CV.CvInvoke' threw an excep

Postby three_xtreme » Tue Sep 25, 2012 5:18 am

Hi Chris.

I have tried using several codecs and some encoders like :AutoMen6_Beta for mencoder as mentioned in the link that you gave.
But still no luck.
I have tried to change it to AVI codec, and I am still facing the same error as you can see in the screenshot below:

http://postimage.org/image/akkcy4euh/

Do you have any experience how to tackle this problem?

Thanks
three_xtreme
 
Posts: 5
Joined: Wed Sep 05, 2012 3:35 am


Return to VB Help

Who is online

Users browsing this forum: No registered users and 1 guest