This can be achieved by dividing the problem into two:
1. Face detection in the image.
2. emotion detection.
For the first, you can simply use the haarcascades available with openCV download.
Once you have detected the face, try matching the ROI versus a database of images of emotions, try to find the closest matching element and assign the same classification/label. Else Detect interesting face points, like nose tip, mouth corners, eye locations, closed/open lids and determine a relation between this elements for each mood.
First approach is possible by applying an abstract representation of the image (eigenFaces, fisherFaces) creating a unique representation of each mood and fitting a codebook feature vector to it. Then match vectors using a distance measure to find the best match.
Interesting links for you:
http://www.scholarpedia.org/article/F... http://docs.opencv.org/trunk/modules/... http://docs.opencv.org/trunk/modules/...
This should give a nice start !