In order to process a video sequence, we need to be able to read each of its frames. OpenCV has put in place an easy-to-use framework that can help us perform frame extraction from video files or even from USB or IP cameras. This recipe shows you how to use it.
Reading video sequences
How to do it...
Basically, all you need to do in order to read the frames of a video sequence is create an instance of the cv::VideoCapture class. You then create a loop that will extract and read each video frame. Here, we are going to explain how to code the main function to show each frame. The following steps will help us to read video sequences:
- Open a video capture with the following code:
int main() { // Open the video file cv...