// A background subtraction class // (c) Andrew Senior 2006 http://www.andrewsenior.com // Preserve this header when redistributing. class PBGS { float [] m_Background; // The background model has to be float because of quantization effects PImage m_Difference; float m_fBlend=0.99; float m_fComp=1-m_fBlend; int m_iWidth; int m_iHeight; // Create the background model to look like the start frame PBGS(PImage I) { m_iWidth=I.width; m_iHeight=I.height; m_Background=new float[I.width* I.height*3]; m_Difference=new PImage(I.pixels, I.width, I.height, RGB); Set(I); } // Set the background image to the given image void Set(PImage I) { for(int i=0; i