我有带相机的简单android kivy应用程序。当我在kivy启动器(android 7.0)上运行该应用程序时,我仅看到按钮,而没有相机。当我用camera.export_to_png("image.png")
拍照时,它仅保存白色图像。代码:
from kivy.app import App
from kivy.uix.camera import Camera
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class cameraapp (App):
def build(self):
layout = BoxLayout(orientation='vertical')
self.cameraObject = Camera(play=True)
self.camaraClick = Button(text="Take Photo")
self.camaraClick.size_hint=(.5, .2)
self.camaraClick.pos_hint={'x': .25, 'y':.75}
self.camaraClick.bind(on_press=self.onCameraClick)
layout.add_widget(self.cameraObject)
layout.add_widget(self.camaraClick)
# return the root widget
return layout
def onCameraClick(self, *args):
self.cameraObject.export_to_png('image.png')
if __name__ == '__main__':
cameraapp().run()
此外,当我要设置分辨率时,它会崩溃(我只是粘贴错误日志的末尾):
File "C:\Users\user\Anaconda3\lib\site-packages\kivy\core\camera\camera_opencv.py", line 117, in init_camera
self._resolution = (int(frame.shape[1]), int(frame.shape[0]))
AttributeError: 'NoneType' object has no attribute 'shape'