wpf 应用程序中的异常

An exception in wpf application

我需要将位图图像转换为矢量图像,这是我的代码:

VectorImage = new Image<Bgr, byte>(CamImage);

其中 CamImage 是位图,我有这个例外:

An exception of type 'System.TypeInitializationException' occurred in Emgu.CV.dll but was not handled in user code

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

发生这种情况的原因可能是您没有将所需的非托管 dll 复制到应用程序 exe 旁边。

如果您通过 nuget 下载 EmguCV,您将在 packages 文件夹中看到一个 lib 和一个 opencv 文件夹。您必须将 dll 复制到应用程序 exe 旁边的 opencv 文件夹中。

Check the documentation,它列出了可能的原因。