if __name__ == '__main__':

    with open('bundle.out') as fp:
        aa = fp.readlines()

    Nc = int(aa[1].split(' ')[0])

    Lori = zeros((Nc, 3,3))
    for n in range(Nc):
        for j in range(3):
            Lori[n,j] = array([float(x) for x in aa[3+n*5+j].split(' ')])

    Lq = zeros((Nc,4))
    for n in range(Nc):
        ori = Quat(mtq(Lori[n]))
        Lq[n] = ori.normalize().q * array([1,-1,1,1])

    ## Read the tardiff output





    ## Get orientations ordered by frame number
    Lr = loadtxt('tardiff_undistorted_quaternions.dat')

    ## fix and normalize reference quaternions.
    fix_reference_quaternions(Lr)

    Le = zeros((Nc,4))
    La = zeros(Nc)