def updateFilter(tpl):
    global COS_WINDOW
    global FILTER_STD
    global FILTER_NUM
    global FILTER_DEN
    global LEARNING_RATE

    height, width = tpl.shape
    ptpl = tpl * COS_WINDOW
    output = utils.genGaussianMatrix(width, height, (width / 2, height / 2), FILTER_STD)
    ftpl = np.fft.fft2(ptpl)
    foutput = np.fft.fft2(output)
    FILTER_NUM = LEARNING_RATE * (foutput * np.conj(ftpl)) + (1.0 - LEARNING_RATE) * FILTER_NUM
    FILTER_DEN = LEARNING_RATE * (ftpl * np.conj(ftpl)) + (1.0 - LEARNING_RATE) * FILTER_DEN
def initFilter(tpl):
    global COS_WINDOW
    global FILTER_INIT
    global FILTER_STD
    global FILTER_NUM
    global FILTER_DEN

    height, width = tpl.shape
    ptpl = tpl * COS_WINDOW
    output = utils.genGaussianMatrix(width, height, (width / 2, height / 2), FILTER_STD)
    ftpl = np.fft.fft2(ptpl)
    foutput = np.fft.fft2(output)
    FILTER_NUM = foutput * np.conj(ftpl)
    FILTER_DEN = ftpl * np.conj(ftpl)
    FILTER_INIT = True

    psr = utils.computePSR(output)