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;
vid_in.open("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;
}
mat_vector.push_back(frame);
}
cout << mat_vector.size() << endl;
return 0;
}