【发布时间】:2021-04-30 02:12:39
【问题描述】:
基本上我有这个代码:
import time
from kivy.app import App
from kivy.uix.camera import Camera
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class MainWindow(App):
def build(self):
layout = BoxLayout(orientation='vertical')
# Create a camera object
self.cameraObject = Camera(play=False)
self.cameraObject.play = True
self.cameraObject.resolution = (300, 300) # Specify the resolution
# add camera and button to the layout
layout.add_widget(self.cameraObject)
# return the root widget
return layout
# Take the current frame of the video as the photo graph
def onCameraClick(self, *args):
self.cameraObject.export_to_png('hello.png')
print("Success")
if __name__ == '__main__':
MainWindow().run()
while True:
time.sleep(1)
MainWindow().onCameraClick()
它应该做的是:
- 运行窗口
- 在窗口中显示网络摄像头
- 使用网络摄像头反复拍照并保存为hello.png
它在做什么:
- 运行窗口
- 在窗口中显示网络摄像头
我的代码有什么问题?是否与尝试访问另一个类中的函数有关?或者它是一个参数错误?如果是,我在日志消息中看不到任何错误。
【问题讨论】: