def compute_P(x, X):
 n = x.shape[1]
 if (X.shape[1] != n):
  raise ValueError("Number of points don't match.")
 M = zeros(((3 * n), (12 + n)))
 for i in range(n):
  M[(3 * i), 0:4] = X[:, i]
  M[((3 * i) + 1), 4:8] = X[:, i]
  M[((3 * i) + 2), 8:12] = X[:, i]
  M[(3 * i):((3 * i) + 3), (i + 12)] = (- x[:, i])
 (U, S, V) = linalg.svd(M)
 return V[(-1), :12].reshape((3, 4))

def compute_P ( x , X ) : n = x . shape [ 1 ] if ( X . shape [ 1 ] != n ) : raise ValueError ( "Number of points don't match." ) M = zeros ( ( ( 3 * n ) , ( 12 + n ) ) ) for i in range ( n ) : M [ ( 3 * i ) , 0 : 4 ] = X [ : , i ] M [ ( ( 3 * i ) + 1 ) , 4 : 8 ] = X [ : , i ] M [ ( ( 3 * i ) + 2 ) , 8 : 12 ] = X [ : , i ] M [ ( 3 * i ) : ( ( 3 * i ) + 3 ) , ( i + 12 ) ] = ( - x [ : , i ] ) ( U , S , V ) = linalg . svd ( M ) return V [ ( - 1 ) , : 12 ] . reshape ( ( 3 , 4 ) )
compute camera matrix from pairs of 2d-3d correspondences .