File size: 834 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
from scipy import signal
import numpy as np
from .base import VHRMethod

class CHROM(VHRMethod):
    """ This method is described in the following paper:
        "Remote heart rate variability for emotional state monitoring"
        by Y. Benezeth, P. Li, R. Macwan, K. Nakamura, R. Gomez, F. Yang
    """
    methodName = 'CHROM'
    
    def __init__(self, **kwargs):
        super(CHROM, self).__init__(**kwargs)
        
    def apply(self, X):

        #self.RGB = self.getMeanRGB()
        #X = signal.detrend(self.RGB.T)
        
        # calculation of new X and Y
        Xcomp = 3*X[0] - 2*X[1]
        Ycomp = (1.5*X[0])+X[1]-(1.5*X[2])

        # standard deviations
        sX = np.std(Xcomp)
        sY = np.std(Ycomp)

        alpha = sX/sY

        # -- rPPG signal
        bvp = Xcomp-alpha*Ycomp

        return bvp