Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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;
        }
    }