Featuring Live Camera Detection and an Interactive Simulator
Live Metrics
Status: Stopped
Respiration Rate: -- BPM
Breaths Detected: 0
Signal Quality: --
Sound:
Mode:
Simulation
Sensitivity:2.5x
Overview
This application measures breathing rate using computer vision. It features two modes: a Live Camera Mode that uses your webcam and a machine learning model to detect your breathing in real-time, and a Simulation Mode that visualizes pre-generated data for a consistent educational experience.
How to Use
Choose a Mode: Use the "Mode" toggle to switch between "Simulation" and "Live Camera".
In Simulation Mode: Click "Play Simulation" to start the animation. The sensitivity slider is disabled in this mode as the data is clean.
In Live Camera Mode: Click "Start Camera" and grant webcam access. Position yourself so your upper body is visible and stable.
Adjust Sensitivity: If breaths are not being detected (e.g., you are breathing very shallowly), slowly increase the "Sensitivity" slider. If you see too many false detections from small movements, decrease it. Finding the right balance is key!
Controls: Use the on-screen buttons or keyboard shortcuts (Spacebar for Play/Pause/Start/Stop, R for Reset) to control the application.
Technical Details
Live Camera Mode: This mode uses Google's MediaPipe Pose, a machine learning model that runs in your browser to detect 33 body landmarks from the webcam feed.
Signal vs. Noise & Sensitivity: The rhythmic vertical movement of your chest is the "signal" we want to measure. However, small, random movements from body sways, camera jitter, or digital video artifacts create "noise". The Sensitivity slider amplifies the difference between the current signal and its recent average.
A high sensitivity can lift a weak breathing signal out of the noise floor, making it detectable.
However, too much sensitivity will amplify the noise itself, causing the algorithm to detect false breaths on random movements. This demonstrates the core trade-off in bio-signal processing.
Unified Signal Processing: Both modes feed landmark data into the same processing pipeline, which includes amplification (live mode only), a moving average filter for smoothing, adaptive peak detection to count breaths, and rate calculation.
Future Directions
This application serves as a foundation for more advanced features. Future development could include:
Multiple Scenarios: Adding buttons to switch between different synthetic data sets, such as "Relaxed Breathing (12 BPM)", "Post-Exercise (25 BPM)", or "Irregular Breathing".
Heart Rate Estimation (rPPG): Implementing an algorithm in Live Mode to detect subtle color changes in the user's forehead (caused by blood flow) to estimate heart rate.
Stress Level Analysis: Correlating breathing rate, regularity, and heart rate variability (HRV) to provide a potential stress indicator.
Data Export: Allowing users to download their session data (BPM over time, breath intervals) as a CSV file for analysis.
Guided Breathing Exercises: Creating a biofeedback mode with a visual guide (e.g., an expanding and contracting circle) to help users practice calming breathing techniques like box breathing.