Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 656
AvielNiego Avatar asked Dec 28 '17 16:12

AvielNiego


People also ask

Can you run OpenCV on Android?

To work with the OpenCV Android library, you have to add it to your app module as a dependency. To easily do this on Android Studio, click on File -> Project Structure. When the project structure dialog opens, click on the app module or any other module that you want to use OpenCV library in.

Can you run Python scripts on Android?

Python can run on Android through various apps from the play store library. This tutorial will explain how to run python on Android using Pydroid 3 – IDE for Python 3 application. Features : Offline Python 3.7 interpreter: no Internet is required to run Python programs.

Can we integrate Python with Android?

The easiest way to use Python in an Android appChaquopy provides everything you need to include Python components in an Android app, including: Full integration with Android Studio's standard Gradle build system.

How do I open a .PY file on Android?

py file! Enter some code here, then go to: Run > Run Module. You'll be prompted to save your file as a module (a compact piece of Python code that can be run from other scripts) and from there, your app will run! That is how to run Python files.


1 Answers

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

like image 105
hyankov Avatar answered Oct 08 '22 06:10

hyankov