/ README.md
README.md
  1  # cheatshield
  2  # AI-Based Online Cheating Prevention System in Online Exams
  3  
  4  ![image](https://github.com/user-attachments/assets/e7b86718-0883-40bd-b92b-0097c7c9784a)  
  5  *Ensuring academic integrity in online exams through AI-powered proctoring.*
  6  
  7  ---
  8  
  9  ## πŸ“ Overview
 10  
 11  The **AI-Based Online Cheating Prevention System** is an intelligent proctoring solution designed to maintain fairness and integrity during online examinations. With the rise of remote learning, ensuring secure virtual assessments has become a critical challenge. This system leverages advanced artificial intelligence techniques to monitor candidates in real time, detect cheating behaviors, and enforce exam rules, reducing the need for human invigilators while fostering trust in digital education.
 12  
 13  The system integrates multiple detection modulesβ€”**object detection (YOLOv5)**, **face detection (MTCNN)**, and **audio detection (YAMNet)**β€”alongside system control mechanisms to create a comprehensive invigilation framework. It monitors for prohibited items (e.g., mobile phones, books), ensures the candidate’s presence, detects suspicious sounds (e.g., speech, whispering), and enforces rules like fullscreen mode and shortcut restrictions. A user-friendly interface built with **PyQt5** displays live webcam feeds, violation counts, and warnings, empowering proctors to oversee exams effectively.
 14  
 15  ---
 16  
 17  ## πŸš€ Features
 18  
 19  - **Object Detection**: Identifies prohibited items like mobile phones and books using YOLOv5 with a custom-trained model (`best.pt`).
 20  - **Face Detection**: Ensures the candidate’s presence and flags multiple faces using MTCNN, preventing impersonation.
 21  - **Audio Detection**: Detects suspicious sounds like speech or whispering using YAMNet, with a lowered threshold for improved sensitivity.
 22  - **System Control**: Enforces exam rules using `QWebEngineView`, maintaining fullscreen mode and disabling shortcuts (e.g., Alt+Tab, F11).
 23  - **Real-Time Monitoring**: Displays live webcam feeds, violation counts, and warnings in a PyQt5-based interface.
 24  - **Violation Handling**: Implements a 15-second cooldown between violations and ends the test after 10 violations.
 25  - **Resource Optimization**: Reduces webcam update rate to 10 FPS, lowers resolution to 160x120, and adjusts detection frequencies for smooth performance.
 26  - **Scalability**: Designed to handle multiple candidates, making it suitable for large-scale institutional assessments.
 27  - **Transparency**: Logs violations with timestamps for post-exam review and dispute resolution.
 28  
 29  ---
 30  
 31  ## πŸ› οΈ Technologies Used
 32  
 33  - **Python 3.x**: Core programming language for the system.
 34  - **YOLOv5**: For object detection to identify prohibited items like mobile phones and books.
 35  - **MTCNN**: For face detection to ensure candidate presence and prevent impersonation.
 36  - **YAMNet**: For audio detection to flag suspicious sounds like speech or whispering.
 37  - **PyQt5**: For building the user interface, displaying webcam feeds, and showing warnings.
 38  - **QWebEngineView**: For enforcing exam rules like fullscreen mode and shortcut disabling.
 39  - **TensorFlow Hub**: For loading pre-trained YAMNet model for audio detection.
 40  - **OpenCV**: For webcam frame processing and display.
 41  - **NumPy**: For numerical computations and array manipulations.
 42  - **SoundDevice**: For audio capture and processing.
 43  
 44  ---
 45  
 46  ## πŸ“‚ Project Structure
 47  AI-Based-Online-Cheating-Prevention-System 
 48  ```
 49  β”‚
 50  β”œβ”€β”€ models/
 51  β”‚   β”œβ”€β”€best.pt               # Custom-trained YOLOv5 model for object detection
 52  β”œβ”€β”€ modules/                 # Source code directory
 53  β”‚   β”œβ”€β”€ object_detection.py  # Module for YOLOv5 object detection
 54  β”‚   β”œβ”€β”€ face_detection.py    # Module for MTCNN face detection
 55  β”‚   β”œβ”€β”€ audio_detection.py   # Module for YAMNet audio detection
 56  β”‚   β”œβ”€β”€ system_control.py    # Module for enforcing exam rules (fullscreen, shortcuts)
 57  β”œβ”€β”€ index.html               # Frontend UI that appears on the external website
 58  β”œβ”€β”€ styles.css               # Stylesheet for the UI
 59  β”œβ”€β”€ main.py                  # Main script to run the proctoring system
 60  β”œβ”€β”€ requirements.txt         # List of required Python packages
 61  └── README.md                # Project documentation
 62  ```
 63  
 64  ---
 65  
 66  ## βš™οΈ Installation and Setup
 67  
 68  ### Prerequisites
 69  - Python 3.8 or higher 
 70  - A webcam and microphone
 71  - Internet connection (for initial package installation)
 72  
 73  ### Steps to run this project
 74  1. **Clone the Repository**
 75     ```bash
 76     git clone https://github.com/vishal017/cheatshield.git
 77     cd AI-Based-Online-Cheating-Prevention-System
 78     ```
 79  2. **Create a Virtual Environment (Optional but Recommended)**
 80     ```
 81     python -m venv venv
 82     ```
 83     ***For Windows***
 84     ```
 85     venv\Scripts\activate
 86     ```
 87     ***For Mac***
 88     ```
 89     source venv/bin/activate
 90     ```
 91  3. **Install Dependencies**
 92     ```
 93     pip install -r requirements.txt
 94     ```
 95  4. **Run the project**  
 96     ```
 97     python main.py
 98     ```
 99  
100    ## πŸ–₯️ Usage
101  
102  1. **Launch the Application**: Run `main.py` to start the proctoring system.  
103  2. **Exam Setup**: The system loads the exam website in a `QWebEngineView` window, enforcing fullscreen mode and disabling shortcuts.  
104  3. **Monitoring**: The PyQt5 interface displays the webcam feed, violation count, and warnings in real-time.  
105  4. **Violation Handling**:  
106     - Issues warnings for detected violations (e.g., mobile phone detected, multiple faces, speech).  
107     - A **15-second cooldown** prevents rapid triggers.  
108     - The test **ends after 10 violations**.  
109  5. **End Test**:  
110     - The test can be ended **manually via a password-protected dialog** or **automatically after 10 violations**.  
111     - Violations are logged in the `logs/` directory with timestamps.  
112  
113  ---
114  
115  ## πŸ“Š Performance and Outcomes
116  
117  - **Enhanced Supervision**: MTCNN ensures continuous face detection with high reliability, flagging impersonation attempts.  
118  - **Precise Object Detection**: YOLOv5 detects prohibited items accurately with confidence thresholds:  
119    - **Mobile Phones** β†’ `0.4`  
120    - **Books** β†’ `0.2`  
121  - **Effective Audio Detection**: YAMNet detects speech with a **0.3 threshold**, optimized with a **5-second detection interval**.  
122  - **System Control**: `QWebEngineView` enforces exam rules, preventing unauthorized access.  
123  - **Resource Efficiency**: Optimized to run smoothly even during YouTube playback with:  
124    - **10 FPS webcam update rate**  
125    - **160x120 resolution**  
126    - **Reduced detection frequencies**  
127  - **Scalability**: Can handle **multiple candidates**, making it suitable for large-scale exams.  
128  
129  ---
130  
131  ## πŸ” Challenges and Solutions
132  
133  - **High Resource Usage**  
134    - **Solution**: Reduced webcam FPS (`10`), lowered resolution (`160x120`), and optimized detection frequencies (`every 8th frame` for object/face detection, `every 5 seconds` for audio).  
135  
136  - **Misclassification in Object Detection**  
137    - **Solution**: Improved by setting confidence thresholds (`0.4` for mobile phones, `0.2` for books) and using a **custom-trained YOLOv5 model**.  
138  
139  - **White Box Issue in UI**  
140    - **Solution**: Made the warning display (`QWebEngineView`) **transparent** in the PyQt5 interface.  
141  
142  - **Noisy Audio Environments**  
143    - **Solution**: Lowered **YAMNet speech detection threshold** (`0.3`) and added **debug prints** to verify audio capture.  
144  
145  ---
146  
147  ## 🌟 Future Enhancements
148  
149  - **Lighter Models**:  
150    - Replace YOLOv5 with a **smaller variant (`yolov5s`)**.  
151    - Use a **lighter face detection model** instead of MTCNN to reduce resource usage.  
152  
153  - **Advanced Logging**:  
154    - Implement **detailed logging** of all detections (objects, faces, audio) for **post-exam analysis**.  
155  
156  - **Eye-Gaze Tracking**:  
157    - Detect off-screen glances **more accurately**.  
158  
159  - **Keystroke Dynamics**:  
160    - Monitor **typing patterns** to detect unusual behavior.  
161  
162  - **Noise Filtering**:  
163    - Enhance audio detection with **advanced noise filtering** for better performance in noisy environments.  
164  
165  ---
166  
167  ## πŸ“œ License
168  
169  This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
170  
171  ---
172  
173  ## 🀝 Contributing
174  
175  Contributions are **welcome!** To contribute:  
176  
177  1. **Fork** the repository.  
178  2. **Create a new branch** for your changes.  
179  3. **Submit a pull request** with appropriate documentation.  
180  
181  Ensure your code follows the **project’s coding style**.  
182  
183  ---
184  
185  ## πŸ“§ Contact
186  
187  For questions, suggestions, or collaboration, feel free to reach out:  
188  
189  - **Email**: vsm52125@gmail.com  
190  - **GitHub Issues**: Open an **issue** in this repository.  
191  
192  ---
193  
194  ## πŸ™ Acknowledgments
195  
196  - [YOLOv5](https://github.com/ultralytics/yolov5) β†’ Object detection.  
197  - [MTCNN](https://github.com/ipazc/mtcnn) β†’ Face detection.  
198  - [YAMNet](https://tfhub.dev/google/yamnet/1) β†’ Audio detection.  
199  - [PyQt5](https://www.riverbankcomputing.com/software/pyqt/) β†’ UI development.  
200  - **The open-source community** for invaluable resources and tools.  
201  
202  ---
203  
204  *Built with ❀️ to ensure fairness in online education.*  
205