OpenCVSharp on Hololens

Hello everyone.

I have been using this: GitHub - Firifire/OpenCvSharp-UWP: C# Wrapper of OpenCV for UWP applications ,to have OpenCv on Hololens.

It work with simple image effects, but when i’m trying to do face recognition, it only works in the Editor, but not in the Hololens.

It gives this error:
Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x021FF478

I want to use Vuforia and connect to SQL server as well.

Still in tests.

Best regards, Rafael Pereira.

What is the exception message? The thing you posted means somewhere in C# an exception is thrown.

I sent a report with the number: 1042099, so you can see what is happening.
Maybe i’m doing the image process wrong, or how i’m getting the image.
Gonna test a plugin for Hololens camera stream, in the next week.

The plugin only works for .net not for IL2CPP

https://github.com/VulcanTechnologies/HoloLensCameraStream

I understand the problem, it’s the path to the xml file that is not correct.
How do i define a path to StreamingAssets in Hololens?

public static string StreamingAssets(string path)
{
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
return Application.streamingAssetsPath + “/” + path;
#elif UNITY_WSA
return “ms-appx-web:///Data/StreamingAssets/” + path;
#endif
}

But it’s not working

Use Application.streamingAssetsPath. That should work.

It’s not working with Application.streamingAssetsPath.
I tested multiple ways.

Someone can help me in this?

Can you show your code?

lbpCascade = new CascadeClassifier(StreamingAssets(“face.xml”));
Txt = System.IO.File.ReadAllText(StreamingAssets(“face.xml”));
t.text = Txt;

public static string StreamingAssets(string file)
{
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
return Application.streamingAssetsPath + “/” + file;
#elif UNITY_WSA
return Application.streamingAssetsPath + “/” + file;
#endif
}

You should really use Path.Combine instead of concatenating paths like that. In either case, is that file really present on disk? Is it in Assets/StreamingAssets during build time?

I will try with Path.Combine.
Yes it is Assets/StreamingAssets, even in the build/deploy to the hololens. but since we don’t an explorer to see the files in hololens i don’t know for sure.

C:/Data/Users/DefaultAccount/AppData/Local/DevelopmentFiles/Template3DVS.Release_Win32.rafael.pereira/Data/StreamingAssets\face.xml

This is the path that i get with: Path.Combine(Application.streamingAssetsPath, file)

I have some log files from UnityPlayer.
One in IL2CPP other in .NET

3522707–281932–UnityPlayer (1).txt (209 KB)
3522707–281933–UnityPlayer.txt (278 KB)

Other option is to do all this in JS or Python with OpenCV in a REST service and database connection in a server. and return in JSON

Or use the new Microsoft face recognition.

Does ReadAllText throw FileNotFoundException?

It finds the file in the ReadAllText, the problem is in the OpenCvUWP.dll.

EntryPointNotFoundException: Unable to find an entry point named ‘objdetect_CascadeClassifier_newFromFile’ in ‘OpenCvUWP’.
at OpenCvSharp.CascadeClassifier…ctor (System.String fileName) [0x00000] in <00000000000000000000000000000000>:0
at Webcam.Start () [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

So maybe i will gonna all in a server.