Using Jitter in Max to create Webcam grid

Jonathan Pord's icon

I would like to create a small grid with my webcam. The goal is that when people pass over certain areas, it can trigger sounds. Basically I need certain areas of the camera to create a bang. I am having trouble getting started with jitter, so any information helps.

Thanks

Christopher Dobrian's icon

The jit.world object reports the position of mouse clicks in its display window. Alternatively, the jit.window object reports the position of the mouse in its display window even without clicking if the @mouseidle attribute is set. Look for the x and y coordinate values, and test to see whether they fall within particular regions in order to know where the mouse is in the window.

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

Jonathan Pord's icon

Thanks! Thats getting me closer to my goal. But how does motion in the display window become registered. For example: If I move my hand in the top right corner of the display window, how can I register that movement as a bang? Ideally Id like to divide the display window up so that different parts of the display window can be triggered by movement. Perhaps I am wrong in thinking this is possible. Maybe I need an infrared camera to detect movement instead?

Christopher Dobrian's icon

This is why clarity of expression is important. When you wrote "when people pass over certain areas", your meaning of "people" and "certain areas" were unclear. I thought you meant "when a viewer of the webcam image moves the mouse over a certain area of the display window". Apparently I was mistaken. It seems you meant "when the person in the webcam's image moves in a particular region of the image". For that, I recommend Jean-Marc Pelletier's cv.jit package of external objects for computer vision. http://jmpelletier.com/cvjit/

yaniki's icon

Agree with Christopher: cv.jit is great. But for simple motion detection on-the-grid you don't need any additional packages:

Here is a simple algorithm I'm typically using for this kind of tasks.

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

Christopher Dobrian's icon

Yes. That's a good, concise example for detecting change in regions of the image.

Jonathan Pord's icon

Thanks, a lot. This really helped me.

Tale Twist's icon

great. I will be playing around. thanks a lot for sharing