Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2022 Apr 15:8:e929.
doi: 10.7717/peerj-cs.929. eCollection 2022.

pyVHR: a Python framework for remote photoplethysmography

Affiliations

pyVHR: a Python framework for remote photoplethysmography

Giuseppe Boccignone et al. PeerJ Comput Sci. .

Abstract

Remote photoplethysmography (rPPG) aspires to automatically estimate heart rate (HR) variability from videos in realistic environments. A number of effective methods relying on data-driven, model-based and statistical approaches have emerged in the past two decades. They exhibit increasing ability to estimate the blood volume pulse (BVP) signal upon which BPMs (Beats per Minute) can be estimated. Furthermore, learning-based rPPG methods have been recently proposed. The present pyVHR framework represents a multi-stage pipeline covering the whole process for extracting and analyzing HR fluctuations. It is designed for both theoretical studies and practical applications in contexts where wearable sensors are inconvenient to use. Namely, pyVHR supports either the development, assessment and statistical analysis of novel rPPG methods, either traditional or learning-based, or simply the sound comparison of well-established methods on multiple datasets. It is built up on accelerated Python libraries for video and signal processing as well as equipped with parallel/accelerated ad-hoc procedures paving the way to online processing on a GPU. The whole accelerated process can be safely run in real-time for 30 fps HD videos with an average speedup of around 5. This paper is shaped in the form of a gentle tutorial presentation of the framework.

Keywords: Contactless monitoring; Deep rPPG; Deepfake Detection; Heart Rate Estimation; Remote photoplethysmography.

PubMed Disclaimer

Conflict of interest statement

The authors declare there are no competing interests.

Figures

Figure 1
Figure 1. Prediction example.
Predictions on the Subject1 of the UBFC Dataset.
Figure 2
Figure 2. The pyVHR pipeline at a glance.
(A) The multi-stage pipeline of the pyVHR framework for BPM estimate through PSD analysis exploiting end-to-end DL-based methods. (B) The multi-stage pipeline for traditional approaches that goes through: windowing and patch collection, RGB trace computation, pre-filtering, the application of an rPPG algorithm estimating a BVP signal, post-filtering and BPM estimate through PSD analysis.
Figure 3
Figure 3. Comparison of the two implemented skin extraction methods.
Output of the Convex-hull approach (A) and face parsing by BiSeNet (B) on a subject of the LGI-PPGI dataset (Pilz et al., 2018).
Figure 4
Figure 4. Landmarks automatically tracked by MediaPipe and correspondent patch tracking on a subject of the LGI-PPGI dataset (Pilz et al., 2018).
Figure 5
Figure 5. Patch tracking within a frame temporal window on a subject of the LGI-PPGI dataset (Pilz et al., 2018).
Figure 6
Figure 6. Predicted BVP signals.
An example of estimated BVP signals on the same time window by four different methods. (A) POS. (B) GREEN. (C) CHROM. (D) PCA.
Figure 7
Figure 7. Estimated PSD.
Estimated Power Spectral Densities (PSD) for the BVP signals plotted in Fig. 6. The BPM estimate, given by the maxima of the PSD, is represented by the blue dashed line. (A) POS. (B) GREEN. (C) CHROM. (D) PCA.
Figure 8
Figure 8. Distribution of BPM predictions by four methods on P patches.
(A) POS. (B) GREEN. (C) CHROM. (D) PCA. Kernel Density Estimates (KDEs) of the predicted BPMs in a time window from P = 100 patches. The ultimate BPM prediction is given by the median (gold dashed line). The uncertainty estimate delivered by the Median Absolute Deviation (MAD) is shown by the golden band around the median. The blue dashed line represents the actual BPM.
Figure 9
Figure 9. Comparison of predicted vs ground truth BPMs using the patch-wise approach.
Predicted BPM (blue) for the Subject1 of the UBFC Dataset. The uncertainty is plotted in shaded blue, while the ground truth is represented by the red line.
Figure 10
Figure 10. Per-frame time requirements.
Average time requirements to process one frame by the Holistic and Patches approaches when using CPU vs. GPU accelerated implementations. The green dashed line represents the real-time limit at 30 frames per second (fps).
Figure 11
Figure 11. The graphical user interface.
A screenshot of the graphical user interface (GUI) for online video analysis. The plot on the left shows the predicted BPMs, while on the right it is shown the processed video frames (captured with a webcam) with an example of the segmented skin and the tracked patches.
Figure 12
Figure 12. The assessment module at a glance.
One or more datasets are loaded; videos are processed by the pyVHR pipeline while ground-truth BPM signals are retrieved. Predicted and real BPM are compared with standard metrics and the results are rigorously analyzed via hypothesis testing procedures.
Figure 13
Figure 13. Box plots showing the CCC values distribution for the POS, CHROM and GREEN methods on the UBFC2 dataset.
Figure 14
Figure 14. Results of the statistical assessment procedure.
CD diagram displaying the results of the Nemenyi post-hoc test on the three populations (POS, CHROM and GREEN) of CCC values on the UBFC2 dataset.
Figure 15
Figure 15. Box plots showing the SNR values distribution for the POS, CHROM, MTTS-CAN and GREEN methods on the UBFC1 dataset.
Figure 16
Figure 16. Results of the statistical assessment procedure.
CD diagram displaying the results of the Nemenyi post-hoc test on the four populations (POS, CHROM, MTTS-CAN and GREEN) of SNR values on the UBFC1 dataset.
Figure 17
Figure 17. Class diagram of dataset hierarchy of classes.
Figure 18
Figure 18. Deepfake detection results.
The 1,000 FaceForensics++ original videos (blue) and their swapped versions (yellow) represented in the 2-D space of BVP Fractal Dimension vs. BPMs average MAD. The green and red half-spaces are simply learned via a linear SVM.

References

    1. Aarts LA, Jeanne V, Cleary JP, Lieber C, Nelson JS, Oetomo SB, Verkruysse W. Non-contact heart rate monitoring utilizing camera photoplethysmography in the neonatal intensive care unit A pilot study. Early Human Development. 2013;89(12):943–948. doi: 10.1016/j.earlhumdev.2013.09.016. - DOI - PubMed
    1. Balakrishnan G, Durand F, Guttag J. Detecting pulse from head motions in video. Proceedings of the IEEE conference on computer vision and pattern recognition; Piscataway. 2013. pp. 3430–3437.
    1. Bansal A, Ma S, Ramanan D, Sheikh Y. Recycle-gan: unsupervised video retargeting. Proceedings of the european conference on computer vision (ECCV); 2018. pp. 119–135.
    1. Benavoli A, Corani G, Demšar J, Zaffalon M. Time for a change: a tutorial for comparing multiple classifiers through Bayesian analysis. The Journal of Machine Learning Research. 2017;18(1):2653–2688.
    1. Benezeth Y, Li P, Macwan R, Nakamura K, Gomez R, Yang F. Remote heart rate variability for emotional state monitoring. 2018 IEEE EMBS international conference on biomedical & health informatics (BHI); Piscataway. 2018. pp. 153–156.

LinkOut - more resources