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 (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).
Use Patent Claims
Include Install Instructions
These details are provided for information only. No information here is legal advice and should not be used as such.