Codecs and Streaming
Once you have a frame you often want to get it off the board: preview it on a host, record it, or stream it live. ESP-VISION offers several codecs and transports, each suited to a different use case.
Still-image codecs: JPEG and PNG
image.Image.to_jpeg() (and its alias image.Image.compress()) encodes a frame to JPEG. JPEG is lossy: the quality keyword (1-100) trades size for fidelity, and subsampling controls how aggressively chroma is reduced (JPEG_SUBSAMPLING_420 is smallest, 444 is best quality). On boards with a hardware JPEG encoder this is offloaded; otherwise a software encoder (esp_new_jpeg) is used.
Current firmware does not enable the PNG decoder or encoder. Loading a PNG with image.Image(path) raises OSError immediately; image.Image.to_png() and saving an uncompressed image to .png raise RuntimeError. Convert PNG assets to JPEG before uploading them.
Recording sequences: ImageIO
imageio.ImageIO records a sequence of frames with their inter-frame timing preserved, so playback runs at the original speed. A file stream writes a container on storage; a memory stream keeps frames in a pre-allocated PSRAM buffer for fast capture and replay. See image.ImageIO – Image Stream.
Host preview: USB CDC
During development the quickest way to see what the camera sees is image.Image.flush(), which pushes the current frame to the host as a binary JPEG on the EV-MUX preview.frame channel. The companion host tool decodes and displays it. This path needs no Wi-Fi and no SD card, making it the default feedback loop while iterating on a script.