Docker Community Forums

Share and learn in the Docker community.

EmguCV on Windows Server 2016 Core Image


(Jeroenvdz) #1

Client:
Version: 17.06.2-ee-6
API version: 1.30
Go version: go1.8.3
Git commit: e75fdb8
Built: Mon Nov 27 22:46:09 2017
OS/Arch: windows/amd64

Server:
Version: 17.06.2-ee-6
API version: 1.30 (minimum version 1.24)
Go version: go1.8.3
Git commit: e75fdb8
Built: Mon Nov 27 22:55:16 2017
OS/Arch: windows/amd64
Experimental: false

Container is based on microsoft/windowsservercore

Hi,

We are moving our build process to a Docker container.
(mostly MSBuild)
That is now all working fine, but we also run some unit-tests during the build and those fail in the Docker container. The thing is that we test our machine vision algorithm and that uses EmguCV. (based on OpenCV 3.x)

The build script run fine on the host OS (Windows Server 2016) but fails inside the container:
System.TypeInitializationException : The type initializer for ‘Emgu.CV.CvInvoke’ threw an exception.
----> System.DllNotFoundException : Unable to load DLL ‘cvextern’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Emgu.CV.Image`2…ctor(String fileName)
at RPR_Image_Evaluation_UnitTests.ReactivityTests.Test1ReactiveWells()
–DllNotFoundException
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke…cctor()

I already tried this: https://withinrafael.com/2017/09/09/windows-container-app-compat-opencv-python/
But that did not help in my case.

Does anyone has a suggestion on how to get this working?

Best Regards,

Jeroen Vandezande


(Charka) #2

Try to copy these libraries from host folder C:\windows\system32 into the same folder in the container.

  • avicap32.dll
  • avifil32.dll
  • ddraw.dll
  • glu32.dll
  • ksuser.dll
  • mf.dll
  • mfcore.dll
  • mfplat.dll
  • mfreadwrite.dll
  • msacm32.dll
  • msvfw32.dll
  • opengl32.dll

Assuming 64-bit usage here, adjust accordingly. I have tested it with

  • EmguCV Nuget package Emgu.CV -Version 3.4.1.2976
  • Test container based on microsoft/dotnet-framework:4.7.2-runtime-windowsservercore-ltsc2016
  • Host Windows Server 2016

Alternatively, in OpenCV wrapper OpenCvSharp3, this subset of libraries is sufficient:

  • avicap32.dll
  • avifil32.dll
  • msacm32.dll
  • msvfw32.dll

Tested with Nuget package OpenCvSharp3-AnyCPU -Version 3.4.1.20180319

See here how to add the DDLs to an image. For getting deeper into detecting such dependencies a tutorial by Stefan Scherer and its comments are very useful.