Inspiration
The idea for MidnightShift was born out of the long hours students spent studying at Texas A&M. During these late night sessions, we noticed a concerning trend: students frequently leave their laptops unlocked and unattended in public study spaces to take a break, creating a massive privacy risk. Beyond security, we also observed the physical and mental toll of these midnight study shifts. We saw ourselves and our fellow students struggle with poor posture, distracted eyes or simply scroll on their phones or watch YouTube videos on their laptops as fatigue set in. We saw an opportunity to address these problems using OpenCV’s facial recognition technology. We wanted to create a tool that not only secures a user’s data by auto-locking when they walk away, but also helps them maintain their health and focus. Through MidnightShift, we bring a solution to these issues, providing a smarter, more secure way to handle the demands of late-night productivity.
What it does
MidnightShift utilizes real-time facial recognition to monitor user presence. If the user walks away from their device, the system automatically locks the screen in a 5 second buffer to prevent unauthorized access and protect private data. Using OpenCV, the software also tracks eye movement to determine if the user is looking at the screen or becomes distracted by their surroundings and monitors specific metrics such as blink rate and the percentage of time eyes remain open and focused on the task at hand. The system checks the user’s posture during long study sessions, providing feedback to help prevent the physical strain during late night work. The users also receive push notifications if they get distracted on their device and open up social media applications. At the end of each session, users receive a detailed report of their productivity. This includes a percentage based analysis of time spent off-task, a log of time spent on distracting applications and a session history to help users identify patterns in their focus and improve their long term study habits.
How we built it
- We built the core engine using Python, leveraging OpenCV for real-time video tracking and webcam access. We integrated dlib for precise facial landmark detection and the face-recognition library to verify the user’s presence. To address the physical toll of long study sessions, we utilized ultralytics (YOLO) for posture detection.
- We implemented a system using psutil to monitor active windows and log time spent on distracting applications like Discord, Instagram, and WhatsApp. For security, we developed a 5-second buffer logic that automatically locks the device when the user is no longer detected.
- The user interface was made with React (TypeScript) and styled using CSS to create a clean, "night owl" friendly dashboard. We used Flask and flask-cors to build the APIs that facilitate communication between the Python-based vision engine and the React frontend.
- To keep users focused without needing to check the dashboard constantly, we integrated win10toast to send real-time Windows push notifications when distractions are detected.
Challenges we ran into
As beginner hackers, we ran into quite a few challenges while working with software, including python 3.14 compatibility issues with ultralytics, dlib and using flask to connect the front end to the backend. We also faced issues with counting the number of blinks and ensuring the system could monitor multiple metrics such as posture, eye engagement and active window tracking simultaneously without significant lag was also a major challenge. We were unfortunately unable to deploy our Python backend due to the complexity of hosting a real-time computer vision application that requires direct hardware (webcam) access and high computational processing on accessible cloud platforms. There was also intended to be a predictive model that utilized time of day with productivity data, but the dataset ended up being too small to effectively train and test a model within a feasible amount of time in an average session.
Accomplishments that we're proud of
- Built a fully functional, end-to-end system that combines computer vision, security automation, and productivity analytics in real time.
- Successfully integrated multiple complex technologies such as OpenCV, dlib, YOLO, Flask, React, and system-level monitoring into a single cohesive product.
- Designed and implemented a 5-second auto-lock buffer that balances security with usability, preventing accidental lockouts.
- Implemented real-time push notifications to help users regain focus without interrupting their workflow.
- Tackled real-world issues students face during late-night study sessions, combining privacy, health, and productivity into one tool.
What we learned
- Gained hands-on experience with real-time computer vision pipelines, including facial recognition, eye tracking, and posture detection.
- Learned how to manage performance trade-offs when tracking multiple metrics simultaneously without introducing significant lag.
- Deepened our understanding of full-stack development, especially connecting a Python-based backend to a React frontend using Flask APIs.
- Discovered the challenges of deploying hardware-dependent ML applications, especially those requiring webcam access and low-latency processing.
- Improved our debugging skills by resolving library compatibility issues across Python versions and machine learning frameworks.
- Learned the importance of scoping datasets realistically when attempting predictive modeling in short development timelines.
What's next for MidnightShift
For future scalability, we hope to train a model on the student’s statistics to predict their future productivity trends and suggest optimal study times. We also hope to implement drowsiness detection alerts and integrate a built-in task list to correlate completion rates.
Log in or sign up for Devpost to join the conversation.