|
The type initializer for 'Emgu.CV.CvInvoke' threw anexception.
If you see this exception, please check the following
Have you installed MSVCRT?
For Version 2.0+, the bundled OpenCV 2.0 binary is build withVisual Studio 2008, you will needs to installedMSVCRT 9.0 SP1 to resolve the dependencyissue.
For Version 1.5, the bundled OpenCV pre1.1 binary is build withVisual Studio 2005, you will needs to installedMSVCRT 8.0 SP1 to resolve the dependencyissue.
Have you copied the OpenCV dlls to the execution directory?
Make sure the unmanaged DLLs are in the execution directory.
For Emgu CV version <= 2.1, this means thefollowing dlls: cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll,highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dll andcvextern.dll whereXXX is the OpenCV versionnumber.
For Emgu CV version >= 2.2 this means thefollowing dlls: opencv_calib3dXXX.dll, opencv_contribXXX.dll,opencv_coreXXX.dll, opencv_features2dXXX.dll,opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll,opencv_mlXXX.dll, opencv_objectdetectXXX.dll,opencv_videoXXX.dll where XXX is the OpenCVversion number.
The best way to set up your project is:
Copy the unmanaged DLLs to your project folder
Right click on the project, click Add->ExistingItem and select all unmanaged DLLs. Add them to the project.
For each of the included Dlls, left click on it, find the "Copyto Output Directory" option and select "Copy if newer"
Are you running a 32-Bit OS?
The windows installer is only available for 32-Bit windows. Ifyou are using a 64-bit OS, there are three possible ways to resolvethis issue:
You can download the 64bit binary only zip package fromsourceforge and add it to your project.
You can also recompile OpenCV from source for 64-bit platform. See the instruction for building fromSVN
Alternatively you can force your .NET application to run in32bit mode, even on a 64-bit OS. To do this, in the configurationpage of your executable project, select Platform Target as'x86'.
Are you missing any dependency?
Download Dependency Walker and use it to open the"cvextern.dll" file. Check if any dependency is missing.
I have checked all of above but I still got theException
In this case, please try to build and run the examples.After building the examples, try to run the "Hello World"Program.
If "Hello World" runs without any problem, compare it with youproject, find the difference in configuration and fix it.
If "Hello World" get the same "The type initializer for'Emgu.CV.CvInvoke' threw an exception." message, try to find outtheInnerException and report it to the discussion forum
类型初始化的emgu。CV。cvinvoke '把例外。
如果你看到这个例外,请检查以下
你有没有安装msvcrt?
版本2 +,捆绑的opencv 2二进制是建立Visual Studio 2008,你将需要installedmsvcrt 9 SP1解决dependencyissue。
1.5版本,捆绑的OpenCV pre1.1二进制建立Visual Studio 2005,你将需要installedmsvcrt 8 SP1解决dependencyissue。
你复制的opencv DLL执行目录?
确保非托管DLL在执行目录。
对于emgu CV版< = 2.1,这意味着以下的DLL:cvxxx.dll,cvauxxxx.dll,cxcorexxx。DLL,highguixxx.dll,opencv_ffmpegxxx.dll,mlxxx.dll andcvextern.dll wherexxx是opencv的versionnumber。
对于emgu CV版> = 2.2这意味着以下的DLL:opencv_calib3dxxx.dll,opencv_contribxxx。DLL,opencv_corexxx.dll,opencv_features2dxxx。DLL,opencv_highguixxx.dll,opencv_imgprocxxx.dll,opencv_legacyxxx。DLL,opencv_mlxxx.dll,opencv_objectdetectxxx。DLL,opencv_videoxxx.dll XXX是opencvversion数。
建立你的项目的最好方法是:
非托管DLL复制到你的项目文件夹
右键单击项目,单击“添加-> existingitem选择所有的非托管DLL。将它们添加到项目中。
每个所包含的DLL,左键点击它,找到“复制与输出目录”选项,选择“复制如果更新”
你运行32位操作系统吗?
视窗安装程序只可提供32位视窗。如果你使用的是64位的操作系统,有三种可能的方式解决这一问题:
你可以下载64位二进制只有zip包fromsourceforge并添加到您的项目。
你也可以从64位平台编译OpenCV源。看到建筑fromsvn指令
或者你可以强迫你的。NET应用程序运行in32bit模式,即使在64位操作系统。要做到这一点,在你执行项目的configurationpage,选择平台的目标as'x86”。
你缺少任何依赖吗?
下载依赖沃克和用它来打开“cvextern DLL文件。”。检查是否丢失了任何依赖关系。
我检查了所有以上但我仍然有例外
在这种情况下,请尝试构建和运行实例。在构建实例之后,尝试运行“你好世界”程序。
如果“世界你好”运行没有任何问题,它与youproject比较,发现在结构上的差异和解决它。
如果“你好世界”得到同样的“类型初始值设定项for'emgu。CV。cvinvoke“抛出一个异常。”消息,试图找到outtheinnerexception向论坛
|
上一篇:0元璐小米手环等产品详细教程下一篇:C#通过DllImport导入并调用Win32 API 函数
|