#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
int main()
{
const std::string path = "../resources/test_video.mp4";
cv::VideoCapture cap(path);
if (!cap.isOpened())
{
std::cout << "Video cannot be opened!" << std::endl;
return -1;
}
const std::string wndName = "input";
cv::Mat frame;
int fps = 30; // this fps should be obtained from the metadata of the loaded movie.
while (cv::waitKey(1000 / fps) != 27) // press ESC to close prematurely
{
cap.read(frame);
if (frame.empty())
{
std::cout << "Found the end of video!" << std::endl;
break;
}
cv::imshow(wndName, frame);
}
return 0;
}
Thank you very much! It works!