def _computeBGDiff(self):
        self._flow.update( self._imageBuffer.getLast() )
        
        n = len(self._imageBuffer)        
        prev_im = self._imageBuffer[0]
        forward = None
        for i in range(0,n/2):
            if forward == None:
                forward = self._imageBuffer[i].to_next
            else:
                forward = forward * self._imageBuffer[i].to_next
                
        w,h = size = prev_im.size
        mask = cv.CreateImage(size,cv.IPL_DEPTH_8U,1)
        cv.Set(mask,0)
        interior = cv.GetSubRect(mask, pv.Rect(2,2,w-4,h-4).asOpenCV()) 
        cv.Set(interior,255)
        mask = pv.Image(mask)

        prev_im = forward(prev_im)
        prev_mask = forward(mask)
        

        next_im = self._imageBuffer[n-1]
        back = None
        for i in range(n-1,n/2,-1):
            if back == None:
                back = self._imageBuffer[i].to_prev
            else:
                back = back * self._imageBuffer[i].to_prev
        
        next_im = back(next_im)
        next_mask = back(mask)
        
        curr_im = self._imageBuffer[n/2]

                
        prevImg = prev_im.asMatrix2D()
        curImg  = curr_im.asMatrix2D()
        nextImg = next_im.asMatrix2D()
        prevMask = prev_mask.asMatrix2D()
        nextMask = next_mask.asMatrix2D()

        # Compute transformed images
        delta1 = sp.absolute(curImg - prevImg)   #frame diff 1
        delta2 = sp.absolute(curImg - nextImg)   #frame diff 2
        
        delta1 = sp.minimum(delta1,prevMask)
        delta2 = sp.minimum(delta2,nextMask)
        
        #use element-wise minimum of the two difference images, which is what
        # gets compared to threshold to yield foreground mask
        return sp.minimum(delta1, delta2)
dataset/ETHPy150Open bolme/pyvision/src/pyvision/surveillance/BackgroundSubtraction.py/MotionCompensatedFrameDifferencer._computeBGDiff/swapped operands of `-`