added green channel mean code
This commit is contained in:
parent
e03373be5f
commit
7c71df48c9
18
ppg.cpp
18
ppg.cpp
|
|
@ -11,6 +11,9 @@ int DISCARD_DURATION=5;
|
|||
bool isDiscardData=true;
|
||||
int countDiscard=0;
|
||||
|
||||
bool isBufferFull = false; //buffer variables to initialise before main();
|
||||
int sampleIdBuffer = 0;
|
||||
int BUFFER_DURATION= 5;
|
||||
|
||||
int main(){
|
||||
//Print "PPG algorithm" to terminal
|
||||
|
|
@ -71,6 +74,21 @@ int main(){
|
|||
cv::Rect foreheadROI; //create a forehead ROI equal to the face ROI slightly moved upward.
|
||||
foreheadROI = faceRectangles[0];
|
||||
foreheadROI.height *= 0.3;
|
||||
|
||||
cv::Mat frame_forehead = frame(foreheadROI);
|
||||
cv::Scalar avg_forehead = mean(frame_forehead); //calculates mean of object frame_forehead
|
||||
|
||||
//Buffer of average value for the green channel over the forehead ROI
|
||||
cv::Mat greenSignal(1, FPS*BUFFER_DURATION, CV_64F);
|
||||
if (!isBufferFull)
|
||||
{
|
||||
greenSignal.at<double>(0, sampleIdBuffer) = avg_forehead[1] ;
|
||||
sampleIdBuffer++;
|
||||
if (sampleIdBuffer == FPS*BUFFER_DURATION)
|
||||
{
|
||||
isBufferFull = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue