15

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
  • 1,193
  • 2
  • 12
  • 27

3 Answers3

5

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

Community
  • 1
  • 1
AvielNiego
  • 1,193
  • 2
  • 12
  • 27
4

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 :)

Yoav Glazner
  • 7,936
  • 1
  • 19
  • 36
  • Thanks Yoav! I need something that I will be able to run from my other standard java Android apps, will it be possible? – AvielNiego Dec 28 '17 at 21:47
  • 2
    In that case try creating a kivy app as an android service https://blog.kivy.org/2014/01/building-a-background-application-on-android-with-kivy/ - – Yoav Glazner Dec 29 '17 at 11:27
1

Another option is https://termux.com, but you'll have a bit of hard time getting cv2 to work on it.

hyankov
  • 4,049
  • 1
  • 29
  • 46