In this chapter, we saw that working with images and files is a key element of computer vision projects. A common approach in this kind of project is to load some images first, perform some processing, and then output the processed images. In this chapter, we reviewed this flow. Additionally, in connection with video streams, both cv2.VideoCapture and cv2.VideoWriter were covered. We also looked at the cv2.VideoWriter class for video writing. Two key aspects were reviewed when writing video files—video codecs (for example, DIVX) and video file formats (for example, AVI). To work with video codecs, OpenCV provides FOURCC, a four-byte code. Typical codecs are DIVX, XVID, X264, and MJPG, while typical video file formats are AVI (*.avi), MP4 (*.mp4), QuickTime (*.mov), and Windows Media Video (*.wmv).
We also reviewed the concept of fps and how to calculate it in our...