且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#应用程序中调用opencv c ++代码

更新时间:2023-02-07 20:24:17

我将显式导出将入口点包装在C ++头文件中的方法,然后使用P/Invoke引用它们:

I would explicitly export methods that wrap your entry points in a C++ header, and then use P/Invoke to reference them:

extern "C" __declspec(dllexport) BOOL DoSomething();

然后在C#中使用它们:

Then consume them in the C#:

[DllImport("MyOpenCVWrapper.dll")]
private static extern bool DoSomething();

我不会尝试引用OpenCV标头.

I wouldn't try to reference the OpenCV headers.