Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ ESP32-CAM YOLOv8 AI Video Streamer & Studio

Python 3.10+ Flask YOLOv8 ESP32-CAM License: MIT

An end-to-end, high-performance Computer Vision and Video Streaming Studio for the AI-Thinker ESP32-CAM (OV2640) powered by Ultralytics YOLOv8 real-time object detection, MJPEG serial/Wi-Fi streaming, interactive glassmorphic web dashboard, and instant snapshot capture.


🌟 Key Features

  • 🧠 Real-Time YOLOv8 AI Object Detection:
    • Live inferencing using yolov8n.pt with bounding boxes, class labels, and confidence tags.
    • 1-click YOLOv8 toggle switch with live adjustable confidence threshold slider (10%–100%).
    • Real-time detected object count & category metadata badge panel.
  • ⚑ High-Speed Dual Streaming:
    • Serial/USB Binary Streaming: Ultra-stable 460,800 baud binary framed stream (0xAA 0x55 0xAA 0x55) direct to browser via Flask MJPEG server (/video_feed).
    • Wi-Fi Hotspot / AP Stream: ESP32 creates its own dedicated hotspot (ESP32-CAM-HD / 12345678) hosting a standalone high-speed MJPEG stream on http://192.168.4.1/stream.
  • πŸ“Έ High-Resolution Capture & Gallery:
    • Capture one-click full-resolution snapshots directly saved into uploads/.
    • Annotated snapshots saved with YOLOv8 bounding boxes when AI detection is enabled.
    • Interactive photo gallery with download, preview modal, and delete actions.
  • πŸ’‘ Hardware Control & Studio UI:
    • Onboard High-Power Flashlight LED toggle (GPIO 4).
    • Glassmorphic dark cyberpunk dashboard with real-time FPS counter, resolution indicator, and system health status.
    • Automated Timelapse capture mode.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       Serial (460800 baud)        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI-Thinker     β”‚ ════════════════════════════════> β”‚ Python Streaming Engineβ”‚
β”‚  ESP32-CAM      β”‚                                   β”‚ (video_streamer.py)    β”‚
β”‚  (OV2640 Sensor)β”‚ <── Flash & Commands ───────────  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                               β”‚ Frame Buffer
                                                                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         MJPEG Stream (HTTP)       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Modern Web UI   β”‚ <════════════════════════════════ β”‚ Flask Web Server       β”‚
β”‚ Dashboard (5000)β”‚                                   β”‚ + YOLOv8 Detector      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Repository Structure

β”œβ”€β”€ app.py                      # Flask backend & MJPEG / API server
β”œβ”€β”€ yolo_detector.py            # Ultralytics YOLOv8 inference & annotation engine
β”œβ”€β”€ video_streamer.py           # High-speed binary serial frame receiver
β”œβ”€β”€ capture_and_save.py         # Standalone CLI capture script
β”œβ”€β”€ upload.py                   # Automated Arduino CLI / ESP32 flasher
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ esp32_cam_capture/          
β”‚   └── esp32_cam_capture.ino   # High-efficiency C++ firmware for AI-Thinker OV2640
β”œβ”€β”€ templates/
β”‚   └── index.html              # Modern glassmorphism web studio UI
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ app.js                  # Frontend logic & real-time polling
β”‚   └── style.css               # Responsive cyberpunk styling
└── uploads/                    # Directory where captured images are stored

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/ashishvegan/esp32-cam-yolov8-ai-stream-studio.git
cd esp32-cam-yolov8-ai-stream-studio

2. Install Dependencies

pip install -r requirements.txt

3. Flash the ESP32-CAM Firmware

Upload esp32_cam_capture/esp32_cam_capture.ino using Arduino IDE (Board: AI Thinker ESP32-CAM) or via the helper script:

python upload.py

4. Run the AI Web Studio Server

python app.py

Open your browser and navigate to: πŸ‘‰ http://localhost:5000


πŸ”Œ ESP32-CAM Pinout & Wiring (AI-Thinker)

ESP32 Pin Function
GPIO 4 High-Power Flash LED
GPIO 33 Onboard Status LED (Inverted)
GPIO 1 UART TX0 (To USB-TTL RX)
GPIO 3 UART RX0 (To USB-TTL TX)
GPIO 0 GND during flashing / Float for normal boot
5V / GND External 5V 2A Power Supply

πŸ› οΈ API Reference

Endpoint Method Description
/video_feed GET Live multipart MJPEG video stream with YOLOv8 annotations
/api/status GET System telemetry (FPS, YOLO status, detections, resolution)
/api/snapshot POST Captures current frame and saves to uploads/
/api/yolo/toggle POST Turn YOLOv8 detection ON/OFF or update confidence threshold
/api/flash POST Toggle onboard Flashlight LED
/api/images GET List all saved snapshots
/api/delete/<file> DELETE Delete a snapshot

πŸ“œ License

This project is licensed under the MIT License.

About

High-performance AI Video Streaming Studio for AI-Thinker ESP32-CAM with real-time YOLOv8 object detection, MJPEG streaming, Flask backend, and modern web UI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages