2

我已经在我的项目中使用 NuGet 管理器安装了最新的 OpenCVSharp 2 (2.4.10.201...)。有关 OpenCVSharp.CvMat 的一切工作正常(加载、操作等),所以我确信安装是正确的。

但是我根本不能使用 OpenCVSharp.CPlusPlus!我试图简单地创建一个 Mat 但无济于事:

using OpenCvSharp;
using OpenCvSharp.CPlusPlus;
using MyCVSharp;
using System.Diagnostics;
using System.Collections;

class MainClass
{
    static void Main()
    {
        Mat test3 = new Mat( new Size( 100, 100 ), MatType.CV_8UC1 ); // ERROR
        Mat test2 = new Mat( "f1.png", LoadMode.Color ); // ERROR

        CvMat test = new CvMat( "f1.png", LoadMode.Color ); //; THIS WORKS

错误是:

MyCVSharpTEST.exe 中出现“System.TypeInitializationException”类型的未处理异常

附加信息:“OpenCvSharp.CPlusPlus.Mat”的类型初始化程序引发了异常。

许多 dll 与我的项目一起部署。OpenCvSharp.CPlusPlus.dllOpenCvSharp.dll部署在MyCVSharpTEST.exe旁边的同一个文件夹中,而 dll 文件夹由 x86 和 x64 子文件夹创建,每个子文件夹包含另外 22 个相关的 dll。

我什至尝试从已经创建的 CvMat 创建一个 Mat,但仍然是同样的错误。

编辑: 从 try-catch 块显示的错误:

System.TypeInitializationException: The type initializer for 'OpenCvSharp.CPlusPlus.Mat' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at OpenCvSharp.CPlusPlus.NativeMethods.core_Mat_sizeof()
   at OpenCvSharp.CPlusPlus.Mat..cctor()
   --- End of inner exception stack trace ---
   at OpenCvSharp.CPlusPlus.Mat..ctor()
   at MainClass.Main() in C:\Users\kotsias\Documents\Visual Studio 2015\Projects\MyCVSharp\ConsoleApplication1\Test.cs:line 14

由于这个问题现在似乎与 dll 有关,我决定写一个关于它的全新问题

4

0 回答 0