Source code for src.camera

from typing import TypedDict
from picamera2 import Picamera2
import numpy as np


[docs] class Config(TypedDict): # show_preview=True only works when having a graphical connection to the pi show_preview: bool
[docs] class Camera: cam: Picamera2 image_array: np.ndarray def __init__(self, config: Config): self.image_array = np.ndarray(0) try: self.cam = Picamera2() self.cam.start(show_preview=config['show_preview']) except: self.cam = None
[docs] def capture(self): if self.cam != None: self.image_array = self.cam.capture_array()