This section describes the process of reading a video file stored on a computer. All the frames from a video will be read one by one, operated upon, and displayed on the screen in all video processing applications using OpenCV.
The following code is for reading and displaying video—a line-by-line explanation is then given:
#include <opencv2/opencv.hpp>#include <iostream>using namespace cv;using namespace std;int main(int argc, char* argv[]){ //open the video file from PC VideoCapture cap("images/rhinos.avi"); // if not success, exit program if (cap.isOpened() == false) { cout << "Cannot open the video file" << endl; return -1; } cout<<"Press Q to Quit" << endl; String win_name = "First Video"; namedWindow(win_name); ...