Skip to content

About

Gafas inteligentes open-source: ESP32-CAM + app Android con vision multimodal (Gemma 4 E2B), busqueda web en vivo y voz manos libres, 100% local y privado.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

OpenGlasses: Smart Glasses Ecosystem with On-Device AI & Web Search

English • Español


Platform AI Engine Model UI License

An open-source ecosystem that turns a $5 ESP32-CAM module and your smartphone into smart glasses with real-time multimodal vision, web search, and voice interaction.


OpenGlasses Live Demonstration



Architecture • Features • Quick Start • AI Models • REST API


Overview

OpenGlasses is a low-cost, fully functional smart glasses solution designed around the Edge-Split AI paradigm:

  1. Glasses (Wireless Optical Sensor): An ESP32-CAM mounted on standard eyeglass frames. Acts as a real-time MJPEG camera (SVGA resolution), an autonomous MicroSD video/photo recorder (AVI format with zero flash LED blink), and a standalone Wi-Fi SoftAP.
  2. Smartphone (Neural Processing Unit): Your phone executes on-device intelligence 100% locally and privately using Google LiteRT-LM (GPU-accelerated via OpenCL), queries SearXNG for live web grounding, and handles hands-free audio through Bluetooth smart glasses or earbuds.

Core Features

Category Capability Technical Details
On-Device Inference 100% Local & Private Powered by Google LiteRT-LM. GPU-accelerated (OpenCL) with shader caching or safe fallback to CPU.
Multimodal Vision Gemma 4 E2B Multimodal Environmental comprehension from SVGA frames captured directly from the glasses or attached gallery images.
Live Web Grounding SearXNG Metasearch Real-time web querying that injects top relevant snippets into LLM context with transparent citations.
Hands-Free Audio Bluetooth SCO + TTS Continuous voice recognition (STT) over Bluetooth SCO (smart frames/earbuds) and switchable speech synthesis (TTS).
Autonomous Recording MicroSD Card Storage 10 FPS Motion-JPEG AVI video and snapshot storage over 1-bit SD_MMC (eliminates GPIO 4 flash blinking) with auto-download to phone.
Native Android App Jetpack Compose Modern dark HUD interface inspired by ChatGPT/OpenWebUI, collapsible live viewfinder, and reactive touch controls.
Captive Web Portal Web Viewfinder & Controls Embedded web app in ESP32-CAM PROGMEM for live camera streaming, photo capture, MicroSD video recording, and Wi-Fi setup without installing apps.

System Architecture

flowchart TB
    subgraph GLASSES ["GLASSES (ESP32-CAM Hardware)"]
        OV["OV2640 Sensor (SVGA 800x600)"]
        AP["Wi-Fi SoftAP / HTTP Server"]
        SD["AVI Video & Photo Recording (MicroSD 1-Bit)"]
        OV -->|"MJPEG Stream / JPEG Frame"| AP
        OV -->|"10 FPS AVI Buffers"| SD
    end

    subgraph AUDIO ["AUDIO PERIPHERALS"]
        BT["Bluetooth Frames / Earbuds"]
    end

    subgraph SMARTPHONE ["SMARTPHONE (Native Android App / Edge AI)"]
        UI["Jetpack Compose UI (OpenWebUI HUD)"]
        STT["Speech Recognition (Bluetooth SCO)"]
        TTS["Text-to-Speech Engine"]
        LLM["Google LiteRT-LM Engine<br/>(Gemma 4 E2B Multimodal)"]
        ACCEL{"Inference Acceleration"}
        GPU["OpenCL GPU (Adreno / Mali)"]
        CPU["CPU Fallback"]
        ACCEL --> GPU
        ACCEL --> CPU
        
        UI -->|"Frame Request /stream or /capture"| AP
        STT -->|"Live Transcription"| UI
        UI -->|"Prompt + Image"| LLM
        LLM --> ACCEL
        LLM -->|"Token Streaming"| UI
        UI -->|"Voice Synthesis"| TTS
        TTS -.->|"Wireless Audio"| BT
        BT -.->|"User Voice"| STT
    end

    subgraph CLOUD ["EXTERNAL NETWORK (Concurrent 4G/5G)"]
        SX["SearXNG Instance (JSON Metasearch)"]
        GW["(Optional) AI Gateway / Ollama"]
    end

    AP -->|"Local Wi-Fi (192.168.4.1)"| UI
    UI -->|"Tool Call: Web Query"| SX
    SX -->|"Top 3 Relevant Snippets"| UI
    UI -.->|"Fallback Remote API"| GW
