I have made an small non-comercial Py program that performs some simple OCR tasks, it works well enough in both Windows and Linux systems, but the usage doesn't feel right, i figured out that it would be much better running on an Android device.
The problem is i have almost 0 knowledge of Java (i'm just learning) so i would like to "reuse" my Python code.
So to be precise, my question is:
Is it possible to port my Python 3.9 program that uses [opencv 2, Tesseract 5, PyQT5, pandas, numpy and matplotlib] to an Android device?
If so, i would really appreciate some pointers in the right direction.
I have done my fair share of googling and found out about Kivy but also about pyqtdeploy, now im not sure if i should just trash the PyQT5 code and replace it with Kivy.
Also the more puzzling matter for me is Tesseract, seems logical that it should work on an Android device, but in the desktop i had to install Tesseract executable and have no idea how to do that on Android, also i have a .traineddata file i really need would it also work on Android?
Well, i think that's more than enough questions for a first timer.
Thanks in advance
Related
I have written a small program in python and QT5. I want it on raspberry PI as a single application. I have checked out buildroot and yocto but can't seems to find a single tutorial which can explain the steps from compiling the python code and make it part of buildroot/yocto. Can anyone please guide me or point me to a tutorial.
Regards,
In Buildroot, there are two ways that you can add your own Python code to the build.
Using a root filesystem overlay to add you python files in the appropriate place in the root filesystem. This has a lot of limitations though: it doesn't get byte-compiled, you have to make sure yourself that it gets installed in some location in PYTHONPATH, and generally it's a bit more difficult to maintain. However, it's a very simple approach for a first try.
Creating a custom python package. It's also not really complicated to do that, but you really do have to read the documentation.
I am just a newbie on that things and I want to turn python to apk with android studio or whatever. I don't really need anything to complex, I just want to open my codes output gui (I used turtle) when I open the app. Nothing else, thats all. It is probably complex process so you can just give me where to look and learn if you can't explain it all in here. Thanks!
Turtle is built around TKinter, which is a library for making desktop apps. There doesn't seem to be a way to run programs built in TKinter within Android without using some other app to run them. If you're ok with that, then you could use the solution suggested by this answer to run your code by pasting it into an app that can run Python code.
I am new on Linux, OpenCV and deep learning, in fact I just started with these things a couple weeks ago.
In my reserches I found a lot of people saying that is much better use OpenCV on Linux than on Windows, so, that is what I am doing. I installed an Ubuntu distro on a VM and I am using it to study.
But today a doubt came up into my mind. It would be possible to write an OpenCV app on Linux and use it on Windows? I've read a lot and I couldn't find a satisfatory answer.
Maybe this is a silly question, but as I said, I am very new on all of that stuff.
For now, I am just studying and I am really feeling like learning Linux, but when I'll really start to build my applications it will be important to being able to run them on Windows.
So, if this is possible, is there some specific things that I should do to make the trasition easier?
There is absolutely no difference in the syntaxes of opencv between different operating systems. (Well, I used both and didn't bother me.) So it should be fine as long as you have the same version of Opencv installed as there are differences between opencv 3x and opencv 4x.
I am wondering what options I have to speed up kivy after I package it.
I was looking into cython and pypy because those should speed up python. Also, I was reading that kivy can be a little slower and bigger than most android applications because it includes python and the interpreter. I usually just search around forever until i find an answer but it can be hard to find things about kivy.
Can anyone with experience recommend something to get better speeds out of this framework? I'm dealing with a lot of code so it could be cumbersome testing a lot of this stuff out.
edit: 132137
asked Nov 24 '17 at 19:13
I have a lot of this application packaged now. I wouldn't so much worry about cython until you are packaging it. I would also try to package the application incrementally to make sure everything works. More than anything, I was just really worried about how things would go when I started packaging it. I should have started earlier. The size hasn't been too much of an issue. I would try and write it on ubuntu or a linux distribution(buildozer doesn't work with windows) and not everything will run the same cross all platforms(I had some issues with some of the modules I was working with). I love kivy this is like an eli5 thing I wish I'd known at the time.
After messing around with it some I got it down to 16mb. So I'm really happy with the framework. I guess i didn't need to include the buildozer folder in the build. I'm new to programming but I'm pretty happy with how everything turned out.
When it comes to responsiveness, make sure your python code is optimised. That means doing things like not loading Screens or other widgets until you need them (or even doing it in the background as much as possible).
For speeding up python itself, the main supported method is cython. python-for-android does not support pypy.
kivy can be a little slower and bigger than most android applications because it includes python and the interpreter.
A basic Kivy-using APK is about 7MB. And the delay from starting the interpreter manifests largely during the startup of the application, which can take a few seconds, especially on older devices.
I am running OpenCV2.2 on Windows 7 64-bit.
I built OpenCV using cmake with MinGW 32-bit.
I have no problem with the C/C++ build. However the python bindings seem to have some problems. Most of the python samples are crashing.
The HighGui functions seem to cause trouble. Python crashes when I try to read an image (using imread, LoadImage or LoadImageM), display an image (imshow or ShowImage) or even create and manipulate windows (NamedWindow, MoveWindow, etc).\
WaitKey doesn't crash python but it always returns a -1 immediately, no matter how long the delay I provide. Similarly imgproc functionality listed under "Image Filtering" in the reference seem to crash python. I haven't been able to test it with too many other functions, mainly because I can't load in images and I am forced to test it with matrices i have built myself.
I am currently using python 2.6.6 (32-bit) , but I got the same problem with python 2.7 (32-bit). I also tried building the python wrappers for OpenCV2.1, and I got the same problem. It's very likely a problem specific to my setup. I've been cracking my head against this problem for quite some time now, I would appreciate any help.
Thanking you in advance.
Regards,
Anush.