Friday, February 4, 2022

[SOLVED] Deploying OpenCV on Raspberry Pi 4 - The type initializer for 'Emgu.CV.CvInvoke' threw an exception

Issue

I am trying to connect my Kinect v1 to my Raspberry Pi 4 (ARMv7) using C#. I am coding under Windows 10 with VS 2019.

With NuGet I installed the Emgu.CV.runtime.windows package as it was suggested here. However upon executing my code I get this error:

The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'cvextern' or one of its dependencies.

As suggested in other threads, I placed the necessary .dlls out of the x64 dll-folder in the folder of the executable in my Pi. I still get this error. Any suggestions?


Solution

With Emgucv, the primary purpose of the library is to be a c# wrapper of the c++ library opencv. In order to make this work, you need the runtime package for the platform that you are coding on to be included in the references.

As of Febuary 2020, you will have to build the native binary for the Raspberry pie.

You can read more about the issue below.

https://github.com/emgucv/emgucv/issues/298



Answered By - Aaron Jones
Answer Checked By - Cary Denson (WPSolving Admin)