This is a complex subject that requires much learning. I'd suggest you start by looking at OpenCV - http://opencv.willowgarage.com/wiki/ - a computer vision library with tutorials etc. Partly it is about not so much a "general face" but about picking out features, and then running a metric - like how far apart or relative orientation of those features.