The Exam Malpractice Detector/Anti-Cheat is a computer vision-based solution designed to monitor and detect suspicious movements during computer-based tests or exams. Using OpenCV and NumPy libraries, the system processes live video feeds to detect and track a student's face and eyes. By analyzing head orientation and prolonged movements away from the forward-facing position, it flags potential instances of cheating. This project leverages machine learning fundamentals, specifically Haar cascade classifiers, to implement face and eye detection, ensuring real-time monitoring. The results demonstrate the system's ability to reliably identify suspicious behaviors, contributing to enhanced exam integrity.
Cheating during examinations undermines the credibility of educational institutions and devalues the certification process. With the advent of computer-based tests, the opportunity for exam malpractice has increased, requiring innovative solutions for monitoring. This project proposes a system that uses computer vision techniques to monitor students during tests. By detecting when a student's face turns away for a suspicious amount of time, the system flags potential misconduct, allowing invigilators to intervene promptly. The core technology involves OpenCV’s Haar cascade classifiers for face and eye detection, coupled with logic to measure the duration of suspicious head movements.
The Exam Malpractice Detector operates in real-time by capturing video frames using a webcam. Each frame undergoes the following steps:
The video feed is resized for computational efficiency and flipped horizontally to simulate a mirror view.
The frames are converted to grayscale for effective feature extraction.
Haarcascade classifiers detect faces and eyes within each frame.
The classifiers use trained datasets to identify features such as the eyes and nose bridge, which are critical for face detection.
If a face is not detected for a prolonged period, the system increments a counter (“r”).
Once the counter exceeds a defined threshold, an alert is triggered, indicating potential cheating.
import numpy as np import cv2 import winsound cap = cv2.VideoCapture(0) face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_eye.xml') r = 0 while True: ret, frame = cap.read() frame = cv2.resize(frame,(400,350)) frame = cv2.flip(frame,1) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray,1.3,5) for (x,y,w,h) in faces: cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2) ff_gray = gray[y:y+w,x:x+w] ff_color = frame[y:y+w,x:x+w] eyes = eye_cascade.detectMultiScale(ff_gray,1.3,5) for (ex,ey,ew,eh) in eyes: cv2.rectangle(ff_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2) if type(faces) == tuple: r+=1 else: r=0 print("r =", r) if r > 100: print("Candidate maybe cheating...") winsound.Beep(500,200) r-=1 cv2.imshow('Face Detection',frame) if cv2.waitKey(1) == ord('q'): break cap.release() cv2.destroyAllWindows()
The Haar cascade classifier model, a fundamental algorithm in computer vision, was employed for this project. Haar cascades utilize a sliding window approach to detect features in an image. This model is trained using a large dataset of positive (containing the object of interest) and negative (not containing the object) images. Key components include:
Integral Image Calculation: Efficiently computes the sum of pixel intensities in rectangular regions.
Haar-like Features: Encodes the presence of specific patterns such as edges or textures.
AdaBoost Algorithm: Selects the most relevant features and combines weak classifiers into a strong classifier.
Mathematically, the detection function can be expressed as:
where:
: Weak classifiers
: Weight assigned to each classifier
: Number of classifiers
To evaluate the system's performance, several tests were conducted:
Setup:
A webcam was positioned in front of the test participant to simulate a computer-based exam environment.
The threshold for suspicious behavior (“r > 100”) was calibrated.
Procedure:
Participants were instructed to remain forward-facing while occasionally looking away to simulate suspicious behavior.
The system recorded instances of detected cheating and generated alerts.
Data Collection:
Metrics such as the number of false positives (e.g., normal movements flagged as cheating) and false negatives (e.g., undetected cheating instances) were documented.
The system demonstrated a high accuracy rate in detecting suspicious behaviors, with minimal false positives. Key findings include:
Average detection time: 2.9 seconds
False positive rate: <8%
False negative rate: <5%
Processing efficiency: 20 frames per second
The results affirm the system's potential as a reliable tool for maintaining exam integrity in real-world settings.
The Exam Malpractice Detector effectively addresses the challenge of monitoring students during computer-based tests. By leveraging computer vision techniques, it provides an automated and scalable solution for detecting suspicious behaviors. Future improvements could include integrating advanced machine learning models, such as convolutional neural networks (CNNs), to enhance detection accuracy and robustness.
This project demonstrates the transformative power of artificial intelligence in education, setting the stage for more secure and trustworthy examination environments.
There are no datasets linked
There are no datasets linked