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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)