# teikgfgt/autolane-assist architecture

> Architecture diagram of the GitHub repository teikgfgt/autolane-assist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teikgfgt/autolane-assist
- Repository: https://github.com/teikgfgt/autolane-assist

## Overview

##### Project type and purpose
- Type: Embedded real-time computer vision control system
- Purpose: Capture live video, detect lane boundaries with a YOLO model and OpenCV, compute steering corrections, send commands to an Arduino-driven motor to keep a vehicle centered.

##### File structure
- README.md — project description and tech stack
- main.py — orchestrates camera capture, image processing, inference, decision logic, and serial communication
- chi.pt — pre-trained YOLO model weights for lane detection
- teik.mp4 — sample video input for testing or demonstration

##### README for additional insights
- Confirms use of YOLO for object detection and OpenCV for image processing
- Describes real-time lane deviation detection and Arduino control loop

a. Camera Input
– Live video feed or recorded sample (teik.mp4)
b. Pre-processing (OpenCV)
c. Inference Module (YOLO)
– chi.pt weights + YOLO inference engine
d. Decision Logic
– Compute lane center deviation, steering angle
e. Communication Module
– Serial (e.g., USB or UART) link to Arduino
f. Arduino & Motor Assembly
– Arduino microcontroller reads commands and drives servo/motor
g. (Optional) Logging / Monitoring
– On-screen overlay, log files, or debug stream

##### Relationships and interactions (data flow)
1. Camera → Pre-processing
2. Pre-processing → YOLO inference
3. YOLO output → Decision Logic
4. Decision Logic → Serial Interface
5. Serial Interface → Arduino
6. Arduino → Motor / Steering Actuator
7. (Parallel) Send processed frames or metrics to display/log

##### Architectural patterns and design principles
- Pipeline pattern: each stage transforms data and passes it along
- Single-process orchestration in main.py coordinating modules
- Separation of concerns: vision (OpenCV), detection (YOLO), control (logic), actuation (Arduino)
- Real-time constraints: minimal buffering, low-latency serial comm.

##### Relevant technologies and libraries
- Python 3.x
- OpenCV for image capture and pre-processing
- PyTorch/YOLO API for model inference with chi.pt
- pySerial (or equivalent) for serial communication
- Arduino firmware (sketch) to interpret commands and drive a motor

– Annotations on interfaces (frame rate, serial protocol, model file name)
– Optional: overlay test video node for teik.mp4 as a standalone input

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    Cam["Camera Input<br/>(Live Feed / teik.mp4)"]:::vision
    Pre["OpenCV Pre-processor"]:::vision
    Infer["YOLO Inference Engine<br/>(chi.pt)"]:::inference
    Decision["Decision Logic<br/>(Steering Computation)"]:::control
    Comm["Serial Communication Module"]:::control
    Arduino["Arduino & Motor Assembly"]:::hardware
    Logging["Logging / Monitoring"]:::vision
    Doc["Project Documentation<br/>(README.md)"]:::doc

    %% Flow
    Cam -->|"frame"| Pre
    Pre -->|"pre-processed frame"| Infer
    Infer -->|"detections"| Decision
    Decision -->|"commands"| Comm
    Comm -->|"serial data"| Arduino

    %% Parallel logging
    Pre -->|"metrics & frames"| Logging
    Infer --> Logging
    Decision --> Logging

    %% Documentation link
    Doc

    %% Click events
    click Cam "https://github.com/teikgfgt/autolane-assist/blob/main/teik.mp4"
    click Pre "https://github.com/teikgfgt/autolane-assist/blob/main/main.py"
    click Infer "https://github.com/teikgfgt/autolane-assist/blob/main/chi.pt"
    click Decision "https://github.com/teikgfgt/autolane-assist/blob/main/main.py"
    click Comm "https://github.com/teikgfgt/autolane-assist/blob/main/main.py"
    click Logging "https://github.com/teikgfgt/autolane-assist/blob/main/main.py"
    click Doc "https://github.com/teikgfgt/autolane-assist/blob/main/README.md"

    %% Styles
    classDef vision fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef inference fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef control fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef hardware fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef doc fill:#FFFFE0,stroke:#000,stroke-width:1px;
```
