Let's begin this project with the middle layer, the Interactive Recognizer app, in order to see how all layers connect. Like Luxocator (the previous chapter's project), Interactive Recognizer is a GUI app built with wxPython. Refer to the following screenshot, which features one of my colleagues, Chief Science Officer Sanibel "San" Delphinium Andromeda, Oracle of the Numm:
The app uses a face detection model, which is loaded from a disk, and it maintains a face recognition model that is saved or loaded to/from a disk. The user might specify the identity of any detected face and this input is added to the face recognition model. A detection result is shown by outlining the face in the video feed, while a recognition result is shown by displaying the name of the face in the text below. To elaborate, we can say that the app has the following flow of execution:
Joe
or Puss
. When the user hits the Add to Model button, the model becomes trained to recognize the face as whomever the user specified (Joe
, Puss
, or another identity).We will use a type of detection model called a Haar cascade and a type of recognition model called Local Binary Patterns (LBP) or Local Binary Pattern Histograms (LBPH). Alternatively, we can use LBPH for both detection and recognition. As detection models, LBP cascades are faster but generally less reliable, compared to Haar cascades. OpenCV comes with some Haar cascade and LBP cascade files including several face detection models. Command-line tools are also included with OpenCV along with these files. The APIs offer high-level classes for loading and using Haar or LBP cascades and for loading, saving, training, and using LBPH recognition models. Let's look at the basic concepts of these models.