File size: 1,534 Bytes
39b4c8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import h5py
import numpy as np
from pyVHR.datasets.dataset import Dataset
from pyVHR.signals.bvp import BVPsignal

class COHFACE(Dataset):
    """
    Cohface dataset structure:
    -----------------
        datasetDIR/
        |
        |-- subjDIR_1/
        |   |-- vidDIR1/
        |       |-- videoFile1.avi
        |       |-- ...
        |       |-- videoFileN.avi
        |...
        |   |-- vidDIRM/
        |       |-- videoFile1.avi
        |       |-- ...
        |       |-- videoFileM.avi
        |...
        |-- subjDIR_n/
        |...
    """
    name = 'COHFACE'
    signalGT = 'BVP'         # GT signal type
    numLevels = 2            # depth of the filesystem collecting video and BVP files
    numSubjects = 40         # number of subjects
    video_EXT = 'avi'        # extension of the video files
    frameRate = 20           # vieo frame rate
    VIDEO_SUBSTRING = 'data' # substring contained in the filename
    SIG_EXT = 'hdf5'         # extension of the BVP files
    SIG_SUBSTRING = 'data'   # substring contained in the filename
    SIG_SampleRate = 256     # sample rate of the BVP files
    skinThresh = [40,60]     # thresholds for skin detection

    def readSigfile(self, filename):
        """ Load BVP signal.
            Must return a 1-dim (row array) signal
        """

        f = h5py.File(filename, 'r')
        data = np.array(f['pulse'])        # load the signal
        data = data.reshape(1,len(data))   # monodimentional signal

        return BVPsignal(data, self.SIG_SampleRate)