Manipulating images with the OpenCV and Dlib libraries

Many machine learning algorithms are related to computer vision problems. Such tasks are object detection in images, segmentation, image classification, and others. To be able to deal with such tasks, we need instruments for working with images. We usually need routines to load images to computer memory, as well as routines for image processing. For example, the standard operation is image scaling, because many machine learning algorithms are trained only on images of a specific size. This limitation follows from the algorithm structure or is a hardware requirement. For example, we cannot load large images to the graphics processing unit (GPU) memory because of its limited size.

Also, hardware requirements can lead to a limited range of numeric types our hardware supports, so we will need to change initial image representation to one that our hardware can efficiently process. Also, machine learning algorithms usually assume a predefined layout of image channels, which can be different from the layout in the original image file.

Another type of image processing task is the creation of training datasets. In many cases, we have a limited number of available images for a specific task. However, to make a machine algorithm train well, we usually need more training images. So, the typical approach is to augment existing images. Augmentation can be done with operations such as random scaling, cropping parts of images, rotations, and other operations that can be used to make different images from the existing set.

In this section, we show how to use two of the most popular libraries for image processing for C++. OpenCV is a framework for solving computer vision problem that includes many ready-to-use implementations of computer vision algorithms. Also, it has many functions for image processing. Dlib is a computer vision and machine learning framework with a large number of implemented algorithms, as well as a rich set of image processing routines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.194.123