I am writing a program to capture camera frames using opencv 2.49.
My problem is that the camera cap capture up to 500 FPS. But after the 5th frame capturing frames drop to 40 FPS and some times go beck to 500 FPS.
Could any one has an idea why is this happening? how I can fix capturing frames 500 FPS.
I have attached the output FPS
while(true)
{
cout << "\nStart while loop:" << endl;
auto t1 = chrono::high_resolution_clock::now();
Mat curFrame;
cap >> curFrame;
if( curFrame.empty() ) break; // end of video stream
auto t2 = chrono::high_resolution_clock::now();
auto cap_time = chrono::duration_cast<chrono::microseconds>( t2 - t1 ).count();
cout << "cap_time :" << cap_time << " microseconds, " << 1000000/(float)cap_time << " FPS" << endl;
imshow("Original", curFrame);
if (waitKey(1) >= 27)
{
cout << "esc key is pressed by user" << endl;
break;
}
}