# dfdurand/augmented-reality-app-with-opencv-and-esp32 architecture

> Architecture diagram of the GitHub repository dfdurand/augmented-reality-app-with-opencv-and-esp32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dfdurand/augmented-reality-app-with-opencv-and-esp32
- Repository: https://github.com/dfdurand/augmented-reality-app-with-opencv-and-esp32

## Overview

##### Project Type and Purpose
- The project is not a full-stack web app but rather an IoT / embedded system where one component runs a Python script (main_esp32cv.py) using computer vision libraries (cvzone, OpenCV) and communicates via serial (pyserial) with an ESP32.
- The ESP32 runs firmware (rtoscvesp32.ino) built in the Arduino environment and uses the DHT sensor library to monitor environmental data.
- The purpose is to process webcam input on the PC side and interact with sensor data from the ESP32 over serial communication.

##### File Structure
- README.md – Provides installation instructions for both sides (Python libraries for the PC and DHT sensor library for ESP32).
- main_esp32cv.py – The Python script that handles computer vision (webcam input) and manages serial communication.
- rtoscvesp32.ino – The Arduino sketch that runs on the ESP32 and deals with sensor data (DHT sensor) and serial interaction.

##### Elements
a. Main Components:
- PC Side (Webcam + Python Application)
- Modules: OpenCV, CVZone, and PySerial.
- Responsibility: Capture and process webcam data, manage serial communication with the ESP32.
- ESP32 Device (Microcontroller)
- Firmware: rtoscvesp32.ino.
- Libraries: DHT sensor library.
- Responsibility: Read sensor values (e.g., temperature, humidity) and respond/communicate with the PC.

b. Relationships and Interactions:
- Data flows: The Python application may send commands or request sensor information, while the ESP32 sends sensor readings or status updates back to the PC.

c. Architectural Patterns/Design Principles:
- Separation of concerns: The PC handles computer vision and UI aspects (or logging/display), and the ESP32 focuses on interfacing with physical sensors.
- Inter-process communication over serial is central to the design.

d. Relevant Technologies/Frameworks:
- On the PC: Python with libraries such as OpenCV, CVZone, and PySerial.
- On the ESP32: Arduino framework with the Adafruit DHT sensor library.

##### Final Overview
- Make each component visually distinct and annotate the interfaces and dependencies appropriately.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "PC Side"
        PC("Python Application (Webcam & Computer Vision)\n(OpenCV, CVZone, PySerial)"):::pc
    end

    subgraph "ESP32 Device"
        ESP("ESP32 Microcontroller (Sensor Interface)\n(Arduino, DHT sensor)"):::esp
    end

    PC -->|"serial communication"| ESP
    ESP -->|"sensor feedback"| PC

    subgraph "Project Files"
        DOC("Project Documentation (README.md)"):::file
        IMG("Auxiliary Visuals/Diagrams (images)"):::file
    end

    click PC "https://github.com/dfdurand/augmented-reality-app-with-opencv-and-esp32/blob/main/main_esp32cv.py"
    click ESP "https://github.com/dfdurand/augmented-reality-app-with-opencv-and-esp32/blob/main/rtoscvesp32.ino"
    click DOC "https://github.com/dfdurand/augmented-reality-app-with-opencv-and-esp32/blob/main/README.md"
    click IMG "https://github.com/dfdurand/augmented-reality-app-with-opencv-and-esp32/tree/main/images"

    classDef pc fill:#d1e8ff,stroke:#0d47a1,stroke-width:2px;
    classDef esp fill:#f8bbd0,stroke:#880e4f,stroke-width:2px;
    classDef file fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
```
