I suggest you to read this post in order to see the main research on the topic of eyeglasses detection, recognition and so on:
http://answers.opencv.org/question/19...
You can add to this list another recently published algorithm based on local binary pattern:
Glasses detection on real images based on robust alignment
This algorithm works as follows.
First of all, this work starts with location of the face using the algorithm by Viola & Jones. At this step you could
use another face detection algorithm (see https://github.com/nenadmarkus/pico or http://blog.dlib.net/2014/02/dlib-186...)
After the face is located in the image, some preprocessing is necessary in order to deal
with pose, rotation, scale and inaccuracies of the located face. A face normalization algorithm is applied
to get the region around the eyes. Afterwards, LBP and Robust LBP are applied in order to get the feature sets.
Finally, Support Vector Machine (SVM) is applied on the classiffication step. SVM is applied to
classify the extracted feature histograms over the normalized eyes glasses regions. The output of the SVM
classiffier is a two-class clasiffication problem i.e. glasses vs no glasses.
The face normalization algorithm relies on a detector of facial landmarks.
When the shape or intensity characteristics of the eyes cannot be reliably measured due to occlusion (like wear-
ing glasses or sunglasses), the context characteristics are very useful for eye localization. This is because eyes
in the face context usually have stable relationship with other facial features in terms of both appearance and
structure distribution. In this way, a detector of facial landmarks (http://cmp.felk.cvut.cz/~uricamic/fla... or http://cmp.felk.cvut.cz/~uricamic/cla...) learned by structured output SVM has been applied in order to detect the positions of the main points of the face and hence, of the eyes.
To sum up, the input is a still image containing a single face. The output is estimated locations of a set of facial landmarks.
The face aligment algorithm is explained here:
http://answers.opencv.org/question/24...
The face normalization algorithm is explained here:
http://answers.opencv.org/question/64...
How to know if a person is wearing a hat
You could use this same approach but in order to know if a person is wearing a hat or not, you can use the upper part of
the face instead the region of the eyes.