This project is part of a Bachelor's thesis focused on real-time heart rate and variability detection using camera-based methods. It aims to provide a non-invasive way to measure heart rate and heart rate variability (HRV) using image processing and signal analysis techniques. Application based on proposed pipeline[1]
Important: OpenCV needs to be build from source with Gstreamer
-
Heart Rate Monitoring: Utilizes camera input to detect and monitor heart rate.
-
Heart Rate Variability Analysis: Offers HRV analysis using advanced signal processing techniques.
-
Non-Invasive Method: Employs a camera-based approach, eliminating the need for physical contact.
-
Configurable Settings: Includes various settings for camera resolution, filtering parameters, and more, as defined in
settings.toml
. -
Interactable Dashboard: - Dashboard for recording and visualising various signals inclusing:
- HR (with or without reference device)
- HRV (with or without reference device)
- rPPG Signal
- Post Processed rPPG signal
- Correlation Plots
- ...
-
Reference Device evaluation: utilises Openant to read in ANT+ compatible chest strap
-
Evaluation of Accuracy: Evaluates the reference device HR against the estimated HR
-
Reference Device HRV calulation: Caluculates the HRV of a ANT+ compatible chest strap
-
Clone the repository:
git clone https://github.com/parisj/CBHRM.git
-
Install required dependencies:
pip install -r requirements.txt
To run the application, execute:
cd CBHRM
python run_application.py
fps_camera
: The frame rate of the camera in frames per second. Default is20
.resolution
: The resolution of the camera. Default is960x720
pixels.
live
: Determines if the video source is live (true
) or pre-recorded (false
). Default isfalse
.path
: The file path to the pre-recorded video. Default is"dataset/P1/Talking/recording_3.avi"
.evaluate_dataset
: A boolean flag to indicate whether to evaluate the dataset. Default istrue
.path_measurements
: File path to the dataset measurements. Default is"dataset/P1/Talking/recording_3.csv"
.live = true evaluate_dataset = false
live = false evaluate_dataset = false
live = false evaluate_dataset = true
fs
: Sampling frequency. Default is20
.lowpass_order
: Order of the lowpass filter. Default is6
.wn_lowpass
: Normalized cutoff frequency for the lowpass filter. Default is0.6
.pos_window_l
: Position window length. Default is32
.cutoff_window
: Cutoff window frequencies. Default is[0.235, -0.235]
.bandpass_order
: Order of the bandpass filter. Default is25
.
time_window
: Time window for measurement in milliseconds. Default is200
.start_delay_peak_detection
: Delay before starting peak detection in milliseconds. Default is15
.distance
: Minimum distance between peaks. Default is6
.prominence
: Minimum prominence of peaks. Default is0
.
delay
: Delay in evaluation in samples. Default is85
.len_hr_min
: Minimum length for heart rate data. Default is21
.fps
: Frames per second for evaluation. Default is20
.dashboard_refresh_time
: Dashboard refresh rate in milliseconds. Default is1000
.min_ref_measurements
: Minimum reference measurements. Default is500
.calibration_time_ref
: Calibration time for reference in samples. Default is300
.min_ref_hrv
: Minimum reference for HRV. Default is90
.calibration_time_ref_hrv
: Calibration time for HRV reference in samples. Default is50
.
path
: Path to save results. Default is"dataset/P2/breathing2.csv"
.write
: Enable writing results. Default istrue
.
hrv_window
: HRV measurement window in samples. Default is200
.device_id
: Device ID for the reference measurement. Default is20074
.
fps_camera
: Frames per second for the camera in the dataset recording. Default is20
.resolution
: Camera resolution for the dataset recording. Default is[960,720]
.device_id
: Device ID for the dataset recording. Default is20074
.video_path
: Path to the video file for the dataset recording. Default is"dataset/P2/breathing2.avi"
.readings_path
: Path to the readings file for the dataset recording. Default is"dataset/P2/breathing2.csv"
.
- Scan with openant for devices and write json will found devices
openant scan --outfile devices.json
-
Extract device ID
-
Replace device ID with new ID
Tip: Duplicate settings.toml and name old one: settings_old_device_ID.toml
CBHRM/
.gitignore
README.md
requirements.txt
run_application.py
settings.toml
dataset/
P1/
Post_Workout/
Rotation/
Steady/
Talking/
P2/
Rotation/
Steady/
Talking/
P3/
Post_Workout/
Rotation/
Steady/
Talking/
P4/
result.csv
Post_Workout/
Rotation/
Steady/
Talking/
Plots/
results/
src/
blackboard.py
control.py
dashboard.py
heart_rate_monitor.py
image_processor.py
signal_processor.py
video_stream.py
__init__.py
devices/
devices.json
util/
heart_rate.py
histogram_inspection.py
legacy_dashboard.py
livefilter.py
load_pkl.py
plot_frequency.py
plot_functions.py
recoord_dataset.py
[1] A. Gudi, M. Bittner, R. Lochmans, and J. van Gemert, ‘Efficient Real-Time Camera Based Estimation of Heart Rate and Its Variability’. arXiv, Sep. 03, 2019. Accessed: Dec. 10, 2023. [Online]. Available: http://arxiv.org/abs/1909.01206