This commit is contained in:
Ly PECHVATTANA 2023-02-24 10:46:49 +01:00
parent e515e8f5fa
commit 76f2e9de06
1 changed files with 23 additions and 15 deletions

18
ppg.cpp
View File

@ -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,11 +19,14 @@ int main() {
}
while (true) {
// create a matrix to store the image from the cam
if(isDiscardData){
countDiscard++;
if(countDiscard == DISCARD_DURATION*FPS)
isDiscardData = false;
}
else{
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;
@ -27,6 +35,6 @@ int main() {
if (cv::waitKey(1000.0 / FPS) >= 0)
break;
}
}
return 0;
}