Pydroid 3 --I tried OpenCV and TensorFlow options for IDE for Python 3 (Android)

Pydroid 3 --IDE for Python 3 is Python that runs on Android, but is compatible with Python on your PC. Highly GUI programs such as tkinter can use the same source. It is recommended because you can write an app that can be used reasonably with just a smartphone. Furthermore, it seems to work with OpenCV and TensorFlow. Unfortunately, these libraries are paid options, but I applied for a 3-day trial.

Paid option application

There are two types of paid options: ・ Purchase ¥ 1160 ・ Monthly ¥ 110 Free for the first 3 days I decided to give it a try for 3 days. You can apply from the product. Click the icon on the upper left to open the side menu, and you will find the paid option application menu at the top. When you enter the application menu, you will see the above two option selection menus. Screenshot_20200913-074331.png Screenshot_20200913-074319.png Click "3 DAY FREE TRIAL" below. Screenshot_20200913-074343.png When you press the subscription, a personal authentication dialog will appear, so you can authenticate with your fingerprint. This completes the application.

Library installation

When the application is completed, the one grayed out in the library menu can be installed. Screenshot_20200913-075009.png I installed everything. tensorflow-2.2.0, opencv-python-4.3.0, torch-1.5.0 have been installed.

Sample program

You can download the sample program from Samples in the side menu. The ones that were grayed out can now be selected. Screenshot_20200913-210722.png Tensorflow MNIST It's a common one. It is a guy who downloads sample data and trains it. It's so slow that it's set to epoch = 5. It's hard just to turn it 5 times. The model seems to be able to use ordinary Keras sources. Screenshot_20200913-173630.png Image Classification Screenshot_20200913-173816.pngScreenshot_20200913-173924.png Text classification It seems to identify the clothing image. Finally, matplotlib will display the images and graphs. Screenshot_20200913-173816.png Screenshot_20200913-173924.png When I took this sample source to Windows and ran it, I was able to run it without changing a single line. Figure_1.png Regression Is the fuel consumption estimated from the specifications of the car and compared with the true value? Screenshot_20200913-174249.png The same source works on Windows as well. OpenCV Some older models could not download OpenCV. There are problems with the camera function, such as the camera not working on another model, or the operation is not stable even on a model that can use the camera. Hello camera The camera is not stable. It worked only once, but forgot to take a capture. When I tried it with Zenfone3 Max, the following message appeared and it did not work. It seems that the model must support the Camera NDK API. Screenshot_20200914-140205.jpg

When I run it on Windows, I get the following error.

