From 7c71df48c923b5fc86438784734cecab32242fb6 Mon Sep 17 00:00:00 2001 From: Nicolas TRAGLIA Date: Mon, 27 Feb 2023 19:28:26 +0100 Subject: [PATCH] added green channel mean code --- ppg.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ppg.cpp b/ppg.cpp index 7d2b8ef..0e1b1cc 100644 --- a/ppg.cpp +++ b/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(0, sampleIdBuffer) = avg_forehead[1] ; + sampleIdBuffer++; + if (sampleIdBuffer == FPS*BUFFER_DURATION) + { + isBufferFull = true; + } + } } } }