OpenCV with Magic Leap 2

I have been trying to use OpenCV in Magic Leap2 using OpenCV Plus plugin. But when I run it shows OpenCVSharpExtern.so DLL file is not found kind error.

That's because by default OpenCV Plus plugin provides this .so files for ARM-abiv7 and X86 architecutres, and Magic Leap2 is works on X86_64.

I also faced same issue when deploying app in Android. But somehow I managed to find that file from unity forum for ARM64, and it worked.

Here is the code how that guy has generated .so file for ARM 64. GitHub - Gobra/OpenCV-Unity: OpenCV plus Unity

I used same code to generate .so file for X86_64 architecutre, but unfortunately it didn't work on Magic Leap2.

Can anyone help me with this?

A couple of questions:
When you say it didn't work, what errors were you getting when testing on the Magic Leap 2?
What changes did you make to the build script to build the x86_64 plugin ?
Have you considered using the OpenCV for Unity plugin that is available on the Unity asset store?

Error

DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.

What I did?

1.) Cloned this repo: GitHub - Gobra/OpenCV-Unity: OpenCV plus Unity
2.) Added necessary files -> did little bit changes to build for X86_64.
3.) Built the OpenCVSharpExtern.so file for X86_64.
4.) Copied to Asset -> plugins -> Android directory.
5.) From inspection changed in CPU, ARM64 to X86_64 and checked 'load on startup'.

Result

Still getting same error.

I didn't use OpenCV for Unity plugin rather have used OpenCV plus plugin.

Thanks for providing the details. Since we're not directly familiar with that specific library, I recommend posting your question on the GitHub repository page for further assistance from the maintainers or the community.

In the meantime, I suggest using Android Studio and creating a virtual x86_64 Android 10 device and deploying your application as a standard Android APK to this virtual device. This approach should help you isolate the issue and provide a controlled environment for testing the plugin. It might also allow the repository owner or other developers to test and debug the x86_64 architecture without needing a Magic Leap 2 device.

I can't test, because it says this
image

If you create a new Android application in Unity, without using Magic Leap SDK or any AR/VR components and build it for x86_64.

Then in android studio create a new virtual device
Tools >Device Manager
Then select the + button to create a new device
Then proceed through the Virtual Device Configuration to create an Android 10, x86_64 device without google play services

Alright, thank you! I'll test it out. By the way, you mentioned the OpenCVForUnity plugin—does it support ARUco markers?

I want to go with a custom OpenCV solution because the ARUco marker detection and the exact position provided by Magic Leap's official library don't seem to be very accurate.

If you could suggest any workaround for positioning markers with millimeter-level accuracy, I would really appreciate it. My ultimate goal is to accurately position the 3D model and anchor it to exact position with respect to marker, and when next time that marker will be scanned, then 3D model should be spawned at exact location where previously it was saved.

Thank you

Millimeter level accuracy might be difficult to achieve and can be highly dependent on the lighting and size of the marker you are trying to track.

Here is a link to the OpenCV for Unity plugin. Note, this is not a product endorsement. I only mention the package because we have seen developers use this plugin before.

Thanks!! OpenCVForUnity plugin has .so files needed to run on X86_64 architecture.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.