artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
41 stars 22 forks source link

Windows plugin needs opencv DLLs. #21

Closed OptrixAU closed 1 year ago

OptrixAU commented 4 years ago

@ThorstenBux - Trying to upgrade an existing v5 project to X, and I've run into this issue.

Currently building for Windows.

I initially simply copied the files from the source version over my existing version (after ensuring I grabbed the Windows and Android binaries).

When that had the DLLNotFound exception, I then downloaded the latest release UnityPackage and installed it into my project. I did NOT include the items trying to install to C:\ drive, or the stuff from the Packaging system.

Still didn't work.

When I use Dependency Walker, it's indicating that it's looking for the OpenCV DLL files and not finding them (this can often trigger a "The Specified Module Could Not Be Found" error in Windows.) Did the Windows DLL somehow get compiled with dynamic linking against OpenCV instead of static linking?

OptrixAU commented 4 years ago

Just created a brand-new project, installed the UnityPackage, opened a sample - same problem, although the issue is a little clearer that it's specifically "Failed to load 'Assets/Plugins/x86_64/ARX.dll' because one or more of its dependencies could not be loaded" (Unity 2019 provides more detail than I was getting in 2018).

OptrixAU commented 4 years ago

Yes, it appears that the OpenCV DLLs are needed. They can be downloaded from https://github.com/artoolkitx/artoolkitx/releases in ARToolkitXForWindows.v1.0. Quite chunky, but then again OpenCV is a chunky beast.

This gets the DLL working and the camera turns on. In Unity 2019, the editor then immediately crashes.

Now trying 2018.4

Yaugan commented 3 years ago

I am also facing the same problem and by reading the comments I tried to add OpenCV as you said but now my Unity 2020, crashes. Do you have any idea @OptrixAU, how to resolve it?

OptrixAU commented 3 years ago

This was a while back, but if I recall correctly the issue ended up being an unsupported colour encoding.

The default colour encoding for a Windows camera was a really odd format that caused the library to crash. I had to force a more sensible format in the settings in ARToolkit.

Go to your AR Controller class in Unity and make sure the line below appears in your Video Config for Windows...

-format=BGRA -flipH

Yaugan commented 3 years ago

Hello @OptrixAU, Can you please mention where to change in Video Config for windows, as I am unable to find where to change it? Thankyou in advance

OptrixAU commented 3 years ago

You should have a GameObject somewhere in your Unity scene with the AR Controller behaviour on it. In my scene, the object is called ARFramework

You can even search for it - in Hierarchy (where you see all of the objects in your scene), type 'ARController' in the search bar at the top. This should highlight the object in your scene that contains the ARController behaviour.

Click on the object, and you'll findthe option you're looking for in the Unity inspector under Video Config. (Windows)

Yaugan commented 3 years ago

![Uploading 1.png…]()

Yaugan commented 3 years ago

I have done that but still getting this error

Yaugan commented 3 years ago

Hey @OptrixAU, So I have removed the OpenCV Dll files but when I reimported it and done what you said, the camera not starts in Unity Editor and I think everything is working fine, thanks to you. But when I build the same unity project for android, my app crashes again and again on my mobile, and I have tested this app in different mobiles just to make sure, but everything remains the same. Can you help me out, in that?

OptrixAU commented 3 years ago

Hmmm...best off looking at your Android Debug Log. It's usually pretty informative about what has caused an app to fail.

Search Google for "ADB Debug Unity" for an example of the command-line you need.

philip-lamb commented 1 year ago

Fixed by https://github.com/artoolkitx/arunityx/commit/7e0cd7f1b9b0cafaf54f714fe90dec99bedd45b3