def compute_P_from_essential(E):
 (U, S, V) = svd(E)
 if (det(dot(U, V)) < 0):
  V = (- V)
 E = dot(U, dot(diag([1, 1, 0]), V))
 Z = skew([0, 0, (-1)])
 W = array([[0, (-1), 0], [1, 0, 0], [0, 0, 1]])
 P2 = [vstack((dot(U, dot(W, V)).T, U[:, 2])).T, vstack((dot(U, dot(W, V)).T, (- U[:, 2]))).T, vstack((dot(U, dot(W.T, V)).T, U[:, 2])).T, vstack((dot(U, dot(W.T, V)).T, (- U[:, 2]))).T]
 return P2

def compute_P_from_essential ( E ) : ( U , S , V ) = svd ( E ) if ( det ( dot ( U , V ) ) < 0 ) : V = ( - V ) E = dot ( U , dot ( diag ( [ 1 , 1 , 0 ] ) , V ) ) Z = skew ( [ 0 , 0 , ( - 1 ) ] ) W = array ( [ [ 0 , ( - 1 ) , 0 ] , [ 1 , 0 , 0 ] , [ 0 , 0 , 1 ] ] ) P2 = [ vstack ( ( dot ( U , dot ( W , V ) ) . T , U [ : , 2 ] ) ) . T , vstack ( ( dot ( U , dot ( W , V ) ) . T , ( - U [ : , 2 ] ) ) ) . T , vstack ( ( dot ( U , dot ( W . T , V ) ) . T , U [ : , 2 ] ) ) . T , vstack ( ( dot ( U , dot ( W . T , V ) ) . T , ( - U [ : , 2 ] ) ) ) . T ] return P2
computes the second camera matrix from an essential matrix .