I used this code in my ISEA/San Jose Zero One workshop on "Computer vision for Artists"
it's not meant to be fast, more to demonstrate the principles, from frame differencing and adaptation to morphology and connected components. The code is designed to use JMyron by Josh Nimoy, but could be adapted to use the video module of processing. I've designed some of my own new classes but it's based around the pimage class of processing.
I am making the code publicly available in gratitude for all the great free software out there, in particular processing and JMyron. You are welcome to use the code for your own projects, just preserve the attribution in the code, and please credit me and link to my web site where possible.
The code can be found in a zip file here or as individual files:
See also the simple keepmax program using JMyron and processing.