diff --git a/OpTests b/OpTests index b18b3cc..5abbd2d 100755 Binary files a/OpTests and b/OpTests differ diff --git a/ppg.cpp b/ppg.cpp index 69f855d..aba7393 100644 --- a/ppg.cpp +++ b/ppg.cpp @@ -96,22 +96,43 @@ int main() //! [start] cv::Mat rgbmat; + + bool isDiscardData = true; + int countDiscard = 0; + const int DISCARD_DURATION = 5;//maybe do a float? + const int FPS = 30;//can actually switch to 15fps in low light, but for this application it is not very important + std::cout << "beginning loop" << std::endl; while(!protonect_shutdown) { listener.waitForNewFrame(frames); libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color]; cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data).copyTo(rgbmat); - cv::imshow("rgb", rgbmat); - + if(cv::waitKey(1) >= 0){//the listener waits for frames, there is no need to limit speed ourselves protonect_shutdown = true; } - - listener.release(frames); + + + + + cv::imshow("rgb", rgbmat); + + if(isDiscardData){ + countDiscard++; + if(countDiscard == DISCARD_DURATION*FPS){ + isDiscardData = false; + std::cout << "not discarding data anymore" << std::endl; + } + + continue; + } + + + } //! [loop end]