Loading

Repository Structure

openglasses/
├── android_app/               # Native Android Application (Kotlin + Jetpack Compose)
│   ├── app/src/main/
│   │   ├── java/.../openglasses/
│   │   │   ├── data/          # SearXNG client, backend configuration, preferences
│   │   │   ├── ui/main/       # HUD interface, Compose components, video viewer
│   │   │   └── MainActivity.kt# Application lifecycle and orchestration
│   │   └── AndroidManifest.xml# Permissions, OpenCL and native VNDK declarations
│   └── build.gradle.kts       # Gradle, NDK and LiteRT dependency configuration
├── firmware/                  # PlatformIO project for ESP32-CAM
│   ├── platformio.ini         # Build configuration, PSRAM flags, huge_app partition
│   ├── include/
│   │   ├── camera_pins.h      # AI-Thinker OV2640 pin mapping
│   │   ├── storage.h          # NVS flash handling & 1-bit MicroSD file system
│   │   ├── video_recorder.h   # Native AVI Motion-JPEG video recorder
│   │   └── web_ui.h           # Embedded Web UI (live stream, photo/video & Wi-Fi)
│   └── src/
│       └── main.cpp           # SoftAP Wi-Fi, HTTP Server, DNS & REST API
├── ai_gateway/                # Optional Edge AI Gateway (FastAPI + Ollama)
│   ├── gemma_server.py        # Proxy server for testing or desktop offloading
│   └── requirements.txt       # Python dependencies
└── docs/media/                # Media assets
    └── demo.gif               # Demonstration animation

Quick Start

1. Flashing the ESP32-CAM

  1. Connection: Mount the ESP32-CAM module onto its USB programmer shield / HAT (ESP32-CAM-MB) and plug the USB cable into your computer.
  2. Build and Flash via PlatformIO:
    cd firmware
    pio run --target upload
  3. The programmer HAT automatically handles the UART serial interface, 5V power regulation, and bootloader reset. Monitor logs with:
    pio device monitor -b 115200

2. Installing the Android App (android_app)

Requirements:

  • Android device running Android 8.0 (API 26) or higher (Android 12+ recommended with Snapdragon or MediaTek processor supporting OpenCL).
  • Android Studio Iguana or newer (or command line Android SDK).

Building the APK:

cd android_app
./gradlew assembleDebug

The resulting APK will be located at: android_app/app/build/outputs/apk/debug/app-debug.apk

Install directly onto your connected device via ADB:

adb install -r app/build/outputs/apk/debug/app-debug.apk

3. Loading the AI Model (Gemma 4)

Open the OpenGlasses app on your phone:

  1. Tap the Settings icon in the top-right corner.
  2. Tap "Select .litertlm / .task" to browse and select the model file from your device storage.
  3. The file will be copied safely into internal application storage (files/model.litertlm) for persistent offline access.

AI Models Guide (LiteRT-LM)

OpenGlasses uses the official Gemma 4 model family packaged for the litertlm format by Google and the LiteRT Community:

