added green channel mean code

This commit is contained in:
Nicolas TRAGLIA 2023-02-27 19:28:26 +01:00
parent e03373be5f
commit 7c71df48c9
1 changed files with 18 additions and 0 deletions

18
ppg.cpp
View File

@ -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;
}
}
}
}
}