Running python script with Numpy and OpenCV on Android
Solution 1
The best solution for me was using steveliles's OpenCv for Android and converting the Python scripts to Java. Turns out opencv had all the mat calculation functions I needed
Another solution would be using chroot
:
https://technohackerblog.blogspot.co.il/2016/07/running-arch-linux-in-chroot-on-android.html
Solution 2
I would give a try to Kivy Launcher you'll have to build it with opencv and numpy support
please see: How to run OpenCV in Kivy Launcher? for details on that.
after the first build you'll have an app that can run your script and you won't have to generate the APK again, just change the script :)
AvielNiego
Updated on June 29, 2022Comments
-
AvielNiego almost 2 years
I have a complicated image processing script that runs in python with Numpy and OpenCV. I want to run this script in Android but I couldn't find a way to do it.
After some research I found some frameworks that may help but I have some problems with them:
- Kivy only generates full APK, but what I need is an AAR or some background service so I could use it from other apps
- QPython only runs scripts, I didn't find a way to communicate with it from my app
- cxfreeze I've tried to generate executable out of my script and then running it from my app, but I couldn't find a way to compile my script to an ARM processor so Android would be able to execute it
I will be happy to hear some ideas on how to run this script in Android. Is it possible to maybe root the device and install Python, Numpy and OpenCV?
-
AvielNiego over 6 yearsThanks Yoav! I need something that I will be able to run from my other standard java Android apps, will it be possible?
-
Yoav Glazner over 6 yearsIn that case try creating a kivy app as an android service blog.kivy.org/2014/01/… -
-
thadaBoy almost 5 yearsHi @AvielNiego How did you convert the python code to java?
-
AvielNiego almost 5 yearsIt was long ago, but I think that I just worked closely with OpenCV's docs
-
Lazik about 2 yearsI got it to install in termux by using pkg install opencv opencv-python