Move to using classes
This commit is contained in:
36
src/main.py
Normal file
36
src/main.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import picamui
|
||||
import picam
|
||||
|
||||
def main():
|
||||
captureResolution = (1280, 1024)
|
||||
captureDirectory = "./images"
|
||||
captureExtension = "jpg"
|
||||
|
||||
# Setup UI
|
||||
ui = picamui.PiCamUi()
|
||||
ui.createUi()
|
||||
|
||||
# Setup camera
|
||||
cam = picam.PiCam()
|
||||
cam.setPreviewResolution(ui.getScreenResolution())
|
||||
captureResolution = cam.getMaxResolution()
|
||||
|
||||
loop = True
|
||||
while loop:
|
||||
rgb = cam.getPreviewFrame()
|
||||
ui.updatePreview(rgb, cam.getPreviewResolution())
|
||||
ui.update()
|
||||
|
||||
uiEvents = ui.getEvents()
|
||||
for event in uiEvents:
|
||||
if event == "keyDownEscape" or event == "pygameQuit" or event == "btnExitPressed":
|
||||
loop = False
|
||||
elif event == "btnTakePressed":
|
||||
cam.capture(captureResolution, captureDirectory, captureExtension)
|
||||
else:
|
||||
print("Unknown event {}".format(event))
|
||||
ui.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user