Home

Awesome

PhysRecorder

A tool for recording high availability rPPG datasets, lossless and highly synchronized. This tool aims to guide researchers in collecting high-value rPPG datasets. In past dataset works, some studies lacked attention to signal synchronization and compression formats, making their collected datasets unsuitable for training and only suitable as test sets, which limited the use of the datasets. It is hoped that this program can help everyone quickly and cost-effectively solve this problem.

Requirments

It is recommend using the packaged .exe executable file, which can be run by double-clicking in the Windows operating system.

If you need to run from source code, please refer to the following:
pip install -r requirements.txt (python 3.6)
For other python environments (like python 3.8), the hid package may not be installed successfully. You may need to install it mannually and put the hid.pyd (hid.cp38-win_amd64.pyd for example) file with main.py as a module. The details of installation could refer to hidapi 0.14.0.

Setup

First, you need to run Contec SpO2 Assistant and connect to the device via HID (currently not supporting devices with COM ports). When the SpO2 Assistant displays waveforms, PhysRecorder can synchronously read waveform data.

image

Setting

The user interface has multiple options for selection, allowing users to determine the recording duration, video resolution, camera transmission format, and file storage format. At the top are three indicator icons for users to confirm the BVP signal reading status, camera signal reading status, and recording status.

image

File structure

To view examples, please download the Example folder.

Root
├── p001
    ├── v01                      
        ├── pictures_ZIP_RAW_RGB    # PNGS format.
            ├── 00000000.png        # PNG lossless pictures.
            ├── 00000001.png
            ├── ...
        ├── video_ZIP_H264.avi      # H264 format.
        ├── video_ZIP_MJPG.avi      # MJPG format.
        ├── video_RAW_I420.avi      # YUV420 lossless format.
        ├── video_RAW_RGBA.avi      # RGBA lossless format.
        ├── video_ZIP_RAW_BGRA.avi  # FFV1 lossless format.
        ├── BVP.csv                 # BVP wavefrom with UNIX timestamps.
        ├── HR.csv                  # Heart rate with UNIX timestamps.
        ├── SpO2.csv                # Blood oxygen saturation level (SpO2) with UNIX timestamps.
        ├── frames_timestamp.csv    # UNIX timestamps for each frame.
        ├── info.txt                # Information related to video recording.
        ├── missed_frames.csv       # If all frames are written correctly to the file, it is empty. 
    ├── ... 
├── ...

Compatible with PhysBench

If you have collected your own dataset, it is recommended to use PhysBench for training and testing. See https://github.com/KegangWangCCNU/PhysBench
For the collected single video, you can use inference.py in PhysBench to extract BVP signals.

Use Seq-rPPG to extract BVP signals from the Example

image
The above video was recorded using PhysRecorder and saved in the Example folder. To extract the BVP signal using PhysBench, use the following command:
python inference.py --video face.avi --out BVP.csv
Visualize them:
image
The BVP waveforms extracted from different video formats are shown from top to bottom, and it can be seen that the H264 format causes significant damage to physiological signals.

Precautions:

To ensure high synchronization, higher device performance is required.

Recommended configuration: 8-core or higher CPU and SSD hard drive.
It is strongly discouraged to use USB portable hard drives!

Citation

If you use PhysRecorder, please cite the following <a href="https://github.com/KegangWangCCNU/PICS/raw/main/PhysBench.pdf" target="_blank">paper</a>

@misc{wang2023physbench,
      title={PhysBench: A Benchmark Framework for Remote Physiological Sensing with New Dataset and Baseline}, 
      author={Kegang Wang and Yantao Wei and Mingwen Tong and Jie Gao and Yi Tian and YuJian Ma and ZhongJin Zhao},
      year={2023},
      eprint={2305.04161},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}