How johnnykozman2007/studymonitor works
1. Repository shape
- This is a small, mostly monolithic C++ Windows application.
- The core logic appears to live in a single source file, StudyMonitor.cpp.
- The rest of the tracked files are runtime assets or build artifacts: sound.wav, sound2.wav, sound3.wav, study_helper.exe, and OpenCVConfig-version.cmake.
2. Primary runtime model
- The app runs locally on a user’s machine and processes live webcam video in real time.
- There is no sign of a network service, database, or multi-process architecture.
- The executable is a study-session monitoring tool that continuously evaluates posture/focus signals and emits alerts.
3. External dependencies that define the architecture
- OpenCV provides camera capture, image processing, face detection, and UI/windowing support.
- dlib provides facial landmark detection through the 68-point landmark model.
- Windows APIs are used for message boxes and audio playback, which makes this specifically a Windows desktop application rather than a cross-platform one.
4. Startup and configuration flow
- On launch, the app shows a welcome message and asks the user to choose a session length: 30, 60, or 90 minutes.
- It expects local runtime assets to be present near the executable, including:
- shape_predictor_68_face_landmarks.dat
- haarcascade_frontalface_default.xml
- optional sound files
- The README also points to configurable thresholds in an AppConfig structure, implying the behavior is controlled by runtime parameters rather than multiple services.
5. Video acquisition and detection pipeline
- The webcam feed is the primary data source.
- Each frame likely goes through a sequence like:
- detect face presence,
- locate facial landmarks,
- infer eye openness,
- estimate pupil movement,
- estimate screen distance.
- That pipeline is the heart of the system and is where all “focus” signals are derived.
6. Focus-signal subsystems
- Distance tracking: determines whether the user is too close to the screen, with a warning threshold around 0.5 m.
- Eye state detection: classifies eyes as open or closed and tracks how long they remain closed.
- Pupil movement / zoning-out detection: watches whether the pupil appears stationary for too long, used as a proxy for reduced attention.
- These are not separate services; they are distinct analyses over the same video stream.
7. State accumulation and timers
- The app keeps running counters for:
- time spent too close,
- time with eyes closed,
- time zoning out.
- It also tracks session time remaining.
- The alert thresholds are temporal, not just visual: for example, eyes closed for more than 6 seconds or pupil stagnation for around 2 seconds.
8. Alerting and feedback loop
- When the app detects a focus issue, it warns the user with audio alerts using the bundled sound files.
- The README mentions Windows sound APIs, so the alerts are likely triggered directly from the app without any middleware.
- The user-facing output includes real-time status for face presence, eye state, focus level, and session countdown.
9. User interaction controls
- The app is interactive but minimal:
- ESC exits early.
- SPACE three times within 3 seconds triggers a study report.
- This suggests the main loop is event-driven around keyboard input while continuously processing camera frames.
10. Session summary/reporting
- The report feature aggregates the tracked durations into a session summary.
- This is the main “end-of-session” artifact of the application: it turns raw detection history into a human-readable assessment of study quality.
- It reinforces that the app is a single-session monitor rather than a long-running analytics system.
11. Packaging and deployment boundary
- The repo is designed to ship as a local Windows executable with companion files in the same folder.
- study_helper.exe indicates a built binary, while the XML model and WAV files are external runtime dependencies.
- The project boundary is therefore “desktop executable plus local assets,” not a layered client/server stack.
12. Architecture summary for diagramming
- The main diagram should show one local application process in the center.
- Inputs: webcam, keyboard, local model files, cascade XML, optional sound assets.
- Core processing: OpenCV frame loop + dlib landmarks + heuristics/timers.
- Outputs: on-screen status, Windows message boxes, audio reminders, final session report.
- The architecture is fundamentally a real-time computer-vision monitoring loop with lightweight local persistence only in the form of bundled files and session state in memory.
Main entry points: StudyMonitor.cpp Frame loop · study_helper.exe study_helper.exe · OpenCVConfig-version.cmake OpenCV · sound.wav sound.wav
Components 20
Application
Local Windows study-session monitor
- Study Monitor · Single-process desktop app that monitors study focus in real time
StudyMonitor.cpp - Session setup · Starts with welcome prompt and session-length choice
StudyMonitor.cpp - Keyboard input · ESC exits; triple-space triggers report
StudyMonitor.cpp
Processing
Real-time webcam analysis and session state
- Frame loop · Continuously reads webcam frames and drives analysis
StudyMonitor.cpp - Face detect · Finds face presence in the live video stream
StudyMonitor.cpp - Landmarks · Extracts facial landmarks from detected faces
StudyMonitor.cpp - Eye state · Classifies open vs closed eyes and tracks closure time
StudyMonitor.cpp - Pupil focus · Tracks pupil movement to detect zoning out
StudyMonitor.cpp - Distance check · Estimates whether the user is too close to the screen
StudyMonitor.cpp - Session state · Accumulates close-eye, distance, and zoning-out durations
StudyMonitor.cpp - Alerts · Triggers audio and message-box warnings on focus issues
StudyMonitor.cpp - Study report · Builds the end-of-session summary from tracked history
StudyMonitor.cpp - Status display · Shows live face, eye, focus, and countdown status
StudyMonitor.cpp
Dependencies
External libraries and platform APIs
- OpenCV · Provides camera capture, image processing, and windowing
OpenCVConfig-version.cmake - dlib · Provides facial landmark detection
- Windows APIs · Provides message boxes and sound playback
Runtime files
Bundled executable and companion assets
- study_helper.exe · Built local executable shipped with the repo
study_helper.exe - sound.wav · Bundled alert sound
sound.wav - sound2.wav · Bundled alert sound
sound2.wav - sound3.wav · Bundled alert sound
sound3.wav
Connections 21
- study_helper.exe → Study Monitor: runs · The packaged executable launches the application
- Session setup → Frame loop: starts · Session setup feeds the monitoring loop
- Keyboard input → Session setup: selects · Keyboard interaction chooses session length and can end early
- Frame loop → OpenCV: captures · OpenCV drives webcam acquisition and UI display
- Frame loop → Face detect: analyzes · Each frame begins with face presence detection
- Face detect → Landmarks: refines · Detected face regions are passed to landmark extraction
- Landmarks → Eye state: derives · Landmarks are used to classify eye openness
- Landmarks → Pupil focus: derives · Landmarks support pupil-motion heuristics
- Landmarks → Distance check: derives · Facial geometry supports screen-distance estimation
- Eye state → Session state: updates · Eye-closure duration is accumulated in session state
- Pupil focus → Session state: updates · Zoning-out duration is accumulated in session state
- Distance check → Session state: updates · Too-close duration is accumulated in session state
- Session state → Status display: renders · Current status and countdown are shown to the user
- Session state → Alerts: triggers · Threshold breaches emit warnings
- Alerts → Windows APIs: plays · Windows APIs handle message boxes and sound playback
- Alerts → sound.wav: uses · One of the bundled audio cues
- Alerts → sound2.wav: uses · One of the bundled audio cues
- Alerts → sound3.wav: uses · One of the bundled audio cues
- Frame loop → dlib: uses · Landmark detection depends on dlib
- Frame loop → Study report: summarizes · Session history is condensed into a study report
- Keyboard input → Study report: invokes · Triple-space gesture triggers report generation