Nowadays, everyone is using Facebook and you all must have seen facial recognition in an image on Facebook. Facial recognition identifies who a face belongs to and face detection only finds faces in an image, that is, face detection does not determine to whom the detected face belongs. Face detection in a given input image is quite a popular functionality in lots of applications; for example, counting the number of people in an image. In face detection, the algorithm tries to find human faces in a digital image.
Face detection is a kind of classification problem. We can classify images into two classes, face or not face. We need lots of images to train such a model for classification. Thankfully, OpenCV offers pre-trained models such as the Haar Feature-Based Cascade Classifier and the Local Binary Pattern (LBP) classifier, trained on thousands of images. In our example, we will use Haar feature extraction to detect a face. Let's see how to capture a face in an image...