I created this demo to make it easy for people to play around with face detection, and get an idea of what the various options in OpenCV do.
For an explanation of how face detection works using the Viola-Jones algorithm see this interview with Adam Harvey.
See this StackOverflow question for a brief explanation.