简体   繁体   中英

EmguCV 64-bit build runtime error

I am running into issues building an existing 32-bit EmguCV ( Version 2.3 ) into 64-bit using .net 4.0 and VS2010 on a W7/x64 OS. I have purchased a commercial license, if that matters and downloaded from the links provided in the receipt.

The error is

System.TypeInitializationException was unhandled
 Message=The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
 Source=Emgu.CV
 TypeName=Emgu.CV.CvInvoke

I followed the instructions provided in this article . In fact I used the samples projects in the article and they build fine with V2.2, but when I replace with V2.3 binaries (both emgu and opencv), run into the error.

Has anyone successfully built an Emgu ( Version 2.3.x ) x64 project? Please provide some guidance.

The cause of this error (should anyone else run into the same problem) is that the program cannot access opencv_imgproc231.dll or opencv_core231.dll even though they are present in the output "bin" directory.

There are two solutions:

  1. Add them to the project and set their properties to copy always as they are EMGU's two key files.

  2. If step 1 doesn't work, replace the current key files in the bin folder with new copies.

If both methods fail then there may be a problem with the build, so download a new copy of EMGU from Sourceforge and try again. The error will later be incorporated within an technical article in order to provide a clearer explanation of how to solve it.

Cheers, Chris

No need to add them to the project; VS will not let you. Simply open FaceRecognizer.cs at public static partial class CvInvoke and change:

[DllImport(CvInvoke.EXTERN_LIBRARY, CallingConvention = CvInvoke.CvCallingConvention)] 

to:

[DllImport(Emgu.CV.CvInvoke.EXTERN_LIBRARY, CallingConvention = Emgu.CV.CvInvoke.CvCallingConvention)] 

Ensure you change all of them.

First test this way: open a sample project from emgu cv installaiton directory and run it. for example, open hello world example and try to run it. if sample projects run with out problem then the installation is correct.

For emgu cv sample projects, value of Output Path option in Build settings of the project is set to '..\\..\\ bin' . To fix your project problem, open the project in visual studio and set value of Output Path option to 'C:\\Emgu\\emgucv 2.9\\bin' . Try to run the project. It must run with success.

Now, set back the value of Output Path option to bin\\Debug\\ . Then, add all DLL files in the 'C:\\Emgu\\emgucv 2.9\\bin' folder to your project using ADD -> Existing Item menu. similarly, add all DLL files in the 'C:\\Emgu\\emgucv 2.9\\bin\\x64' folder to your project using ADD -> Existing Item menu. Now, go to properties window and set Copy to Output Directory option of all dll files to Copy Always . Finally, in the Configuration Manager window, create a new configuration for x64 platform.

Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM