Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use it for Android? #43

Open
muxavir opened this issue Apr 14, 2021 · 4 comments
Open

Can we use it for Android? #43

muxavir opened this issue Apr 14, 2021 · 4 comments

Comments

@muxavir
Copy link

muxavir commented Apr 14, 2021

Thanks for awesome plugin. Can it be used for mobile phone (android)?

@danem
Copy link

danem commented May 3, 2021

Yes, it is usable on android.

First, you will need to download/compile opencv with opencv_contrib included. Then you need to build ArucoUnityPlugin linking to your android opencv build, and using the android toolchain. Finally you place the generated .so in your assets folder and specify that it should only be used on Android.

@muxavir
Copy link
Author

muxavir commented May 4, 2021 via email

@Surlix
Copy link

Surlix commented Jan 10, 2022

Heyho, I know it may be a bit late, but if anyone else stumbles over this and does not have as much experience with building from sources and building for android in general. I have struggled a bunch on this topic, here is what exactly you need to build arucounity from sources for Android(on Windows):

Download (Versions are very important):

(Only if you don't have it already --> Cmake Gui and MinGW installer )

Generate OpenCV MakeFiles with OpenContrib using AndroidToolchain:

  • Source Code: $SourceDirectoryOpenCVCore
  • Build directory: $BuildDirectoryOpenCV
  • Click Configure --> MinGW Makefiles --> Specify Toolchain file for cross-compiling --> "../android-ndk-r15c/build/cmake/android.toolchain.cmake" (change folder for your own folder structure)
  • Wait for Cofiguration to stop by itself with an Error (no SDK specified)
  • "ANDROID_HOME"=$ANDROIDSDK_FOLDER (change for your own structure)
  • "ANDROID_SDK_TOOLS"=$TOOLS_25.2.5_FOLDER (change for your own structure)
  • "OPENCV_EXTRA_MODULES_PATH"=".../opencv_contrib/modules/" (change for your own structure)
  • Disable BUILD_ANDROID_PROJECTS
  • Disable BUILD_ANDROID_EXAMPLES
  • Disable BUILD_PERF_TESTS
  • Disable BUILD_TESTS
  • optional: Disable all Extra Modules not needed (Needed: Calib3d and Ccalib), but don't disable core modules
  • Ignore warning about Cmake required Version. If you get errors here, switch cmake version to 3.22 or older (It worked with 3.22)
  • --> Configure
  • --> Generate

Generate ArUcoUnityPlugin MakeFiles linked with [Android OpenCV with OpenContrib] using AndroidToolchain

  • Source Code: $SourceDirectoryArUcoUnityPlugin
  • Build directory: $BuildDirectoryArUcoUnityPlugin
  • Click Configure --> MinGW Makefiles --> Specify Toolchain file for cross-compiling --> "../android-ndk-r15c/build/cmake/android.toolchain.cmake" (change folder for your own folder structure)
  • Wait for it to fail configuring
  • "OpenCV_DIR" = $BuildDirectoryOpenCV
  • "ArucoUnity_DIR" = $SourceDirectoryArucoUnity
  • --> Configure
  • --> Generate

Build OpenCV with OpenContrib using Android Toolchain:

  • open Terminal "cmake --build $BuildDirectoryOpenCV"
  • Wait for it to finish (make a coffee or something, that will take a while (30-60 Minutes maybe?)
  • finish

Build ArUcoUnityPlugin

  • open Terminal "cmake --build $BuildDirectoryArUcoUnityPlugin"
  • There may be a lot of Compiler errors.
  • Replace all ">>" with "> >" in the files with those errors.
  • It is not possible to break something with just pressing "replace all", I tried it.
  • finish

After this you got the needed "libArucoUnityPlugin.so" in $BuildDirectoryArUcoUnityPlugin
This all needs to be done in this order with these Versions of each part (maybe there is some other combination possible but it was really tedious to figure out)

@vinitsawant29
Copy link

Hi @Surlix, Thank you for the detailed steps.
I followed the steps and stumbled upon an error at the end of the step after replacing all the '>>' with '> >', saying
"No member named 'drawAxis' in namespace 'cv::aruco'.
The error occurred in "ArucoUnityPlugin-Master\src\aruco_unity_plugin.cpp" at line 65:18

Can you please suggest a turn around?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants