无法加载DLL'opencv_core242':找不到指定的模块。 Emgu CV

时间:2012-12-14 09:05:45

标签: c# emgucv

我正在尝试为C#开始使用emgu CV open CV。但我无法使其正常工作。 我正在按照本指南使用emgu CV Link制作简单的程序,但我得到以下错误:(知道我做错了什么?)

    System.TypeInitializationException was unhandled
      Message=The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
      Source=Emgu.CV
      TypeName=Emgu.CV.CvInvoke
      StackTrace:
       at Emgu.CV.Image`2..ctor(String fileName) in c:\Emgu\emgucv-windows-x86-gpu 2.4.2.1777\Emgu.CV\Image.cs:line 144
       at TEST.Form1.button1_Click(Object sender, EventArgs e) in c:\documents and settings\laci\my documents\visual studio 2010\Projects\TEST\TEST\Form1.cs:line 28
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at TEST.Program.Main() in c:\documents and settings\laci\my documents\visual studio 2010\Projects\TEST\TEST\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.DllNotFoundException
       Message=Unable to load DLL 'opencv_core242': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
       Source=Emgu.CV
       TypeName=""
       StackTrace:
            at Emgu.CV.CvInvoke.cvRedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
            at Emgu.CV.CvInvoke..cctor() in c:\Emgu\emgucv-windows-x86-gpu 2.4.2.1777\Emgu.CV\PInvoke\CvInvoke.cs:line 166
       InnerException: 

7 个答案:

答案 0 :(得分:8)

由于Emgu.CV只是一个.NET包装器(参见http://en.wikipedia.org/wiki/Wrapper_library),因此需要将OpenCV的本机.DLL文件放在应用程序输出目录中。

您可以通过在http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.2/OpenCV-2.4.2.exe/download

下载相应版本的OpenCV来查找所需文件

答案 1 :(得分:3)

我会节省你很多时间。 对于EMGU CV版本2.4。*缺少的dll是" nvcuda.dll"这不是EMGU的二进制文件的一部分,但它通常位于system32文件夹中(也许你需要安装nvidia驱动程序,如果不只是在线查找dll)

答案 2 :(得分:1)

您可以使用Dependency Walker解决此问题 - >在{opencv_core242.dll'上http://www.dependencywalker.com/找到任何丢失的DLL。

对我来说,它显示我没有将tbb.dll作为线程tbb.dll not found

只需从https://www.threadingbuildingblocks.org/下载并将tbb * .dll复制到工作目录或“System32”即可。

答案 3 :(得分:1)

旧的,但我有同样的问题。事实证明2.4.0具有GPU集成,如果您没有Nvidia卡,则缺少nvcuda.dll并且无法加载opencv_core242.dll。尝试了一切,唯一的解决方案是回到2.3.0,一切正常。

答案 4 :(得分:0)

正如错误所述 - 它无法在applcation的工作目录中找到本机DLL。确保将opencv_core242.dll库复制到应用程序的输出目录和工作目录中。

答案 5 :(得分:0)

http://www.dependencywalker.com/下载依赖步行者并打开声称无法加载的.dll。然后查找依赖项,如果甚至您的系统文件夹(system32或syswow64)的应用程序目录中缺少一个或多个依赖项,那么它们需要在那里。

答案 6 :(得分:0)

这里是解决问题的正确步骤。

访问:https://sourceforge.net/project/emgucv/emgucv/2.4.2/
根据您的操作系统,例如Windows x86,下载特定版本的emgucv 2.4.2,可以下载:libemgucv-windows-x86-gpu-2.4.2.1777.exe

将其安装在C:\ Emgu之类的位置 之后,转到C:\ Emgu \ emgucv-windows-x86-gpu 2.4.2.1777 \ bin \ x86,然后复制所有opencv dll文件并将其粘贴到应用程序exe输出目录中。

  • 要删除不必要的opencv dll文件,请运行您的应用程序,然后按ctrl + A并尝试删除这些文件,这些文件已被您的应用程序使用,您将无法删除它们,因为它们正在运行在使用中,并且重置的未使用dll文件将被删除,但您可以使用已过时的依赖行者应用程序(http://www.dependencywalker.com/)除外,它可能会也可能不会起作用