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

前端 未结 11 2256
轮回少年
轮回少年 2020-11-29 10:17

I\'m getting this error

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

when I try to use Emgu CV. I\'ve tried

相关标签:
11条回答
  • 2020-11-29 10:40

    you should add dependency dll into project and change 'copy to output directory' property to 'copy always' (add -> existing item) from Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86

    in my project add : opencv_core290.dll , opencv_highgui290.dll , opencv_ffmpeg290.dll , opencv_imageproc290.dll and cudart32_55.dll

    0 讨论(0)
  • 2020-11-29 10:48

    First you have to add three libraries to your project. opencv_core290.dll,opencv_highgui290.dll,opencv_imgproc290.dll. In here 290 refers that your opencv version. After that change in their property "Do not copy" to "copy always". than save your project. After that go to following location. If your machine is 64 bit than go to following folder "C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x64" or if your using 32 bit os than go to "C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86" and copy all the dlls in that folder and paste that into your Your Project/bin/debug/ folder. than rebuild your project. Than it will works fine.

    Best of luck!!!!

    0 讨论(0)
  • 2020-11-29 10:49

    Installing this nuget: https://www.nuget.org/packages/Emgu.CV.runtime.windows/ solved my problem, looks like the manual dll copying was resolved by this package.

    0 讨论(0)
  • 2020-11-29 10:49

    If it doesn't work on Windows Server you have to enable UI Desktop Experience.

    you can view the post

    0 讨论(0)
  • 2020-11-29 10:50

    It's probably failing to load the unmanaged DLL dependencies. A couple of suggestoins:

    1. Make sure your .NET project is targeting x86 rather than AnyCPU, since you likely have the x86 build of OpenCV.
    2. Make sure the OpenCV dlls are in your PATH (or directly in the bin directory, if this is a Console/WinForms/WPF app.)
    0 讨论(0)
  • 2020-11-29 10:56

    I had the same problem. My inner exception was "Unable to load DLL 'opencv_core290'".

    You need to copy x86 and x64 folders from "yourEmguFolder/bin" to your project's output(bin) directory. Then build project again and run.

    According to emgu wiki

    0 讨论(0)
提交回复
热议问题