I am using Unity to develop programs for MS Hololens2. Here, I am going to use OpenCV (C++ DLL) for image processing.
In Unity, I changed the platform to Universal Windows Platform (UWP) and built it, and installed the Windows SDK and Hololens2 emulator. In order to develop a library using OpenCV, a DLL was created with a Universal Windows dedicated DLL project (C++). At this time, OpenCV proceeded using World.dll released from the official website.
However, if the emulator calls a function in the DLL, it throws an exception saying that it cannot be loaded.
There is no problem with how to create and build a DLL project for OpenCV. Because when I tested it without using OpenCV, it worked without any problems. Therefore, I thought I had to rebuild OpenCV World.dll using CMake, and even though I tried various things, it still didn’t work.
Of course, the Unity project also included OpenCV World.dll and built it. (I tried to exclude it, but it still didn’t work)
I searched for materials related to cross-compiling and tried to repeat it, but I couldn’t do it properly.
Are there any resources to reference? How can I do it?
OS: Windows10 (x64)
OpenCV: 4.5.0
Unity: 2019.4.22f1
Visual Studio: Visual Studio Community 2019
world.dll is an OpenCV DLL that is created when the OpenCV library is built. (same as opencv_world450.dll)
Refer to opencv_world.dll in “Universal Windows dedicated DLL project (C++)” and write only the algorithm part separately. Another project is correct.
This is a Qualcomm Snapdragon based Hololens2. It runs on Windows10 64-bit, but I know it as ARM64. I don’t have any equipment yet, so I’m testing it with an emulator.
HoloLens 2 emulator is x64. If you compiled the DLL to ARM64, then it will not be loadable in the emulator (but will work on the actual device).
You should compile the DLL to all architectures you want it to work on, and then put them in the Unity project and configure them accordingly in the plugin inspector.
Yes. So, when I made a DLL without OpenCV, I built it with x64 and tested it with an emulator.
I made a basic DLL and tested it, and when I made a DLL by adding only OpenCV in the same environment, it didn’t work.
Should I seek input from the OpenCV or the Hololens community?
• It is missing/not getting deployed correctly (you should be able to verify this by calling File.Exists() in your app);
• It is compiled for the wrong CPU architecture (looks like you already eliminated this reason);
• It is compiled in debug mode but you’re deploying the app in release mode;
• It references DLLs/APIs not available on the devices, and thus cannot be loaded. Usually, you’d troubleshoot it by enabling loader snaps, however, I don’t think that’s an option on HoloLens. Perhaps you can try using GitHub - lucasg/Dependencies: A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues. to see if anything sticks out?
Did you find the solution? I have the same problem.
Edit :
I have the dlls in Unity data folder in VS(in attached pic)
Will that be a problem? The file structure was built by Unity. I just had the plugins in the assets.Th eonl difference is I ma using Hololens 1 so it is x86 architecture.