Kivy 相机不保存图片 android phone

Kivy camera does not save pic on android phone

此站点的代码对我不起作用:https://kivy.org/doc/stable/examples/gen__camera__main__py.html 它在我的电脑上完美运行。但是,当我使用

将其推送到我的 android phone 时
buildozer -v android debug deploy run

相机正常打开,当我按下 'Capture' 时,它就像拍照一样。但是,当我查看 phone 的画廊时,我找不到任何新图片。图片是否保存在画廊之外的某个地方?我的应用程序还有几个步骤可以将该图片上传到 google firebase。而且它永远找不到根目录中最近拍摄的照片。同样,它在 PC 上运行完美。我的 buildozer 规格是:

Permissionsandroid.permissions = INTERNET,CAMERA,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE

我试过 WRITE_INTERNAL_STORAGE 但不喜欢。所以我想默认情况下会给出写入内部存储权限。

另一个小问题:应用程序的屏幕向侧面翻转。它显示了正确的实时图片,但有点奇怪。我尝试在 Builder.load_string 中的 'vertical' 和 'horizontal' 之间切换,但没有任何变化。

请协助。感谢任何意见。

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import time
Builder.load_string('''
<CameraClick>:
    orientation: 'vertical'
    Camera:
        id: camera
        resolution: (640, 480)
        play: False
    ToggleButton:
        text: 'Play'
        on_press: camera.play = not camera.play
        size_hint_y: None
        height: '48dp'
    Button:
        text: 'Capture'
        size_hint_y: None
        height: '48dp'
        on_press: root.capture()
''')


class CameraClick(BoxLayout):
    def capture(self):
        '''
        Function to capture the images and give them the names
        according to their captured time and date.
        '''
        camera = self.ids['camera']
        timestr = time.strftime("%Y%m%d_%H%M%S")
        camera.export_to_png("IMG_{}.png".format(timestr))
        print("Captured")


class TestCamera(App):

    def build(self):
        return CameraClick()


TestCamera().run()````

我想通了。不知何故,根目录不起作用。要使其工作,只需更改

camera.export_to_png("IMG_{}.png".format(timestr))

camera.export_to_png("/sdcard/IMG_{}.png".format(timestr))