There are plenty of examples that show how to use background subtraction and blob detection, but they are pretty terrible. This is a simple program that showcases background subtraction, blob detection, and face detection complete with code comments.
This uses the Processing.org
... [More] (http://processing.org) and OpenCV compiled for Java (http://ubaa.net/shared/processing/opencv/) libraries.
I've written this for the Eclipse environment but it could be easily changed for the Processing environment (just remove the class definition, the main function, and any 'public' tags). [Less]