Skip to content

mishrasushruti99/Doom-scroll-app

Repository files navigation

app_ollama app_7 app_9 necessary files for different versions of the app

Doomscroll Detector

A real-time head-pose monitoring system that detects when you’re “doomscrolling” (looking down at your screen for too long) and triggers an MP4 alarm to bring you back to awareness. Built with Streamlit, OpenCV, and MediaPipe.

Features

  • Real-time head-pose detection using MediaPipe Face Mesh.

  • Calibrates neutral head position for each user.

  • Smooths pitch angle over multiple frames to reduce jitter.

  • Triggers an MP4 alarm video if you look down continuously for a configurable duration.

  • Live webcam feed displayed in the browser via Streamlit.

  • Interactive UI with a single Start Detection button.

Requirements

Python 3.9+

Streamlit

OpenCV (opencv-python)

MediaPipe

NumPy

You can install the required packages via pip:

pip install streamlit opencv-python mediapipe numpy

How to Run

Clone or download the repository.

Make sure your alarm video (drums_alarm.mp4) is in the same directory as the script or update VIDEO_PATH in the script in the respective app.

Run the Streamlit app:

streamlit run .py

Click Start Detection in the browser to begin.

Follow the calibration instructions: sit normally for 5 seconds.

If your head pitch exceeds the neutral position for more than 3 seconds, the alarm video will play.

Configuration

You can adjust the following parameters in the script:

VIDEO_PATH = "drums_alarm.mp4" # Path to your MP4 alarm video DOOM_TIME = 3 # Seconds of looking down before alarm triggers CALIBRATION_TIME = 5 # Seconds to measure neutral pose PITCH_WINDOW_SIZE = 5 # Number of frames to smooth pitch

How It Works

Uses OpenCV to capture webcam frames.

Uses MediaPipe Face Mesh to detect facial landmarks.

Estimates 3D head pose using cv2.solvePnP.

Computes pitch angle and smooths it over a rolling window.

If pitch exceeds neutral + threshold for more than DOOM_TIME seconds, triggers an MP4 alarm.

Displays real-time webcam feed and status overlay in the Streamlit UI.

Notes

Designed for macOS webcam (cv2.VideoCapture(0) with default backend).

For Windows or Linux, you may need to change the webcam backend.

Make sure the MP4 video path is correct; Streamlit will play it in-browser.

Press Ctrl+C in the terminal to stop the Streamlit app.

streamlit run app_doomscroll_8.py

app_7 Features

Real-time head-pose detection using MediaPipe Face Mesh.

Calibration phase to measure your neutral head position.

Smooths pitch angle over multiple frames to reduce jitter.

Triggers an MP4 alarm video if you look down continuously for a configurable duration.

Overlays live status on the webcam feed.

Requirements

Python 3.8+

OpenCV (opencv-python)

MediaPipe

NumPy

mpv (for playing MP4 alarms)

Install Python packages via pip:

pip install opencv-python mediapipe numpy

Install mpv:

macOS: brew install mpv

Windows: Download installer

Linux: sudo apt install mpv

How to Run

Make sure your alarm video (e.g., drums_alarm.mp4) is in the same directory as the script.

Run the script:

python doomscroll_detector.py

Sit normally for 5 seconds to calibrate your neutral head position.

If your head pitch exceeds neutral + threshold for more than 3 seconds, the alarm will play.

Press ESC to exit the program.

Configuration

You can adjust these parameters at the top of the script:

VIDEO_PATH = "drums_alarm.mp4" # Path to MP4 alarm video DOOM_TIME = 3 # Seconds of looking down before alarm triggers CALIBRATION_TIME = 5 # Seconds to measure neutral pose PITCH_WINDOW_SIZE = 5 # Frames to smooth pitch

had to diable airplay handoff thing in mac. had to brew install mpv made a backend versionn made a web version as well

Laptop Webcam ↓ OpenCV Video Capture (30 FPS) ↓ Frame Processing Loop ↓ ┌─────────────────────────────┐ │ Face Detection (MediaPipe) │ │ Head Pose Estimation │ │ Eye Gaze Approximation │ │ Phone Object Detection │ └─────────────────────────────┘ ↓ Behavior Aggregator (Time-based) ↓ Doomscroll Threshold Trigger ↓ Instant MP4 Playback (subprocess)

TODO 📈 How to Make It REALLY Smart Level 2 (Recommended)

Add:

Head pitch angle (PnP solve)

Phone detection (YOLOv8n)

Confidence smoothing (EMA)

Adaptive threshold based on time of day

Multiple alarms escalating

Log doomscroll minutes per day

Add head-pose calculation (PnP) so it detects “looking down at phone” reliably.

Optional phone detection using YOLOv8n or a simple color/object heuristic.

Trigger MP4 alarm instantly when the doomscroll conditions are met.

About

Made an anti doom scroll app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages