Course materials · Microprocessor Applications

Camera capture

English translation

Uses Picamera2 on Raspberry Pi OS. If it is not installed in the OS, run sudo apt install python3-picamera2 in a terminal.

Captured file: image.jpg in the folder where you ran the notebook.

from pathlib import Path
from time import sleep
from picamera2 import Picamera2
output = Path('image.jpg')
with Picamera2() as camera:
    camera.configure(camera.create_still_configuration())
    camera.start()
    sleep(5)
    camera.capture_file(str(output))
print(output.resolve())