The main purpose of this project is to show how to develop mobile applications with Python and explain the use of OpenCV and TensorFlow in this mobile application.
For detailed information: Kivy Documentation
sudo apt-get update
sudo apt-get install -y \
python3-pip \
python3sudo apt-get -y install python3-dev build-essential git make autoconf automake libtool \
pkg-config cmake ninja-build libasound2-dev libpulse-dev libaudio-dev \
libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-devsudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install python3-kivysudo apt-get install git libssl-dev cython3Note: If you get an error related to Cython, follow these steps:
cd /bin/ && sudo gedit cythonAdd this line to the opened file:
cython3 $@Then:
sudo chmod 755 cython cd ~
sudo git clone https://github.com/kivy/buildozer.git
sudo apt install -y git zip unzip default-jre default-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
cd buildozer/
sudo python3 setup.py installEnter your Python Kivy project and run the following command:
buildozer initThis command will create the buildozer.spec file. Add non-Python libraries (for example, TensorFlow or OpenCV) and file extensions like .tflite to this file so that these files are also included when the APK is created.
After making the necessary changes, you can start the APK conversion with this command:
buildozer --verbose android debugWhen the process is completed without errors, the generated APK file will be located in the "bin" folder. You can transfer the APK file to your Android phone and then install it.
Note: If the APK is successfully created but the application suddenly closes, does not open, or does not work at all after loading it on the phone, you can use the
adbtool to solve these errors. This tool allows you to see the operations, codes, and errors performed while the application is running on the terminal screen when you connect the phone to the computer via USB.
sudo apt install adbUSB debugging must be enabled in the developer options on your phone.
Connect the phone to the computer via USB and run the following command:
adb logcat -s pythonNote: If you are using a virtual machine and
adbdoes not detect your phone, turn off the virtual machine and try theadbcommand again.
You can monitor your application's steps on the terminal screen and view any errors here.
Bu projenin temel amacı, Python ile mobil uygulama geliştirmenin nasıl yapılacağını göstermek ve bu mobil uygulamada OpenCV ve TensorFlow kullanımını açıklamaktır.
Detaylı bilgi için: Kivy Documentation
sudo apt-get update
sudo apt-get install -y \
python3-pip \
python3sudo apt-get -y install python3-dev build-essential git make autoconf automake libtool \
pkg-config cmake ninja-build libasound2-dev libpulse-dev libaudio-dev \
libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-devsudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install python3-kivysudo apt-get install git libssl-dev cython3Not: Eğer Cython ile ilgili bir hata alırsanız, aşağıdaki adımları izleyin:
cd /bin/ && sudo gedit cythonAçılan dosyaya şu satırı ekleyin:
cython3 $@Ardından:
sudo chmod 755 cython cd ~
sudo git clone https://github.com/kivy/buildozer.git
sudo apt install -y git zip unzip default-jre default-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
cd buildozer/
sudo python3 setup.py installPython Kivy projenizin içine girin ve aşağıdaki komutu çalıştırın:
buildozer initBu komut, buildozer.spec dosyasını oluşturacaktır. Python dışındaki kütüphaneleri (örneğin, TensorFlow veya OpenCV) ve .tflite gibi dosya uzantılarını bu dosyaya ekleyin ki APK oluşturulurken bu dosyalar da eklenmiş olsun.
Gerekli değişiklikleri yaptıktan sonra şu komut ile APK dönüşümüne başlayabilirsiniz:
buildozer --verbose android debugİşlem hatasız bir şekilde tamamlandığında, oluşturulan APK dosyası "bin" klasörü içinde yer alacaktır. APK dosyasını Android telefonunuza aktarabilir ve ardından kurulumunu gerçekleştirebilirsiniz.
Not: Eğer APK başarılı bir şekilde oluşturulmasına rağmen, telefona yükledikten sonra uygulama aniden kapanıyor, açılmıyor ya da hiç çalışmıyorsa, bu hataları çözmek için
adbaracını kullanabilirsiniz. Bu araç, telefonu USB ile bilgisayara bağladığınızda, uygulamanın çalışma sırasında yapılan işlemleri, kodları ve hataları terminal ekranında görmenizi sağlar.
sudo apt install adbTelefonunuzda geliştirici seçenekleri kısmında usb hata ayıklama açık olmalı.
Telefonu bilgisayara USB ile bağlayın ve aşağıdaki komutu çalıştırın:
adb logcat -s pythonNot: Eğer sanal makine kullanıyorsanız ve
adbtelefonunuzu algılamıyorsa, sanal makineyi kapatıpadbkomutunu tekrar deneyin.
Uygulamanızın adımlarını terminal ekranında izleyebilir ve herhangi bir hata olduğunda burada görüntüleyebilirsiniz.
