从内部存储kivy python加载图像 [英] Loading images from internal storage kivy python

查看:91
本文介绍了从内部存储kivy python加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关通过我的kivy应用程序从内部存储文件管理器加载图像的解决方案.

I am looking for a solution regarding loading images from internal storage file manager via my kivy application.

为了进行测试,我需要从内部存储中选择图像,然后使用opencv将其转换为灰度图像.

for testing,i need to select the image from internal storage and then convert it into gray scale image by using opencv.

我尝试了filechooserlistview,但是我无法访问内部存储.

I have tried filechooserlistview,but however i could not access my internal storage.

我还在buildozer.spec文件中添加了以下提到的行. android.permissions = READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE

I have also added below mentioned line in my buildozer.spec file. android.permissions = READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE

最近两天我一直在寻找这种解决方案,但我没有得到任何合适的结果.

i'm searching for this solution for the last two days but i didn't get any proper result yet.

如果有的话,请共享代码. 预先感谢

Please share the code if anything you have. Thanks in advance

推荐答案

在较新的Android系统中,用于访问存储的buildozer权限请求不适用于kivy.
要获取这些权限,您必须通过以下方式在您的应用程序中要求它们:

In newer Android systems, the buildozer permission request for accessing the storage is not working with kivy.
To acquire these permissions you have to ask for them in your app by:

from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE,
                     Permission.READ_EXTERNAL_STORAGE])

...,系统将要求用户使用您的应用访问存储.
android库包含在buildozer版本中,因此您只需要执行此请求即可.

... and the user will be asked to your App to access the storage.
The android library is included in the buildozer builds, so that request is all you have to do...

要获取内部存储路径:

from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()

请注意,这是系统的虚拟(内部)SD卡.

Note that this is the virtual (internal) SD card of the system.

这篇关于从内部存储kivy python加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