[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (374) `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (386) `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (906) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772
[ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (906) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638
[ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (906) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638

Laplacian Again, the camera is not stable. It worked after doing it several times. Extract contours in real time. Screenshot_20200913-184729.png

Face detector This is stable because the capture method is different from the others. Detects faces in real time. Screenshot_20200913-185402.png The sample uses the front camera (1) for selfies, but if you set the camera number to (0), it will work on your PC. You need to install PyQt5. Screenshot_20200913-094118.png ASCII camera Again, the camera is not stable. If you take the doll on the right, it will be displayed in ASCII characters as shown on the left. Screenshot_20200913-184036.pngIMG_20200913_184053s.jpg

Camera options It seems to set the camera, but I'm not sure. Screenshot_20200913-233723.png

PyTorch Tensors Something seems to be working. Screenshot_20200913-234202.png MNIST It seems to be working, but it takes a lot of time. Epoch = 5, but it took about 30 minutes. Screenshot_20200913-234722.png

Pretrained model Download the image and determine what is in it. It took tens of seconds to judge even the downloaded image. Screenshot_20200913-081552.pngScreenshot_20200913-081711.png

Quantized model This camera seems to be stable. Identifies what is captured by the camera in real time. The stainless steel tumbler was judged to be a cocktail shaker, but it may be similar. Screenshot_20200913-192101.png

Summary

It's highly compatible and most samples work just fine on a PC. I'm worried that some OpenCV samples have unstable cameras, but there are some samples that move stably, so there seems to be a way to avoid them. If you want to use the camera with Pydroid3, you can shoot with another app and switch it immediately, or you can use this paid option to use the camera image in real time. However, if the model does not support it, nothing will happen.

You can learn models, but I don't think it will be practical because smartphones are slow. Taking a large amount of data and letting it learn in batch is not suitable for smartphones that take pictures, browse the net, receive calls, or have a lot of interruptions when they feel like it. It may be better to take data and photos on the go instead of at home and let them learn immediately.

It seems to be fun to be able to assemble a program on a smartphone. I have created such an environment (Android app for making apps, "PineVentor") before. However, it was quite difficult to develop with only a smartphone. Pydroid3 can use the same script on a PC, so it may be good to make it while going back and forth. However, at the moment there is no mechanism to easily walk around the script in various places, so it seems necessary to devise various things.

It's not enough to take a laptop with you on the go, but is it for people who want to program in their spare time to play puzzles or play games? It may be possible to collect deeper data if we can take data in the field and immediately make a time series graph. You can play a lot with the free Pydroid 3, so if you don't need to use the camera in real time, you definitely don't need the paid option, but I think it's worth a free 3-day trial. Depending on the model, the camera may not work, or if it is an old model, the entire OpenCV may not work, so even if you purchase it, you should try it.

Recommended Posts

Pydroid 3 --I tried OpenCV and TensorFlow options for IDE for Python 3 (Android)
I tried object detection using Python and OpenCV
I tried using Thonny (Python / IDE)
I tried tensorflow for the first time
I tried non-photorealistic rendering with Python + opencv
[ML-Aents] I tried machine learning using Unity and Python TensorFlow (v0.11β compatible)
I tried "smoothing" the image with Python + OpenCV
vprof --I tried using the profiler for Python
I tried web scraping using python and selenium
I tried "differentiating" the image with Python + OpenCV
I tried Jacobian and partial differential with python
I tried python programming for the first time.
I tried function synthesis and curry with python
I tried "binarizing" the image with Python + OpenCV
I tried Python on Mac for the first time.
I tried Python> autopep8
[OpenCV / Python] I tried image analysis of cells with OpenCV
I made a VM that runs OpenCV for Python
I tried python on heroku for the first time
python for android Toolchain
I tried to implement Grad-CAM with keras and tensorflow
I tried Python> decorator
I tried running TensorFlow
Python: I tried a liar and an honest tribe
OpenCV for Python beginners
I tried "morphology conversion" of images with Python + OpenCV
I tried [scraping] fashion images and text sentences in Python.
I tried porting the code written for TensorFlow to Theano
I tried "gamma correction" of the image with Python + OpenCV
I tried follow management with Twitter API and Python (easy)
How to learn TensorFlow for liberal arts and Python beginners
I tried face recognition from the video (OpenCV: python version)
I tried programming the chi-square test in Python and Java.
I created a class in Python and tried duck typing
Miscellaneous notes that I tried using python for the matter
I tried to enumerate the differences between java and python
I tried to make GUI tic-tac-toe with Python and Tkinter
[Python] Accessing and cropping image pixels using OpenCV (for beginners)
[For beginners] I tried using the Tensorflow Object Detection API
I tried fp-growth with python
I tried scraping with Python
OpenCV3 installation for Python3 @macOS
I compared Java and Python!
Python environment construction and TensorFlow
I tried Python C extension
[Python] I tried using OpenPose
I tried using magenta / TensorFlow
I tried gRPC with Python
I tried scraping with python
I touched Tensorflow and keras
I tried using the python module Kwant for quantum transport calculation
Create a striped illusion with gamma correction for Python3 and openCV3
[Pandas] I tried to analyze sales data with Python [For beginners]
I tried to display the video playback time (OpenCV: Python version)
I tried to make a periodical process with Selenium and Python
I tried to easily detect facial landmarks with python and dlib
I tried running the TensorFlow tutorial with comments (_TensorFlow_2_0_Introduction for beginners)
I tried to make an image similarity function with Python + OpenCV
Environment construction of python and opencv
Shining life with Python and OpenCV
I tried the TensorFlow tutorial 1st