EmguCV cvextern System.DllNotFoundException
Asked Answered
N

6

8

I am trying to run the example of LicensePlateRecognition in EmguCV 3.1. But I always get the error System.DllNotFoundException and the message is that "cvextern.dll cannot be loaded". I am running Windows 7 with Visual Studio 2013 (the computer is provided by my company).

I copied the said dll and some other dlls in the folder to the debug folder (the profile is set to debug mode, and I tried both x86 and x64 versions). After getting the error again and again I started to suspect that it's because of my video card driver (some Google results suggested so). I updated that and the error persisted.

After some more Googling, I found the Dependency Walker. One file "IEShims.dll" is missing. I downloaded that and put it into the debug folder with no luck.

Some output I think might be relevant.

Loading open cv binary from C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64

LoadLibraryEx C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64\opencv_ffmpeg310_64.dll failed with error code 87: The parameter is incorrect.

File C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64\opencv_ffmpeg310_64.dll cannot be loaded.

LoadLibraryEx C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64\cvextern.dll failed with error code 87: The parameter is incorrect.

File C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64\cvextern.dll cannot be loaded.

Does anyone know what's wrong with that?

The error seems to be stemmed from

#if !UNITY_IPHONE
     //Use the custom error handler
     RedirectError(CvErrorHandlerThrowException, IntPtr.Zero, IntPtr.Zero);
#endif

Which is in the method

  /// <summary>
  /// Attempts to load opencv modules from the specific location
  /// </summary>
  /// <param name="modules">The names of opencv modules. e.g. "opencv_cxcore.dll" on windows.</param>
  /// <returns>True if all the modules has been loaded successfully</returns>
  public static bool DefaultLoadUnmanagedModules(String[] modules)

I tried a whole day to find the solution but I really don't know what I can do now. Any help is appreciated.

EDIT: I also tried TlbImp with no luck.

TlbImp : error TI1002 : The input file 'D:\Resources\cvextern.dll' is not a valid type library.

Normanormal answered 12/3, 2016 at 7:45 Comment(0)
H
9

I found this page after encountering a similar problem when upgrading a project from Emgu 3.1.0.2282 to 3.1.0.2504-r16.12

In my case it was because my Win10 computer did not have Visual C++ Redistributable for Visual Studio 2015 installed.

More specifically, in Emgu 3.1.0.2282 the "x86" and "x64" folders contained msvcr120.dll and msvcp120.dll, while in 3.1.0.2504 those folders now contain vcruntime140.dll and msvcp140.dll.

The new dependency isn't mentioned in the changelog or installation instructions, and there was no indication that cvextern.dll was failing because of the visual C runtime - only the error bin\Debug\x64\cvextern.dll failed with error code 126: The specified module could not be found

I've not needed to copy DLL files around to fix this: my bin directory contains only the Emgu.CV.UI and Emgu.CV.World DLL files, plus the "x86" and "x64" folders (containing 4 DLLs each). I mention this to steer people away from all the advice Google will pull up which was intended for older versions of Emgu.

Hedva answered 28/12, 2016 at 4:8 Comment(4)
This must fix the problem for 80% of emgu users that are copying around dll files (such as myself), until they add the ones you mentioned! Clean solution, thanks :)Fredenburg
Potentially new link microsoft.com/en-us/download/details.aspx?id=52685 ? Your's is dead. I also have the C++ runtimes installed :/Predicate
@Hedva What are the exact dlls you need to initializing an "Image<TDepth,TColor>"? I know If I load all dlls(1.5GB!!) it works... can't find out though what is really needed..Ruskin
This has done it for me! Thanks a lot.Illgotten
G
3

Starting with version 4.2 everything is included in the NuGet here: https://www.nuget.org/packages/Emgu.CV.runtime.windows/

The DLL's are deployed if you select x86 or x64 (not AnyCPU).

Glosso answered 16/6, 2021 at 9:2 Comment(1)
If you are deploying via ClickOnce using version 4.1 with NuGet it gets a bit trickier. The DLLs are located in the source folder (for me it was: ...\Visual Studio 2015\Projects\MyProjectName\packages\EMGU.CV.4.1.1.3497\build) But, for some reason they didn't show up in the Application Files and thus weren't present in the ClickOnce installed folder. So I added those DLLs to my project and set them as "Content" and "Copy Always".Tade
M
2

I met the same problem as you. I wrote an application based on EmguCV3.1. It works well on my development PC, but once I copied a release version to another PC without installing any development tools, I got the error. And the test PC system environment is Windows 7 64bit.

Finally, I found that just copy all .dll files from your emgucv install dir such as: D:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x64 or bin/x86 to your release folder. These dll include cvextern.dll, msvcp120.dll, msvcr120.dll, opencvffmpeg310.dll. For 64bit system I copy the dlls from bin\64 folder.

For your situation, I advise you add the bin\x64 or bin\x86 folder dir to the system path environment.

Reference:

EmguCV official wiki about this problem But thers is no necessary to add so much dll for version 3.1.

And Try to check your configuration of emgucv as wiki said:

For Version 3.0+, the required vcrt dlls are included in the "x86" and "x64" folder. You will be ready as long as you copy all the unmanaged dlls in the "x86" and "x64" folder to the folder of executable.

Measureless answered 10/4, 2016 at 5:50 Comment(0)
T
1

The error occurred for me because of missing C++ runtime files on the target machine. They can be downloaded and installed from Microsoft.

Tattered answered 31/1, 2017 at 17:40 Comment(0)
G
0

Another issue I encountered (with the same symptom as cvextern not loading) running on Windows Server (in Azure Cloud) was a dependency on Windows Media Foundation. For what it's worth, this is not installed by default on Windows Server 2012. There are a couple remedies:

  1. Add the feature as described in this question about MF support on 2012
  2. Use Server 2016 (Family 5) (where MF is already installed)
Gen answered 8/3, 2018 at 15:8 Comment(0)
Q
0

This can be resolved by installing the library using Nuget Package Manager in Visual Studio 2019 Tools> NuGet Package Manager > Package Manager Console

you can use the following command to install fully

  • Install-Package Emgu.CV
  • Install-Package Emgu.CV.runtime.windows

And everything worked fine for me.

Quagga answered 18/9, 2021 at 13:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.