Kivy Opencv Android

I am trying to create an example Android application based on Kivy and OpenCv:

import kivy from kivy.uix.button import Button import cv2 kivy.require('1.0.6') from kivy.app import App from kivy.uix.label import Label class MyApp(App): def build(self): return Button(text='Hello!', background_color=(0, 0, 1, 1), font_size=150) if __name__ == '__main__': MyApp().run() 

When I run this example on the desktop, it works fine, however, when I create the APK with the collector and try to run it on the phone, the application opens and closes immediately. My settings:

 [app] title = MyTest package.name = kivycrash2 package.domain = org.test source.dir = . source.include_exts = py,png,jpg,kv,atlas version = 0.1 requirements = kivy, numpy, cv2 orientation = landscape 

If I remove "import cv2" from the code, and also remove the cv2 and numpy requirements from buildozer, the generated apk works fine on the phone.

Is it possible to make opencv work with Kivy on an Android device? Does buildozer use the opencv version installed on my system (opencv 3)?

Thanks.

+2
source share
1 answer

To solve the problem of instant failure when starting apk on the phone, the buildozer.spec file should be configured as follows:

 [app] title = MyTest package.name = kivycrash2 package.domain = org.test source.dir = . source.include_exts = py,png,jpg,kv,atlas version = 0.1 requirements = kivy, numpy, opencv orientation = landscape 

as suggested by @Fins

Thanks.

+4
source

Source: https://habr.com/ru/post/1272521/


All Articles