Kivy Opencv Android

Kivy Opencv Android(Kivy Opencv Android)
本文介绍了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 并尝试在手机上运行它时,应用程序会立即打开和关闭.我的构建器设置是:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Change the style of AlertDialog(更改 AlertDialog 的样式)
Pop up dialog in Android home screen(在 Android 主屏幕中弹出对话框)
How to display an existing ListFragment in a DialogFragment(如何在 DialogFragment 中显示现有的 ListFragment)
When to use Android PopupWindow vs Dialog(何时使用 Android PopupWindow vs Dialog)
Android: Close dialog window on touch(Android:触摸时关闭对话框窗口)
Android - Executing a custom listview in a custom dialog properly(Android - 在自定义对话框中正确执行自定义列表视图)