问题
I'm building an image processing application using Emgu CV (for x64) and I want to use the filtering functions on images. So, I use opencv_imgproc.dll
but it throws BadImageFormatException
Solution Platform : x86
Operating System : Windows 7 - 64
Language: C#
IDE: Visual C# 2010 express
回答1:
Emgu is a managed wrapper for OpenCV. Because OpenCV is unmanaged, you will need to ensure that you are compiling with the correct settings for the version of Emgu you are using.
Based on the exceptions posted in the comments (http://pastie.org/5170481 and http://pastie.org/5170499 for reference), the Emgu version being compiled against is the x86 one, meaning that the OpenCV DLLs it depends on will need to be compiled for 32-bit . For your code to run, the Platform target
in the Build settings of you project needs to be set to x86
, regardless of the bitness of the OS you are running on.
To use the 64-bit version of Emgu, you will need to download a version compiled for 64-bit (you can see the different options here)
and then set the Platform target
to x64
.
来源:https://stackoverflow.com/questions/13170952/opencv-imgproc-dll-throws-badimageformatexception