Awhile ago, fiddled with some code on that.

Checkout the project here..
https://seanlon.github.io/face-detection/examples/emotion.html

You can find and play with source code here.
https://seanlon.github.io/face-detection/