In the preceding section, we learned how to access the cameras attached to our computer, as well as getting the information of all the cameras, playing the video that was captured from a camera in real time, and calculating the frame rate of a camera. In this section, we will learn how to record videos from the camera.
The principle of recording videos is simple: while we are capturing frames from a camera, we compress each frame in a certain way and write it to a video file. The VideoWriter class in the videoio module of the OpenCV library provides a convenient way to do this, and we will use it to record videos in this section.
Before we start with the work of recording videos, we should do some preparation work for our application, for example, where to save the video and how to name each video file. To resolve these prerequisites, we will create an assistant...