smartclass-ai

AI Classroom Monitor: Real-Time Engagement Tracking

An AI-powered (Artificial Intelligence) and IoT-based (Internet of Things) system designed to monitor and analyze student engagement in a classroom setting in real-time. This project uses edge hardware (ESP32-CAM) to capture video frames, a Python server running DeepFace for facial emotion recognition, and a secondary ESP32 with an OLED (Organic Light-Emitting Diode) screen to provide the teacher with instant feedback on class attentiveness.

System Screenshots

Features

Technology Stack

Software & AI:

Hardware:

Tested Development Environment

This system was built, configured, and tested on the following Linux architecture:

System Architecture

  1. The ESP32-CAM connects to a local Wi-Fi hotspot and sends a captured JPEG frame via an HTTP (Hypertext Transfer Protocol) POST request to the Python server every 5 seconds.
  2. The Flask Server receives the frame, queues it, and passes it to the AI worker thread.
  3. DeepFace analyzes the frame, generating an engagement score based on aggregated facial emotions.
  4. OpenCV draws bounding boxes and text onto the image, which is then saved to the disk and logged in SQLite.
  5. The Web Dashboard updates instantly via WebSockets with the annotated frame and new metrics.
  6. The ESP32 OLED board polls the /api/score endpoint to fetch the latest engagement percentage and updates the physical display on the teacher’s desk.

Setup & Installation

1. Server Environment (Linux / Debian-based)

It is strictly recommended to run this project within a Python Virtual Environment (venv) to prevent dependency conflicts with your system packages. Open your terminal and run the following:

# Clone the repository
git clone [https://github.com/yourusername/ai-classroom-monitor.git](https://github.com/yourusername/ai-classroom-monitor.git)
cd ai-classroom-monitor

# Create the virtual environment
python3 -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install all required dependencies
pip install -r requirements.txt

2. Network Configuration

The system relies on a local network bridge. Create a mobile hotspot from your laptop/server with the following credentials to allow the ESP32 boards to auto-connect:

3. Hardware Flashing

You will need the Arduino IDE (Integrated Development Environment) to flash the microcontrollers.

Running the System

Ensure your virtual environment is activated (source venv/bin/activate), then start the Python server. Upon the first run, the SQLite database classroom_data.db and the captures directory will automatically generate.

python server.py

Open your web browser and navigate to http://localhost:5000 or http://127.0.0.1:5000 to view the live dashboard. Keep the terminal running to allow continuous processing.

📄 License

This project is open-source and available under the MIT License.