def getModelFromData(data):
    """
    get translation model from data - data consists of sets of point pairs (p,p')
    p' = p + (tx,ty)
    p = (x,y)
    p' = (x',y')
    the translation model is just [tx,ty]
    a translation matrix T would be [[1 0 tx] [0 1 ty]]
    """
    sumdeltax = 0
    sumdeltay = 0
    if data is None: return None
    for pair in data:
        p = pair[0]
        pprime = pair[1]
        x = p[0]
        y = p[1]
        xprime = pprime[0]
        yprime = pprime[1]
        deltax = xprime-x
        deltay = yprime-y
        sumdeltax += deltax
        sumdeltay += deltay
    npairs = len(data)
    avgdeltax = float(sumdeltax) / npairs
    avgdeltay = float(sumdeltay) / npairs
    tx = avgdeltax
    ty = avgdeltay
    model = [tx, ty]
    return model