Yes, you can do this easily with OpenCV's built-in Haar classifiers, and you'll find a lot of demos and tutorials online for that. You don't need to find the Z position, just the face size. More important to you will be eye position - and there are Haar classifiers for that too. You can find a face region, and then find the eye regions within that region, and you'll have a very good basis for positioning your eyeglass overlay on the subject. There are lots of tweaks to speed up the process, like downsampling and telling the classifier to search for only one face. Good luck.