# nimnaw/esp-vision architecture

> Architecture diagram of the GitHub repository nimnaw/esp-vision, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nimnaw/esp-vision
- Repository: https://github.com/nimnaw/esp-vision

## Overview

ESP-VISION is a MicroPython-based edge vision framework for Espressif boards. A Python application enters the firmware runtime, which initializes camera, display, preview, and storage services; camera frames can then be used through the Python image API for processing and recognition. The README also documents media streaming, video codecs, and ESP-DL inference as product capabilities. Some of those implementation paths are present in the tree but were not sampled, so those capability links are documented rather than source-verified.

Main entry points: [`platform/main.c`](https://github.com/nimnaw/esp-vision/blob/master/platform/main.c) (MicroPython runtime), [`modules/py_image.c`](https://github.com/nimnaw/esp-vision/blob/master/modules/py_image.c) (Python image API), [`platform/storage.c`](https://github.com/nimnaw/esp-vision/blob/master/platform/storage.c) (Storage service), [`platform/camera.h`](https://github.com/nimnaw/esp-vision/blob/master/platform/camera.h) (Camera API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_runtime["MicroPython runtime<br/>[main.c]"]
end

subgraph group_capture["Capture and presentation"]
  node_camera_api["Camera API<br/>[camera.h]"]
  node_camera_board["Board camera driver<br/>[camera.c]"]
  node_display["Display<br/>[display.c]"]
  node_preview["Preview<br/>[preview.c]"]
end

subgraph group_vision["Vision processing"]
  node_image_api["Python image API<br/>[py_image.c]"]
  node_imlib["Image processing<br/>[imlib.c]"]
  node_zxing["Barcode recognition"]
  node_image_io["Image file I/O<br/>[py_imageio.c]"]
end

subgraph group_media["Media and AI"]
  node_jpeg["JPEG codec<br/>[jpeg.c]"]
  node_h264["H.264 codec<br/>[h264.c]"]
  node_rtsp["RTSP streaming<br/>[py_rtsp.c]"]
  node_network["Network APIs<br/>[modnetwork.c]"]
  node_espdl["ESP-DL inference<br/>[py_espdl.cpp]"]
  node_tflite["TensorFlow Lite<br/>[py_tflite.cpp]"]
end

subgraph group_storage["Device storage"]
  node_storage_api["Storage service<br/>[storage.c]"]
  node_storage_vfs["Python filesystem<br/>[storage_vfs.c]"]
  node_flash[("Flash partition")]
  node_sdcard[("SD card")]
end

node_developer(("Python application"))

node_developer -->|"runs application"| node_runtime
node_runtime -->|"initializes"| node_camera_api
node_runtime -->|"initializes"| node_display
node_runtime -->|"initializes"| node_preview
node_runtime -->|"mounts"| node_storage_api
node_camera_board -->|"implements"| node_camera_api
node_image_api -.->|"captures frames"| node_camera_api
node_image_api -->|"calls image routines"| node_imlib
node_image_api -->|"uses recognition"| node_zxing
node_image_api -->|"uses image I/O"| node_image_io
node_developer -.->|"displays images"| node_display
node_developer -.->|"encodes media"| node_jpeg
node_developer -.->|"encodes video"| node_h264
node_developer -.->|"streams media"| node_rtsp
node_rtsp -.->|"uses networking"| node_network
node_developer -.->|"runs inference"| node_espdl
node_developer -.->|"runs models"| node_tflite
node_storage_api -.->|"mounts filesystem"| node_storage_vfs
node_storage_api -.->|"reads and writes"| node_flash
node_storage_api -.->|"reads and writes"| node_sdcard

click node_runtime "https://github.com/nimnaw/esp-vision/blob/master/platform/main.c"
click node_camera_api "https://github.com/nimnaw/esp-vision/blob/master/platform/camera.h"
click node_camera_board "https://github.com/nimnaw/esp-vision/blob/master/boards/ESP32_S31_MOSAICO/camera.c"
click node_display "https://github.com/nimnaw/esp-vision/blob/master/platform/display.c"
click node_preview "https://github.com/nimnaw/esp-vision/blob/master/platform/preview.c"
click node_image_api "https://github.com/nimnaw/esp-vision/blob/master/modules/py_image.c"
click node_imlib "https://github.com/nimnaw/esp-vision/blob/master/components/imlib/upstream/imlib.c"
click node_zxing "https://github.com/nimnaw/esp-vision/blob/master/components/zxing/esp_vision_zxing.cpp"
click node_image_io "https://github.com/nimnaw/esp-vision/blob/master/modules/py_imageio.c"
click node_jpeg "https://github.com/nimnaw/esp-vision/blob/master/platform/jpeg.c"
click node_h264 "https://github.com/nimnaw/esp-vision/blob/master/platform/h264.c"
click node_rtsp "https://github.com/nimnaw/esp-vision/blob/master/modules/py_rtsp.c"
click node_network "https://github.com/nimnaw/esp-vision/blob/master/overlay/micropython/extmod/modnetwork.c"
click node_espdl "https://github.com/nimnaw/esp-vision/blob/master/modules/py_espdl.cpp"
click node_tflite "https://github.com/nimnaw/esp-vision/blob/master/modules/py_tflite.cpp"
click node_storage_api "https://github.com/nimnaw/esp-vision/blob/master/platform/storage.c"
click node_storage_vfs "https://github.com/nimnaw/esp-vision/blob/master/platform/storage_vfs.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime toneBlue
class node_camera_api,node_camera_board,node_display,node_preview toneAmber
class node_image_api,node_imlib,node_zxing,node_image_io toneMint
class node_jpeg,node_h264,node_rtsp,node_network,node_espdl,node_tflite toneRose
class node_storage_api,node_storage_vfs,node_flash,node_sdcard,node_developer toneIndigo
```

## Components

### Firmware runtime

- [MicroPython runtime](https://github.com/nimnaw/esp-vision/blob/master/platform/main.c): `platform/main.c`

### Capture and presentation

- [Camera API](https://github.com/nimnaw/esp-vision/blob/master/platform/camera.h): `platform/camera.h`
- [Board camera driver](https://github.com/nimnaw/esp-vision/blob/master/boards/ESP32_S31_MOSAICO/camera.c): `boards/ESP32_S31_MOSAICO/camera.c`
- [Display](https://github.com/nimnaw/esp-vision/blob/master/platform/display.c): `platform/display.c`
- [Preview](https://github.com/nimnaw/esp-vision/blob/master/platform/preview.c): `platform/preview.c`

### Vision processing

- [Python image API](https://github.com/nimnaw/esp-vision/blob/master/modules/py_image.c): `modules/py_image.c`
- [Image processing](https://github.com/nimnaw/esp-vision/blob/master/components/imlib/upstream/imlib.c): `components/imlib/upstream/imlib.c`
- [Barcode recognition](https://github.com/nimnaw/esp-vision/blob/master/components/zxing/esp_vision_zxing.cpp): `components/zxing/esp_vision_zxing.cpp`
- [Image file I/O](https://github.com/nimnaw/esp-vision/blob/master/modules/py_imageio.c): `modules/py_imageio.c`

### Media and AI

- [JPEG codec](https://github.com/nimnaw/esp-vision/blob/master/platform/jpeg.c): `platform/jpeg.c`
- [H.264 codec](https://github.com/nimnaw/esp-vision/blob/master/platform/h264.c): `platform/h264.c`
- [RTSP streaming](https://github.com/nimnaw/esp-vision/blob/master/modules/py_rtsp.c): `modules/py_rtsp.c`
- [Network APIs](https://github.com/nimnaw/esp-vision/blob/master/overlay/micropython/extmod/modnetwork.c): `overlay/micropython/extmod/modnetwork.c`
- [ESP-DL inference](https://github.com/nimnaw/esp-vision/blob/master/modules/py_espdl.cpp): `modules/py_espdl.cpp`
- [TensorFlow Lite](https://github.com/nimnaw/esp-vision/blob/master/modules/py_tflite.cpp): `modules/py_tflite.cpp`

### Device storage

- [Storage service](https://github.com/nimnaw/esp-vision/blob/master/platform/storage.c): `platform/storage.c`
- [Python filesystem](https://github.com/nimnaw/esp-vision/blob/master/platform/storage_vfs.c): `platform/storage_vfs.c`
- **Flash partition**
- **SD card**

### Other components

- **Python application**

## Connections

- Python application → MicroPython runtime: runs application (evidence: `README.md`)
- MicroPython runtime → Camera API: initializes (evidence: `platform/main.c`)
- MicroPython runtime → Display: initializes (evidence: `platform/main.c`)
- MicroPython runtime → Preview: initializes (evidence: `platform/main.c`)
- MicroPython runtime → Storage service: mounts (evidence: `platform/main.c`)
- Board camera driver → Camera API: implements (evidence: `boards/ESP32_S31_MOSAICO/camera.c`)
- Python image API → Camera API: captures frames
- Python image API → Image processing: calls image routines (evidence: `modules/py_image.c`)
- Python image API → Barcode recognition: uses recognition (evidence: `modules/py_image.c`)
- Python image API → Image file I/O: uses image I/O (evidence: `modules/py_image.c`)
- Python application → Display: displays images (evidence: `README.md`)
- Python application → JPEG codec: encodes media (evidence: `README.md`)
- Python application → H.264 codec: encodes video (evidence: `README.md`)
- Python application → RTSP streaming: streams media (evidence: `README.md`)
- RTSP streaming → Network APIs: uses networking
- Python application → ESP-DL inference: runs inference (evidence: `README.md`)
- Python application → TensorFlow Lite: runs models (evidence: `README.md`)
- Storage service → Python filesystem: mounts filesystem
- Storage service → Flash partition: reads and writes (evidence: `platform/storage.c`)
- Storage service → SD card: reads and writes (evidence: `platform/storage.c`)
