O'Reilly logo

OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing video sequences

In the previous recipes, we learned how to read a video file and extract its frames. This recipe will show you how to write frames and therefore create a video file. This will allow us to complete the typical video processing chain: reading an input video stream, processing its frames, and then storing the results in a video file.

How to do it...

Let's expand our VideoProcessor class in order to give it the ability to write video files. This is done using the OpenCV cv::VideoWriter class. An instance of this is therefore added as a member of our class (plus few other member variables):

class VideoProcessor { private: ... // the OpenCV video writer object cv::VideoWriter writer; // output filename std::string outputFile; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required