【发布时间】:2019-08-21 15:10:20
【问题描述】:
此站点的代码对我不起作用:https://kivy.org/doc/stable/examples/gen__camera__main__py.html 它在我的电脑上完美运行。但是,当我使用
将其推送到我的 android 手机时buildozer -v android debug deploy run
相机正常打开,当我按下“拍摄”时,它就像在拍照一样。但是,当我查看手机的图库时,我找不到任何新图片。图片是否保存在画廊之外的某个地方?我的应用还有几个步骤可以将该图片上传到 google firebase。而且它永远无法在根目录中找到最近拍摄的照片。同样,它在 PC 上运行良好。我的构建器规范是:
Permissionsandroid.permissions = INTERNET,CAMERA,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE
我尝试了 WRITE_INTERNAL_STORAGE,但它不喜欢它。所以我猜默认情况下会写入内部存储权限。
另一个小问题:应用程序的屏幕向侧面翻转。它显示了正确的实时图片,但有点奇怪。我尝试在 Builder.load_string 中的“垂直”和“水平”之间切换,但没有任何变化。
请帮忙。我很感激任何意见。
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()````
【问题讨论】:
-
我认为它可能只是保存到某个文件中。不确定在哪里。尝试保存图像之前和之后当前目录中有哪些文件?
标签: android python-3.x camera kivy buildozer