Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You need to read in a certain number of frames. Like this:

#pragma comment(lib, "opencv_world340.lib")

#include <opencv2/opencv.hpp>
using namespace cv;

#include <iostream>
#include <vector>
using namespace std;

int main(void)
    VideoCapture vid_in;"test.avi");

    long unsigned int fps = static_cast<long unsigned int>(vid_in.get(CV_CAP_PROP_FPS));
    long unsigned int seconds = 3;
    long unsigned int total_frames = fps*seconds;

    vector<Mat> mat_vector;

    for (long unsigned int i = 0; i < total_frames; i++)
        Mat frame;
        vid_in >> frame;

        if (frame.empty())
            cout << "Frame read error" << endl;
            return 0;


    cout << mat_vector.size() << endl;

    return 0;