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?
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
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 :)
Another option is https://termux.com, but you'll have a bit of hard time getting cv2 to work on it.
Related
I want to transform my python code into an Android app. The problem I saw is I'm using openCV in the code, and I didn't found anything related to generate an APK while using openCV.
There is a way to generate an APK from python and openCV?
There is SL4A / PythonForAndroid but unfortunately it uses hardcoded Java RMI invocations for anything os related. That means that there are no OpenCV bindings.
I guess you'll have to learn Java
I have some python scripts which are doing image processing work using its own numpy and scipy libraries. How can I use/call these scripts in Android application providing image input from camera captures and saving the images after processed. Is there some native support for Python like C++. What performance implications would be there if I compare with using C++ as a native support. Any help would be greatly appreciated.
You can use QPython to run python scripts in android. It's a powerful program. Or use Kivy to develop cross platform apps with python. And a better solution is http://code.google.com/p/android-python27/ an embeded python iterpreter!!
Try Pydroid, the best IDE on Android, autocompletion and code analysis works awesome, supports most of the libraries you need
You need a Python Interpreter to run Python scripts,Pydroid Gives you access to compile Python scipts and comes with pip,So you could Install new Python Modules,it's the only app that gives a real Experience of Programming using python.
It's known you can run Python on Android with QPython, but first users have to download and install it on their phone.
Just wondering: is it possible to pack QPython dependencies together with "app" script creating a "standalone" PlayStore-ready .apk?
It's not a direct answer to your question, but you can create totally standalone apks with the graphical framework kivy, or specifically kivy's android build tools. They only directly support apps with a kivy gui, but this is easy to construct if you just want to run a simple script.
Alternatively, I think you actually only need to put your code in a kivy App class, which will run the script but then immediately exit if you don't define any graphics. Maybe this is exactly what you want.
I need to have some code to do some image processing in an existing Android app written in java. Currently my code is written in Python with OpenCV, and running on a PC.
Now I need it too run in the said app too.
I tried running it via sl4a with py4a, which for simple python scripts is OK, but I need to use OpenCV, and couldn't figure how to format it for py4a. (Any idea how to do this?)
What are my options for running Python code using OpenCV inside of an existing Java Android app?
I don't know whether i make sense or not. But just wanted to now that can i run the c/c++ code in android without the need of writing JNI wrapper or using Native Activity way?
I mean, I am having a simple C++ Template Matching code which contains main function and I use to run it using g++ in terminal.
Now I want this Template Matching code to be run in android usng NDK. Is there any way? I have googled a lot but all they is to either use JNI wrapper or use SWIG which makes JNI wrapper, but can't actually get into any of them. I need more simpler solution.
If you have a rooted phone, you can compile and run programs as on any linux machine, from the adb shell.
However, that requires a bit of knowledge about Linux.
So, to start:
Root your phone (force it to give you admin privileges). That is easy for developer phones/boards, and a kill for regular phones bought at a shop downstreet.
compile your app for android and run it from adb as you would do from a linux shell.
Here is a more detailed answer on the matter
How to compile C into an executable binary file and run it in Android from Android Shell?