Exemplo n.º 1
0
def formatParameters(rVec, tVec, linearCoeffs, distCoeffs):
    params = Parameters()

    if prod(rVec.shape) == 9:
        rVec = Rodrigues(rVec)[0]

    rVec = rVec.reshape(3)

    for i in range(3):
        params.add('rvec%d'%i,
                   value=rVec[i], vary=True)
        params.add('tvec%d'%i,
                   value=tVec[i], vary=True)

    # image center
    params.add('cameraMatrix0',
               value=linearCoeffs[0], vary=False)
    params.add('cameraMatrix1',
               value=linearCoeffs[1], vary=False)

    # l and m
    params.add('distCoeffs0',
               value=distCoeffs[0], vary=False)
    params.add('distCoeffs1',
               value=distCoeffs[1], vary=False)
    return params
Exemplo n.º 2
0
def formatParameters(rVec, tVec, linearCoeffs, distCoeffs):
    params = Parameters()
    
    if prod(rVec.shape) == 9:
        rVec = Rodrigues(rVec)[0]
    
    rVec = rVec.reshape(3)
    
    for i in range(3):
        params.add('rvec%d'%i,
                   value=rVec[i], vary=True)
        params.add('tvec%d'%i,
                   value=tVec[i], vary=True)
    
    params.add('cameraMatrix0',
               value=linearCoeffs[0,0], vary=False)
    params.add('cameraMatrix1',
               value=linearCoeffs[1,1], vary=False)
    params.add('cameraMatrix2',
               value=linearCoeffs[0,2], vary=False)
    params.add('cameraMatrix3',
               value=linearCoeffs[1,2], vary=False)
    
    for i in range(4):
        params.add('distCoeffs%d'%i,
                   value=distCoeffs[i,0], vary=False)
    
    return params
Exemplo n.º 3
0
def formatParameters(rVec, tVec, linearCoeffs, distCoeffs):
    '''
    puts all intrinsic and extrinsic parameters in Parameters() format
    if there are several extrinsica paramters they are correctly 
    
    Inputs
    rVec, tVec : arrays of shape (n,3,1) or (3,1)
    distCoeffs must have be reshapable to (5)
    '''
    
    params = Parameters()
    
    if prod(rVec.shape) == 9:
        rVec = Rodrigues(rVec)[0]
    
    rVec = rVec.reshape(3)
    
    for i in range(3):
        params.add('rvec%d'%i,
                   value=rVec[i], vary=False)
        params.add('tvec%d'%i,
                   value=tVec[i], vary=False)
    
    if len(rVec.shape)==3:
        for j in range(len(rVec)):
            for i in range(3):
                params.add('rvec%d%d'%(j,i),
                           value=rVec[j,i,0], vary=False)
                params.add('tvec%d%d'%(j,i),
                           value=tVec[j,i,0], vary=False)
    
    params.add('fX',
               value=linearCoeffs[0,0], vary=False)
    params.add('fY',
               value=linearCoeffs[1,1], vary=False)
    params.add('cX',
               value=linearCoeffs[0,2], vary=False)
    params.add('cY',
               value=linearCoeffs[1,2], vary=False)
    
    # (k1,k2,p1,p2[,k3[,k4,k5,k6[,s1,s2,s3,s4[,τx,τy]]]])
    distCoeffs = distCoeffs.reshape(5)
    for i in range(5):
        params.add('distCoeffs%d'%i,
                   value=distCoeffs[i], vary=False)
    
    return params
Exemplo n.º 4
0
def formatParameters(rVec, tVec, linearCoeffs, distCoeffs):
    '''
    puts all intrinsic and extrinsic parameters in Parameters() format
    if there are several extrinsica paramters they are correctly 
    
    Inputs
    rVec, tVec : arrays of shape (n,3,1) or (3,1)
    distCoeffs must have be reshapable to (5)
    '''

    params = Parameters()

    if prod(rVec.shape) == 9:
        rVec = Rodrigues(rVec)[0]

    rVec = rVec.reshape(3)

    for i in range(3):
        params.add('rvec%d' % i, value=rVec[i], vary=False)
        params.add('tvec%d' % i, value=tVec[i], vary=False)

    if len(rVec.shape) == 3:
        for j in range(len(rVec)):
            for i in range(3):
                params.add('rvec%d%d' % (j, i),
                           value=rVec[j, i, 0],
                           vary=False)
                params.add('tvec%d%d' % (j, i),
                           value=tVec[j, i, 0],
                           vary=False)

    params.add('fX', value=linearCoeffs[0, 0], vary=False)
    params.add('fY', value=linearCoeffs[1, 1], vary=False)
    params.add('cX', value=linearCoeffs[0, 2], vary=False)
    params.add('cY', value=linearCoeffs[1, 2], vary=False)

    # (k1,k2,p1,p2[,k3[,k4,k5,k6[,s1,s2,s3,s4[,τx,τy]]]])
    distCoeffs = distCoeffs.reshape(5)
    for i in range(5):
        params.add('distCoeffs%d' % i, value=distCoeffs[i], vary=False)

    return params