#NEWLINE# def compute_P_from_essential( E ) : #NEWLINE# #INDENT# '    Computes the second camera matrix (assuming P1 = [I 0]) \n        from an essential matrix. Output is a list of four \n        possible camera matrices. ' #NEWLINE# ( U , S , V ) = svd ( E ) #NEWLINE# if ( det ( dot ( U , V ) ) < 0 ) : #NEWLINE# #INDENT# V = ( - V ) #NEWLINE# #UNINDENT# E = dot ( U , dot ( diag ( [ 1 , 1 , 0 ] ) , V ) ) #NEWLINE# Z = skew ( [ 0 , 0 , ( - 1 ) ] ) #NEWLINE# W = array ( [ [ 0 , ( - 1 ) , 0 ] , [ 1 , 0 , 0 ] , [ 0 , 0 , 1 ] ] ) #NEWLINE# 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 ( P2 . T , V ) ) . T , U [ : , 2 ] ) ) . T , vstack ( ( dot ( U , dot ( W . T , V ) ) . T , ( - U [ : , 2 ] ) ) ) . T ] #NEWLINE# return P2