zhaodongsun / contrast-phys

[TPAMI & ECCV 2022] Contrast-Phys & Contrast-Phys+ for facial video-based remote physiological signal measurement
https://ieeexplore.ieee.org/document/10440521
MIT License
60 stars 12 forks source link

About preprocessing. py(BVP) #11

Open ldxbxl opened 3 months ago

ldxbxl commented 3 months ago

I would like to know when using OpenFace to generate .csv file during data preprocessing, as one of the inputs of preprocessing. py, which part of preprocessing. py represents the generated .h5 contains the content of bvp signal? I read my own generated.h5 file containing only {'imgs': }

ldxbxl commented 3 months ago

I would like to know when using OpenFace to generate .csv file during data preprocessing, as one of the inputs of preprocessing. py, which part of preprocessing. py represents the generated .h5 contains the content of bvp signal? I read my own generated.h5 file containing only {'imgs': }

I'm sorry that I didn't see the answer to the previous relevant questions. Now I know that the bvp related content needs to be added manually in the.h5 file during the test. May I ask how to add the bvp information specifically?

zhaodongsun commented 3 months ago

Hi, the bvp has the same sampling rate as the video frames. e.g., video is 30 fps, so the bvp should be 30Hz. Therefore, the temporal lengths of both bvp and imgs should be the same. If imgs has the shape (T, H, W, 3), the bvp should have the shape (T,). You can easily add bvp to .h5 file as shown below.

with h5py.open('xxxxx', 'r+') as f:
    f['bvp'] = bvp
ldxbxl commented 3 months ago

Hi, the bvp has the same sampling rate as the video frames. e.g., video is 30 fps, so the bvp should be 30Hz. Therefore, the temporal lengths of both bvp and imgs should be the same. If imgs has the shape (T, H, W, 3), the bvp should have the shape (T,). You can easily add bvp to .h5 file as shown below.

with h5py.open('xxxxx', 'r+') as f:
    f['bvp'] = bvp

Thanks for your answer.

I applied for the ubfc-rppg dataset, in which dataset2 folder each video contains the corresponding groundturth.txt, how should I deal with them and merge them into.h5? I used the following code to merge. import numpy as np import h5py

bvp_data = np.loadtxt('dataset/ubfc-rppg/UBFC_DATASET/DATASET_2/subject49/ground_truth.txt')

with h5py.File('dataset/ubfc-rppg/UBFC_DATASET/DATASET_2/h5withbvp/49.h5', 'r+') as f:

f.create_dataset('bvp', data=bvp_data)

I use the following code to output the contents of the keys to test.py's.npy file. The output is Loaded data keys: dict_keys(['rppg_list', 'bvp_list']).

def main(): npy_file = "/contrast-phys/results/11/4/38.npy" try: data = np.load(npy_file, allow_pickle=True).item() print("Loaded data keys:", data.keys())

ldxbxl commented 3 months ago

Hi, the bvp has the same sampling rate as the video frames. e.g., video is 30 fps, so the bvp should be 30Hz. Therefore, the temporal lengths of both bvp and imgs should be the same. If imgs has the shape (T, H, W, 3), the bvp should have the shape (T,). You can easily add bvp to .h5 file as shown below.

with h5py.open('xxxxx', 'r+') as f:
    f['bvp'] = bvp

Thanks for your answer.

I applied for the ubfc-rppg dataset, in which dataset2 folder each video contains the corresponding groundturth.txt, how should I deal with them and merge them into.h5? I used the following code to merge. import numpy as np import h5py

bvp_data = np.loadtxt('dataset/ubfc-rppg/UBFC_DATASET/DATASET_2/subject49/ground_truth.txt')

with h5py.File('dataset/ubfc-rppg/UBFC_DATASET/DATASET_2/h5withbvp/49.h5', 'r+') as f:

f.create_dataset('bvp', data=bvp_data)

I use the following code to output the contents of the keys to test.py's.npy file. The output is Loaded data keys: dict_keys(['rppg_list', 'bvp_list']).

def main(): npy_file = "/contrast-phys/results/11/4/38.npy" try: data = np.load(npy_file, allow_pickle=True).item() print("Loaded data keys:", data.keys())

Upon further inspection I found that the.npy generated by test.pys is an empty array