Finishing touches—making a nice and interactive GUI

While the code given so far in this chapter is sufficient for a whole face recognition system, there still needs to be a way to put the data into the system and a way to use it. Many face recognition systems for research will choose the ideal input to be text files, listing where the static image files are stored on the computer, as well as other important data, such as the true name or identity of the person, and perhaps true pixel coordinates of regions of the face (such as the ground truth of where the face and eye centers actually are). This would either be collected manually or by another face recognition system.

The ideal output would then be a text file comparing the recognition results with the ground truth, so that statistics may be obtained for comparing the face recognition system with other face recognition systems.

However, as the face recognition system in this chapter is designed for learning as well as practical fun purposes, rather than competing with the latest research methods, it is useful to have an easy-to-use GUI that allows face collection, training, and testing interactively from the webcam in real time. So this section will show you an interactive GUI that provides these features. The reader is expected to either use the GUI that comes with this book, or modify it for their own purposes, or ignore this GUI and design their own to perform the face recognition techniques discussed so far.

As we need the GUI to perform multiple tasks, let's create a set of modes or states that the GUI will have, with buttons or mouse clicks for the user to change modes:

To quit, the user can hit the Esc key in the window at any time. Let's also add a Delete All mode that restarts a new face recognition system, and a Debug button that toggles the display of extra debug information. We can create an enumerated mode variable to show the current mode.