buffer part
This commit is contained in:
parent
59db00254d
commit
3da94d12ff
15
ppg.cpp
15
ppg.cpp
|
|
@ -9,6 +9,7 @@ const int FPS = 30;
|
||||||
bool isDiscardData = true;
|
bool isDiscardData = true;
|
||||||
int countDiscard = 0;
|
int countDiscard = 0;
|
||||||
const int DISCARD_DURATION = 10;
|
const int DISCARD_DURATION = 10;
|
||||||
|
const int BUFFER_DURATION = 60;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
cv::VideoCapture cap;
|
cv::VideoCapture cap;
|
||||||
|
|
@ -42,6 +43,20 @@ int main() {
|
||||||
faceDetector.detectMultiScale(frame, faceRectangles, 1.1, 3, 0,cv::Size(20, 20));
|
faceDetector.detectMultiScale(frame, faceRectangles, 1.1, 3, 0,cv::Size(20, 20));
|
||||||
foreheadROI = faceRectangles[0];
|
foreheadROI = faceRectangles[0];
|
||||||
foreheadROI.height *= 0.3;
|
foreheadROI.height *= 0.3;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
cv::rectangle(frame, faceRectangles[0], cv::Scalar(0, 0, 255), 1, 1, 0);
|
cv::rectangle(frame, faceRectangles[0], cv::Scalar(0, 0, 255), 1, 1, 0);
|
||||||
cv::rectangle(frame, foreheadROI, cv::Scalar(0, 255, 0), 1, 1, 0);
|
cv::rectangle(frame, foreheadROI, cv::Scalar(0, 255, 0), 1, 1, 0);
|
||||||
cv::imshow("Color", frame);
|
cv::imshow("Color", frame);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue