Working with video stored on a computer

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); ...

Get Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.