The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Deploying a DLL to the HoloLens through Unity
I've been stuck on this for a few weeks now. I'm attempting to integrate OpenCV into my HoloLens project using this tutorial, and I do not believe that the Interop is working when it is deployed to the HoloLens.
When I run the game in Unity it correctly accessed the Init method and returns the correct value (-2, no camera stream to open). However, when deployed to the HoloLens it appears to get stuck in the Init function and does not move on to the next line.
- I have tried just having one OpenCVHoloLens.dll (x64), I now have two, one each in the x64 and x86 folders in the Plugins folder. They are compiled for the selected architecture.
- I have removed all OpenCV code from the method and rebuilt it to see if the OpenCV build was what was broken
- I have completely redone the tutorial several times
- Other projects (not using dlls) deploy and function in the HoloLens correctly
Function from the DLL source
extern "C" int __declspec(dllexport) __stdcall Init(int& outCameraWidth, int& outCameraHeight)
// Load LBP face cascade.
// Open the stream.
outCameraWidth = _capture.get(CAP_PROP_FRAME_WIDTH);
outCameraHeight = _capture.get(CAP_PROP_FRAME_HEIGHT);
Interop Function in Unity C# Script
internal static class OpenCVInterop
public static extern int Init(ref int outCameraWidth, ref int outCameraHeight);
internal static extern int Close();
internal static extern int SetScale(int downscale);
internal unsafe static extern void Detect(CvCircle* outFaces, int maxOutFacesCount, ref int outDetectedFacesCount);
Call in **same **Unity script. Renderers used for visual debugging
int camWidth = 0, camHeight = 0;
rend2 = box2.GetComponent();
rend2.enabled = false;
//FOUND BUG: UNABLE TO ACCESS OpenCVInterop methods
int result = OpenCVInterop.Init(ref camWidth, ref camHeight);
rend3 = box3.GetComponent();
rend3.enabled = false;
using System.Runtime.InteropServices; is included in the Unity script.
Error when run from Start with Debugging:
Exception thrown: 'System.BadImageFormatException' in Assembly-CSharp.dll
'OpenCVTest.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\OpenCVTestVS.Release_x86.vr\System.Diagnostics.StackTrace.dll'. Cannot find or open the PDB file.
BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at OpenCVInterop.Init(Int32& outCameraWidth, Int32& outCameraHeight)
at OpenCVFaceDetection.$Invoke3(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: Line: 0)
Setting up 1 worker threads for Enlighten.
Thread -> id: ea4 -> priority: 1
I apologize for formatting. The code indicator was not working correctly.