Average Green Value Found in the ROI

This commit is contained in:
Thomas PÉRIN 2023-02-24 11:18:10 +01:00
parent e9ae38eae7
commit f76e338c9f
1 changed files with 17 additions and 0 deletions

17
ppg.cpp
View File

@ -8,6 +8,7 @@ const int FPS = 30;
bool isDiscardData = true; bool isDiscardData = true;
int countDiscard = 0; int countDiscard = 0;
const int DISCARD_DURATION = 5; const int DISCARD_DURATION = 5;
const int BUFFER_DURATION = 30;
int main() int main()
{ {
@ -62,6 +63,22 @@ int main()
cv::imshow("Your Face PLS", frame); cv::imshow("Your Face PLS", frame);
if (cv::waitKey(1000.0/FPS) >= 0) if (cv::waitKey(1000.0/FPS) >= 0)
break; break;
cv::Mat frame_forehead = frame(foreheadROI);
cv::Scalar avg_forehead = mean(frame_forehead);
bool isBufferFull = false;
int sampleIdBuffer = 0;
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;
}
}
} }
} }
return 0; return 0;