In the preceding section, we created our new application, Facetious, with which we can play the video feed from our camera and take photos. In this section, we will add a new feature to it—detecting faces in videos in real time by using the OpenCV library.
We will use some facilities called cascade classifiers, which are offered by OpenCV, to detect faces. A cascade classifier is not only used to detect faces, but it is also used to detect objects. As a classifier, it tells us whether a certain region of interest in an image is a certain type of object or not. The classifier contains several simpler classifiers or stages and subsequently applies these simpler classifiers to a region of interest. If any simpler classifier gives a negative result, we say the region of interest does not contain any objects of interest. Otherwise, if...