discarding frames at the start
This commit is contained in:
parent
d78e094641
commit
14144ccd27
29
ppg.cpp
29
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]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue