// Background subtraction (works on processing 0115 Beta) // (c) Andrew Senior 2006 http://www.andrewsenior.com // Preserve this header when redistributing. import JMyron.*; PImageOperations PImOps; JMyron m;//a camera object int iThreshold=190; PBGS pBackground; boolean iSetNext=true; void setup(){ // Set this to your video source's size size(352,288, P3D); // size(320,240, P3D); colorMode(RGB, 255); PImOps=new PImageOperations(); m = new JMyron();//make a new instance of the object m.start(width,height);//start a capture at 320x240 PImage FG=new PImage(m.image(), width, height, RGB); //get the difference image of the camera pBackground=new PBGS(FG); rectMode(CENTER); framerate=10; noStroke(); } void draw(){ m.update();//update the camera view from JMyron int [] piThisFrame=m.image(); // get the camera view from JMyron PImage FG=new PImage(piThisFrame, width, height, ARGB); //put this into a PImage if (iSetNext) { pBackground.Set(FG); iSetNext=false; } pBackground.Update(FG); // Update the background model loadPixels(); pBackground.PutDifference(); // Put the difference on the screen updatePixels(); } // force update of the background model when the mouse is clicked. void mousePressed(){ iSetNext=true; //m.settings();//click the window to get the video devicesettings }