diff --git a/ppg.cpp b/ppg.cpp index bbf699d..afe6ac5 100644 --- a/ppg.cpp +++ b/ppg.cpp @@ -2,7 +2,12 @@ #include "opencv2/videoio.hpp" #include "opencv2/highgui.hpp" -const int FPS = 15; +const int FPS = 30; + + +bool isDiscardData = true; +int countDiscard = 0; +const int DISCARD_DURATION = 10; int main() { cv::VideoCapture cap; @@ -14,19 +19,22 @@ int main() { } while (true) { - // create a matrix to store the image from the cam - cv::Mat frame; - // wait for a new frame from camera and store it into 'frame' - cap.read(frame); - // check if we succeeded - if (frame.empty()) { - std::cerr << "[ERROR] blank frame grabbed" << std::endl; - break; + if(isDiscardData){ + countDiscard++; + if(countDiscard == DISCARD_DURATION*FPS) + isDiscardData = false; + } + else{ + cv::Mat frame; + cap.read(frame); + if (frame.empty()) { + std::cerr << "[ERROR] blank frame grabbed" << std::endl; + break; + } + cv::imshow("Color", frame); + if (cv::waitKey(1000.0 / FPS) >= 0) + break; + } } - cv::imshow("Color", frame); - if (cv::waitKey(1000.0 / FPS) >= 0) - break; - } - - return 0; + return 0; }