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
Related
I'm developing an Android app and I have to use the openCV library.
I was wondering if the openCV python sdk is equivalent to the openCV4Android? I already have some openCV code written in Python - everything that can be done using Python can also be accomplished with Java for Android?
Thanks.
Although I used OpenCV Java SDK for both Android and Java projects, I am not sure whether it supports all functionalities of python library. You can check which parts of the library is included in Java SDK from the documentation
If something is included but not have detailed description, you can check out c++/python equivalent for explanations.
OpenCVForAndroid usually only has the modules in the OpenCVMain repository:
https://github.com/opencv/opencv
If you want more than this, for example the OpenCV extra modules below, then you generally have to build from source. OpenCV extra modules
https://github.com/opencv/opencv_contrib
It is worth noting also that at the time of writing most of the official openCV Android documentation is based on using the Eclipse IDE, while most official Android documentation uses the newer Android Studio.
There are also two main ways to use OpenCV on Android - one is to use the Java SDK as you have noted and the other is to build your OpenCV functionality in c++ using the Android native NDE. The former is generally easier if the Java SDK covers the functionality you need.
I think it is fair to say that getting the latest release of OpenCV with the extra modules compiled and working with Android Studio is not trivial at this time - if you look on Stackoverflow you will see quite a few questions and discussions around this topic, for example look at this question and answers:
Reg. Adding OpenCV to Native C code through CMake on Android Studio
I'm planning to take a photo using the smartphone camera, then make some image processing. In case the Java SDK does not cover the functionality I need, a solution could also be sending the image to a remote server, do the processing (using Python) and send the processed image back to the application. Am I missing something? (of course I increase latency)
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.
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.
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 am attempting to put my C++ program onto an Android phone but have run into several problems with the library linking. It seems most of the useful information I find on this topic through google is outdated (motz) or simply does not account for the complexity of my program. I have been able to run simple C programs but fail when attempting to use libraries outside of Android's Bionic/libc.
So my questions are:
Is it possible to port pre-existing *.so libraries onto Android? If so, how could I do this without seg faulting?
Should I be using the CodeSourcery compiler (arm-none-linux-gnueabi-*)?
How can I work around the lack of a seperate pthread library?
Please help me out! Thanks.
-Scott
You can't use pre-existing *.so files because they need to be compiled for Android. In order to create an *.so for Android you need to use their NDK, which is already set up to build the correct format so you don't need to worry about arm-none-linux-gnueabi or anything. If you want to use a library that isn't available on Android you'll need to build it yourself using the NDK. I had to do this with the STL.
Please refer to the following :
Can i use the native libraries (installed in android stack) in my NDK application?
This should answer you some queries...