1

I'm an EMGU/CV noob using using EMGU3.0 (emgucv-windows-universal 3.0.0.2157), Visual Studio 2013, and a target platform of "Any CPU". I'm trying the C# "hello world" app at http://www.emgu.com/wiki/index.php/Hello_World_in_CSharp#Hello_World_-_Version_2 which looks like this:

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;

...

//Create a 3 channel image of 400x200
using (Mat img = new Mat(200, 400, DepthType.Cv8U, 3)) 
{
   img.SetTo(new Bgr(255, 0, 0).MCvScalar); // set it to Blue color

   //Draw "Hello, world." on the image using the specific font
   CvInvoke.PutText(
      img, 
      "Hello, world", 
      new System.Drawing.Point(10, 80), 
      FontFace.HersheyComplex, 
      1.0, 
      new Bgr(0, 255, 0).MCvScalar);

   //Show the image using ImageViewer from Emgu.CV.UI
   ImageViewer.Show(img, "Test Window");

}

It builds OK. But when I ran it I got "The type initializer for 'Emgu.CV.MatInvoke' threw an exception." . . . at the line . . .

using (Mat img = new Mat(200, 400, DepthType.Cv8U, 3))

Also, in the output window there's another clue. Just before the exception there's a message about unmanaged modules . . .

No suitable directory found to load unmanaged modules

A first chance exception of type 'System.TypeInitializationException'
occurred in Emgu.CV.dll

Any idea what's happening here or how to debug it?

Note: There's a question on SO OpenCV Unmanaged DLLs not found asp.net that involves a different error message - "System.DllNotFoundException" under different circumstances, (it also has no accepted answers). That error message is produced by the system but I think the one I'm getting is produced by EMGU itself. But if any ENGU experts see how that applies to mine I'd appreciate it.

Community
  • 1
  • 1
user316117
  • 7,971
  • 20
  • 83
  • 158

1 Answers1

1

The Emgu cannot find the OpenCV dlls. Simplest solution :

  • Go to your Emgu installation , the bin folder
  • Find inside the folders x86 and x64
  • Copy these folders to the bin\Debug bin\Release folder of your project.
  • Try again.
Mif
  • 632
  • 7
  • 7