Motion Sensor

rememberthis's icon

Hello, I am new to Max/msp jitter and although I am beginning to understand the basics, I am having a little trouble with this. I would like to use my computers on board webcam to sense motion and then play an audio clip if motion is detected. In other words, I would like to detect motion then send a single bang message to toggle a clip on if motion is present. I know this has been done, and I have browsed the forums but haven't quite found anything explaining the Max side of things. Can anyone show me an example or please point me in the right direction.
Thanks,
Logan

Zachary Seldess's icon

Hi Logan,

Here's a simple example that should get you going.

best,
Zachary

Max Patch
Copy patch and select New From Clipboard in Max.

rememberthis's icon

Hi Zachary,
Thank you for the patch. I ultimately came to roughly the same concept yesterday, however your patch got the job done in a much more clear and concise manner, I appreciate the help.
Best regards,
Logan

Zachary Seldess's icon

Glad to help, Logan.

Here's the same patch, but with another part using cv.jit.sum

best,
Zachary

Max Patch
Copy patch and select New From Clipboard in Max.

Tale Twist's icon

Great thanks a lot. I am planning to use the data to toggle different movie clips. What should I be looking for to add to this patch?

yaniki's icon

Hello Tale Twist

Zachary's patch is a very good start point but you may be also interested in these topics:

- https://cycling74.com/forums/using-jitter-in-max-to-create-webcam-grid/replies/1#reply-5a1ac04634c6d67d68541565 (there is an example patch in my post, which may be inspiring for you - it's an old stuff, but still works and as a general algorithm also is simple to transform into something more connected to the current jitter techniques (e.g. processing on GPU);

- https://cycling74.com/forums/sharing-is-maxmspjitter-and-p5js (just follow the link, grab the ZIP I posted in this topic and check the second example).