How to extract frames in opencv 3.0 c++?
I want to extract frames from a video file.But how will i know at what fps to extract the frames? I have been using the code below but
long frameCounter = 0;
std::time_t timeBegin = std::time(0);
int tick = 0;
cv::Mat frame;
while (1)
{
cam.read(frame);
cv::imshow("Img", frame);
cv::waitKey(1);
frameCounter++;
std::time_t timeNow = std::time(0) - timeBegin;
if (timeNow - tick >= 1)
{
tick++;
cout << "Frames per second: " << frameCounter << endl;
frameCounter = 0;
}
}
time() counts in whole seconds, far too coarse for your means.
Can you give me an idea what should i use instead of time()?
maybe:
(though beware, this measures clock time, not wall time)
okay thanks
but if you just want all frames, then grab frames until the frame is empty. You do not need the framerate for that ...
Can I use the gettickcount() function for frames?