Webcam viewer

A camera app in 50 lines: examples/audio/webcam.py.
python examples/audio/webcam.py # the default camerapython examples/audio/webcam.py test # moving color bars, without a cameraSnapshot saves the current picture as a PNG next to the script, Pause freezes it.
from pyzed import camera, ui
cam = camera.Camera(0, width=1280, height=720, mirror=True)cam.start()
def view(self): return pz.column([ ui.camera.Webcam(camera=cam, width=720, height=405, radius=10), ui.button("Snapshot", lambda: cam.snapshot("photo.png")), ])The camera is read on its own thread; each new picture asks the window to redraw, so the app
needs no timer. It uses OpenCV when it is installed (pip install opencv-python), else the
ffmpeg program, else the test pattern. See Webcam for every
option.