Search code examples
androidpythonnumpykivycx-freeze

Running python script with Numpy and OpenCV on Android


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?


Solution

  • 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