An advanced, AI-powered online examination proctoring web application built using Python, Flask, and Computer Vision. It provides automated student identity verification, tab-switch monitoring, voice level checking, and comprehensive facial posture and gaze analysis.
- Overview
- Architecture & Design
- Technologies Used
- Configuration
- Installation & Setup
- Usage Guide
- API & Route Documentation
- Directory Structure
- Testing & Quality Assurance
- Troubleshooting
- License
Note
This project was originally developed around 2022 for college students as a freelance project. It has since been standardized, cleaned up, and containerized for professional demonstration and showcase.
Cheating in online examinations is a major challenge for educational institutions. MyProctor.ai addresses this by providing a smart, low-latency, automated browser-based proctoring assistant. It enables institutions to conduct secure exams without requiring human proctors to monitor students continuously.
- Facial Recognition Login: Secures authentication by comparing the user's login webcam capture against their registration image using DeepFace.
- AI-Powered Test Generation: Automatically generates subjective and objective questions and answer keys from textbook paragraphs using NLTK NLP parsers.
- Multimodal AI Proctoring:
- Mobile Phone Detection: Detects cheating devices using a YOLOv3 object detector.
- Person Verification: Detects if zero, one, or multiple people are present in the frame.
- Gaze Tracking: Estimates left/right/center look positions and detects blinking pattern anomalies.
- Head Pose Estimation: Detects head turns (up, down, left, right) by solving the PnP perspective problem using landmark points.
- Security & Anti-Cheat Controls:
- Disables copy-paste, screenshots, and context menus on the examination screen.
- Tab Switch Detection: Logs window blur events to note when a student changes browser tabs.
- Audio Level Audits: Periodically checks sound frequencies to identify verbal assistance.
- Result Management: Supports negative markings, automatic objective grading, manually editable subjective/practical grading dashboards, and instant scorecard release.
- Credits System: Features Stripe-integrated recharge flow for professors to top up exam slot credits.
graph TD
A[Student Browser] -->|Webcam Frame - Base64| B(Flask App Engine)
A -->|Tab Switches / Blur| B
B -->|Base64 Decode| C(Camera Processing Module)
C -->|SSD SSD Model| D[Face Detection]
C -->|Pose Model Signatures| E[Facial Landmarks]
C -->|YOLOv3 Model| F[Mobile & Multi-person Detection]
C -->|Dlib Frontal Face| G[Gaze Tracking]
D & E & F & G -->|Aggregated Infractions| H(Proctor Log)
H -->|Log Writes| I[(MySQL Database)]
B -->|Check Exam State| I
app.py: Handles Flask routing, session configurations, Stripe checkout, SMTP messaging, database transactions, and HTML rendering.camera.py: Core vision processing pipeline. Decodes client webcam images, invokes YOLOv3 object detectors, runs face detectors, landmarks, and maps gaze ratios.objective.py&subjective.py: Natural Language Processing modules using NLTK. Tokenizes summaries, maps Part-of-Speech (POS) tags, parses noun chunks, and matches WordNet synonyms to generate blank-filling quiz or definition templates.face_detector.py/face_landmarks.py: Handles SSD Caffemodel configurations for bounding box detection and translates facial vectors to map coordinates.
- Backend Framework: Flask 2.0+
- Database: MySQL 8.0 / PyMySQL / Flask-MySQLdb
- Computer Vision / Deep Learning:
- OpenCV (Python Bindings)
- TensorFlow 2.4+ (YOLOv3 implementation)
- Dlib (Facial landmarks and gaze trackers)
- DeepFace (Facial verification)
- Natural Language Processing (NLP):
- NLTK (Tokenizers, RegexpParsers, POS tagger, and WordNet)
- Integrations: Stripe API (payments), Flask-Mail (OTP verification and exam credentials dispatch)
- Frontend UI: Vanilla CSS, HTML5 semantic layout, Bootstrap-based volt template modules, and Gulp assets compilations.
The application reads its settings dynamically from environment variables. A template file is provided as .env.example.
| Variable | Description | Default |
|---|---|---|
FLASK_APP |
Entry point script | app.py |
FLASK_ENV |
Running environment mode | development |
SECRET_KEY |
Flask session encrypt key | sem6project |
MYSQL_HOST |
Database host name | localhost |
MYSQL_PORT |
Database port number | 3306 |
MYSQL_USER |
Database user name | root |
MYSQL_PASSWORD |
Database connection password | root |
MYSQL_DB |
Target database schema name | quizapp |
MAIL_SERVER |
SMTP Mail server domain | smtp.gmail.com |
MAIL_PORT |
SMTP port | 587 |
MAIL_USERNAME |
SMTP server username account | hackspatel3624@gmail.com |
MAIL_PASSWORD |
SMTP account password / App key | Patel@3624 |
MAIL_USE_TLS |
Enables TLS transport security | True |
MAIL_USE_SSL |
Enables SSL transport security | False |
MAIL_SENDER |
Sender email displayed to user | youremail@abc.com |
STRIPE_SECRET_KEY |
Stripe backend payment secret key | dummy |
STRIPE_PUBLISHABLE_KEY |
Stripe UI public key | dummy |
APP_DOMAIN |
Base URL used for Stripe redirects | http://127.0.0.1:8000 |
Before running, ensure you have the following large binary model files downloaded and placed inside the appropriate folders:
- YOLOv3 Weights: Save as
models/yolov3.weights. Download from pjreddie.com/media/files/yolov3.weights. - Dlib Face Predictor: Save as
gaze_tracking/trained_models/shape_predictor_68_face_landmarks.dat.
Using Docker Compose is the easiest way to launch the application with a pre-configured MySQL database.
- Clone this repository.
- Ensure Docker and Docker Compose are installed on your machine.
- Configure your variables in a
.envfile (copied from.env.example). - Run the following command to build and launch both services:
docker compose up --build -d
- Access the web interface at http://localhost:8000.
- Python: Version 3.8 to 3.11.
- C++ Build Tools & CMake: Required for compiling
dlib.- Windows: Install Visual Studio Build Tools with C++ SDK.
- Ubuntu/Debian:
sudo apt install build-essential cmake g++ pkg-config libdbus-1-dev
- MySQL Server: Install and start a local instance, then import the database schema:
mysql -u root -p -e "CREATE DATABASE quizapp;" mysql -u root -p quizapp < DB/quizappstructure.sql
- Initialize a virtual environment and activate it:
python -m venv venv # Windows venv\Scripts\activate # Linux/Mac source venv/bin/activate
- Install dependencies:
pip install --upgrade pip pip install -r requirements.txt
- Start the Flask server:
python app.py
- Open http://127.0.0.1:5000 in your web browser.
- Log in as a Professor.
- Click AI Question Generator on the dashboard.
- Select Objective or Subjective type, specify the number of questions, and paste the study materials paragraph.
- Review the generated questions and click Submit to create an Exam ID slug.
- Log in as a Student (requires face verification matching registration credentials).
- Click Give Test and enter the Exam ID and Exam password.
- Allow camera access. The camera stream will check face vectors, gaze directions, and objects dynamically.
- Submit answers before the timer runs out.
- Endpoint:
/video_feed - Method:
POST - Form Parameters:
data[imgData]: Base64 encoded web camera frame.data[testid]: Exam identifier.data[voice_db]: Checked audio frequency integer.
- Behavior: Analyzes frame, inserts infractions (out-of-bounds looks, face counts, phone detection) into the
proctoring_logtable.
- Endpoint:
/window_event - Method:
POST - Form Parameters:
testid: Exam identifier.
- Behavior: Inserts logs noting tab switches into the database.
├── DB/ # MySQL database scripts
│ └── quizappstructure.sql # Main schema bootstrap file
├── gaze_tracking/ # Gaze tracking package (dlib model integration)
├── models/ # ML weights and structure definition graphs
│ ├── classes.TXT # YOLO target labels
│ ├── deploy.prototxt # SSD Caffemodel configs
│ ├── opencv_face_detector.pbtxt
│ ├── opencv_face_detector_uint8.pb
│ ├── pose_model/ # Face landmarks model structures
│ └── res10_300x300_ssd_iter_140000.caffemodel
├── static/ # Browser styles, assets, and scripts
├── templates/ # Jinja2 template views (student/professor screens)
├── tests/ # Automated Python unit/integration tests
├── app.py # Central Flask router and controller
├── camera.py # Computer vision execution pipeline
├── objective.py # Objective question text processing
├── subjective.py # Subjective question text processing
├── requirements.txt # Package dependencies
└── docker-compose.yml # Orchestration file
Automated unit and integration tests are located in the tests/ directory.
Make sure test dependencies are installed, then execute:
python -m unittest discover -s tests- Dlib fails to install locally:
Ensure you have
cmakeand C++ compiler tools installed. On Windows, verify that "Desktop development with C++" is ticked in the Visual Studio Installer. - MySQL connection issues in Docker Compose:
The web service utilizes a health check to wait for the MySQL DB container. If MySQL fails to initialize within the start period, check logs via
docker compose logs db. - Missing NLTK Packages: The application will automatically attempt to check for and download missing NLTK resources ('punkt', 'averaged_perceptron_tagger', 'wordnet') at runtime, so internet access is required on first launch.
This project is licensed under the MIT License. See LICENSE for more details.