Home > General-Functions > Geometry > calc_depth_perspective.m

calc_depth_perspective

PURPOSE ^

% get depth for perspective camera

SYNOPSIS ^

function depth = calc_depth_perspective(X,P)

DESCRIPTION ^

% get depth for perspective camera 

 Usage:
   d = calc_depth_perspective(X,P)

   X  - 4-vector of 3D points
   P  - 3x4 matrix of perspective projection

   d  - depth, is positive if point is in front of camera
 
 Wolfgang Förstner 4/2013
 wfoerstn@uni-bonn.de 

 See also calc_depth_central_x, calc_depth_central_xs, calc_depth_central_xs_RZ

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% get depth for perspective camera
0002 %
0003 % Usage:
0004 %   d = calc_depth_perspective(X,P)
0005 %
0006 %   X  - 4-vector of 3D points
0007 %   P  - 3x4 matrix of perspective projection
0008 %
0009 %   d  - depth, is positive if point is in front of camera
0010 %
0011 % Wolfgang Förstner 4/2013
0012 % wfoerstn@uni-bonn.de
0013 %
0014 % See also calc_depth_central_x, calc_depth_central_xs, calc_depth_central_xs_RZ
0015 
0016 
0017 function depth = calc_depth_perspective(X,P)
0018 
0019 % w'-coordinate = P(3,:)*X
0020 % normalization with
0021 %      determinant |A|,
0022 %      length of vector of viewing direction,
0023 %      homogeneous coord of X
0024 %
0025 depth = -P(3,:) * X * det(P(:,1:3)) / (norm(P(3,1:3)) * X(4));

Generated on Mon 08-Jan-2018 17:21:49 by m2html © 2005