Motion Detection with Processing & OSC

In case it’s of use to anyone, here’s the Processing code I’ve been using to detect motion in a space using a web cam, and to send that information to Max/MSP. The data is sent via Open Sound Control (OSC), so you’ll need to have installed this in Max before you start (it’s available here: http://cnmat.berkeley.edu/downloads). Although Matt Jackson tells me you can just use the UDP Receive object in Max.

I’ve since moved on to use a ‘blob’ detection solution, based on the Open Computer Vision framework (http://ubaa.net/shared/processing/opencv/) instead of this code – the data being sent to Max was too ‘jittery’ since it sends the location of every patch of screen area in which motion is detected, whereas what I really needed to monitor was the centre point of each person in the space, whether they’re moving or not.