我有一个Unity项目,我必须在其中进行图像处理。我之所以选择使用C ++ Opencv 3.4,那么我创建了一个Visual Studio C ++项目,构建了一个通用Windows平台(UWP)DLL,并在我的C#脚本中将其包装+链接。它在Unity Editor中运行良好,具有以下架构Unity Project Plugin 但我无法在HoloLens和模拟器上部署应用程序。
我已经构建了opencv和我的dll的64位和32位版本。我已经设置Unity Editor使用64位版本和WSA平台使用32位,如下面的截图所示 Unity Plugin Settings x64 / Unity Plugin Settings x86。
我使用以下设置构建Unity项目Unity build。
当我进入visual studio并将应用程序部署到HoloLens时,我在我添加到项目中的每个自定义dll上都会出现以下错误
...
Loading opencv_highgui340.dll
Failed to load 'opencv_highgui340.dll', expected x86 architecture, but was Unknown architecture. You must recompile your plugin for x86 architecture.
(Filename: C:\buildslave\unity\build\Runtime/Misc/Plugins.cpp Line: 150)
Loading DocDetector.dll
Failed to load 'DocDetector.dll', expected x86 architecture, but was Unknown architecture. You must recompile your plugin for x86 architecture.
在HoloLens上部署和启动应用程序时会导致这种情况:
DllNotFoundException: Unable to load DLL 'DocDetector': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
请在下面加载并调用dll的C#脚本(以防万一):
// How I import the dll
internal static class OpenCVInterop
{
[DllImport("DocDetector")]
internal unsafe static extern double SimpleDocumentDetection(ref Color32 image, uint width, uint height, ref byte result);
}
// ...
// How I use it
unsafe
{
duration = OpenCVInterop.SimpleDocumentDetection(ref image[0], width, height, ref result[0]);
}
提前谢谢你;)