Run python + opencv + tensorflow in android

470 views
Skip to first unread message

Marcelo

unread,
Jan 10, 2019, 1:41:14 PM1/10/19
to Kivy users support
Hello everyone!

I am starting to do some programming in the computer vision field. I have a python code which runs opencv and tensorflow to do some object detection.

What is the best way (for a beginner) to run this code in an android app?

Thanks a lot :D

Will Tejeda

unread,
Jan 10, 2019, 5:54:32 PM1/10/19
to kivy-...@googlegroups.com
Following, as I'm looking to do something with this 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/7b87ddf1-9fe2-428f-af81-2bf65ffa8918%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Flatt

unread,
Jan 10, 2019, 7:35:33 PM1/10/19
to Kivy users support
Most people try to use Python-forAndroid, it is not exactly push button, and a work in progress.
Be aware  beginners sometimes crash and burn.
P4a is a wonderful thing if it works for you.

P4a only ports Python code to Android, though it is possible to link ARM object files, for example:
Quite a few Python packages are written in some other language underneath, this requires special handling.
The special handing in p4a is called a recipe, This is the current list:

Tensorflow is not in this list and is written partly in C++ and CUDA .
The assumption of "python code" in the question may not be a good one.

So Tensorflow probably requires writing a p4a recipe.......look at a few examples to see if you want to do this.

Congratulations on looking before you leap, so many people don't :(

One more thing:

Tensorflow presumably does lots of floating point, sometimes on graphics cards for performance.
Intel architectures have had basically the same FP for 40 years.
It might be worth checking which ARM implementations have the FP horsepower you need.
Might not be be an issue.......?

Robert Flatt

unread,
Jan 11, 2019, 4:49:37 PM1/11/19
to Kivy users support
It occurs to me there is another approach.
Think of tensorflow as a hardware resource, on a Pixel this is physically true.

P4a allows access to custom hardware in Java via jnius.
So replace your Python-ish tensorflow package with a Java one (which automatically calls compiled C++)

Don't expect this to just work, try small test cases, jnius checks nothing.

Sai Maithreya

unread,
Jul 15, 2020, 6:15:16 AM7/15/20
to Kivy users support
you were able to do this?
Reply all
Reply to author
Forward
0 new messages