'Factorize the camera matrix into K,R,t as P = K[R|t].'

def factor(self):

    (K, R) = linalg.rq(self.P[:, :3])
    T = diag(sign(diag(K)))
    if (linalg.det(T) < 0):
        T[(1, 1)] *= (-1)
    self.K = dot(K, T)
    self.R = dot(T, R)
    self.t = dot(linalg.inv(self.K), self.P[:, 3])
    return (self.K, self.R, self.t)
