问题描述
我正在尝试构建一个基于 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 并尝试在手机上运行它时,应用程序会立即打开和关闭.我的构建器设置是:
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.
是否可以让 opencv 在 Android 设备上与 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 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!