Code covered by the BSD License  

Highlights from
Carving a Dinosaur

image thumbnail

Carving a Dinosaur


Ben Tordoff (view profile)


21 Dec 2009 (Updated )

This is a demo of reconstructing a 3D shape from multiple images using space-carving.

function [K,R,t] = decomposeP(P)
%DECOMPOSEP  decompose a projection matrix into internal and external params
%   [K,R,T] = DECOMPOSEP(P) decomposes projection matrix P into the
%   internal camera parameter matrix K and external params for rotation R
%   and translation t. The original matrix is then recomposed as P=K*[R,t]

%   Copyright 2005-2009 The MathWorks, Inc.
%   $Revision: 1.0 $    $Date: 2006/06/30 00:00:00 $

[q,r] = qr(inv(P(1:3,1:3)));
invK = r(1:3,1:3);
R = inv(q);
% A rotation matrix should have unity determinant, but QR only gaurantees
% a unitary matrix Q. Correct for sign here.
if det( R ) < 0
    R = -R;
    invK = -invK;
K = inv(invK);
t = invK*P(:,4);

Contact us