Model Size Modality / Capabilities Recommended Acceleration Link
gemma-4-E2B-it.litertlm ~2.58 GB Multimodal Vision + Text (LLM + vision_encoder visual subgraph) GPU (OpenCL) (Devices with $\ge 6\text{ GB}$ RAM) HuggingFace Hub
gemma-4-E2B-it-gpu.litertlm ~2.00 GB Ultra-light Text Only (visual subgraph excluded for low VRAM usage) GPU (OpenCL) HuggingFace Hub

Tip

Hardware Acceleration Tips: Select GPU for maximum inference speed and real-time streaming. Initial initialization compiles OpenCL GPU shaders (5–15 seconds) and caches them for instant launches in future sessions. Select CPU if you prefer a lower-power mode or if your chipset does not support OpenCL.


Concurrent Connectivity Setup

Because the glasses broadcast a local Wi-Fi SoftAP without internet uplink, mobile operating systems may attempt to drop the connection or disable mobile data.

To allow your smartphone to communicate with the ESP32-CAM (192.168.4.1) and simultaneously perform live SearXNG web searches via 4G/5G:

On Android:

  1. Connect to the glasses' Wi-Fi access point (OpenGlasses-POC, password: openglasses123).
  2. When the notification "This Wi-Fi network has no internet access" appears, tap it and select "Always stay connected".
  3. In Settings > Developer options, enable "Mobile data always active".

On iOS (via Fallback Web App):

  1. Connect to the OpenGlasses-POC Wi-Fi network.
  2. When the captive portal appears, tap "Cancel" in the top right and select "Use Without Internet".
  3. Ensure "Wi-Fi Assist" is enabled under Settings > Cellular.

REST API Specification

The ESP32-CAM HTTP server provides the following REST endpoints with CORS headers enabled:

Method Endpoint Description Response / Format
GET /capture Captures and returns an SVGA (800x600) JPEG snapshot. Supports ?save=1 to store on MicroSD. Binary image/jpeg
GET /stream Real-time MJPEG live camera stream. multipart/x-mixed-replace
GET /api/config Reads non-volatile memory (NVS) configuration parameters. JSON (ap_ssid, etc.)
POST /api/config Updates hardware parameters (NVS Preferences). JSON body
POST /api/record/start Starts native AVI video recording to the MicroSD card. {"status": "ok", "filename": "VID_....avi"}
POST /api/record/stop Stops video recording and returns download endpoint URL. {"status": "ok", "download_url": "/recordings?file=..."}
GET /api/record/status Reports recording status and elapsed duration in milliseconds. {"is_recording": true/false, "duration_ms": int}
GET /api/recordings Lists all video and photo files recorded on the MicroSD. JSON array `[{"name": "...", "size": int, "type": "video
GET /recordings?file=... Streams and prompts download of the requested media file. video/x-msvideo or image/jpeg
DELETE /api/recordings?file=... Deletes a video or photo file from the MicroSD card. {"status": "ok"}

Technologies & Dependencies

  • Hardware & Firmware: Espressif ESP32-CAM, Arduino Core (C++), PlatformIO, ESP32 Camera Driver (OV2640), SD_MMC (1-bit bus).
  • Android On-Device AI: Google LiteRT-LM (Android Native JNI), OpenCL C Runtime, Gemma 4 Instruct, MediaPipe Tasks GenAI.
  • Modern Android Stack: Kotlin Coroutines & SharedFlow, Jetpack Compose, Material Design 3, Coil Image Loader, OkHttp 4.
  • Voice & Audio: Android SpeechRecognizer, TextToSpeech, Bluetooth SCO Audio Routing.
  • Metasearch: SearXNG JSON API Metasearch Engine.

License & Attribution

This project is open-source under the Apache License 2.0.

Created and maintained by eelluu.

You are free to use, inspect, modify, and distribute this software for both personal and commercial projects, provided that original authorship, copyright notices, and license conditions are preserved. See LICENSE and NOTICE for details.

About

Gafas inteligentes open-source: ESP32-CAM + app Android con vision multimodal (Gemma 4 E2B), busqueda web en vivo y voz manos libres, 100% local y privado.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages