Kivy Opencv安卓 [英] Kivy Opencv Android
问题描述
我正在尝试基于Kivy和OpenCv构建示例Android应用程序:
I'm trying to build an example Android app 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()
在桌面上运行此示例时,它运行良好,但是当我使用buildozer构建APK并尝试在手机上运行该应用时,该应用会立即打开和关闭.我的buildozer设置是:
When running this example on desktop, it works fine, nevertheless when I build the APK with buildozer and try to run it on the phone, the app opens and closes immediately. My buildozer settings are:
[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
如果我从代码中删除了"import cv2",同时又从buildozer中删除了cv2和numpy要求,则生成的apk在手机上运行良好.
If I remove the "import cv2" from the code and also remove the cv2 and numpy requirements from buildozer, the generated apk runs fine on the phone.
是否可以在Android设备上使opencv与Kivy一起使用? buildozer是否使用我的系统上安装的opencv版本(opencv 3)?
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)?
谢谢.
推荐答案
要解决在手机上运行apk时立即崩溃的问题,必须按以下方式设置buildozer.spec文件:
To solve the immediate crash when running the apk on the phone, the buildozer.spec file must be setup 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
由@Fins建议
谢谢.
这篇关于Kivy Opencv安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!