Now that we understand how to detect faces, we can generalize that concept to detect different parts of the face. We will be using an eye detector to overlay sunglasses in a live video. It's important to understand that the Viola-Jones framework can be applied to any object. The accuracy and robustness will depend on the uniqueness of the object. For example, the human face has very unique characteristics, so it's easy to train our system to be robust. On the other hand, an object such as a towel is too generic, and it has no distinguishing characteristics as such, so it's more difficult to build a robust towel detector. Once you build the eye detector and overlay the glasses, it will look something like this:
Let's look at the main parts of the code:
...
int main(int argc, char* argv[]) { string faceCascadeName = argv[1]; ...