Home > simulink > camera.m

camera

PURPOSE ^

CAMERA Camera imaging model

SYNOPSIS ^

function uv = camera(C, p, Tobj, Tcam)

DESCRIPTION ^

CAMERA     Camera imaging model

    uv = CAMERA(C, p)
    uv = CAMERA(C, p, T)

    Implement the perspective, scaling and offset encapsulated in the
    camera calibration matrix C.  P is a list of 3D world points and
    the corresponding image plane points are returned in UV.
    The data in P is one point per row in X, Y, Z order.

       T is a homogeneous transformation of the object coordinate frame
    wrt to the camera coordinate frame, and can be used to transform
    the points prior to imaging.

 SEE ALSO:    gcamera, camcalp, pulnix

    Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %CAMERA     Camera imaging model
0002 %
0003 %    uv = CAMERA(C, p)
0004 %    uv = CAMERA(C, p, T)
0005 %
0006 %    Implement the perspective, scaling and offset encapsulated in the
0007 %    camera calibration matrix C.  P is a list of 3D world points and
0008 %    the corresponding image plane points are returned in UV.
0009 %    The data in P is one point per row in X, Y, Z order.
0010 %
0011 %       T is a homogeneous transformation of the object coordinate frame
0012 %    wrt to the camera coordinate frame, and can be used to transform
0013 %    the points prior to imaging.
0014 %
0015 % SEE ALSO:    gcamera, camcalp, pulnix
0016 %
0017 %    Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab
0018 
0019 %    pic 1993
0020 function uv = camera(C, p, Tobj, Tcam)
0021 
0022     np = numrows(p);
0023 
0024     % do the camera perspective transform
0025         
0026     p = [p'; ones(1, np)];
0027 
0028     % optionally transform all the points
0029     switch nargin,
0030         case 3,
0031             Tcam =  eye(4,4);
0032         case 2,
0033             Tcam =  eye(4,4);
0034             Tobj = eye(4,4);
0035     end
0036     p = inv(Tcam)*Tobj * p;
0037 
0038     x = C * p;        % camera transform
0039     iXY = x(1:2,:) ./ [x(3,:); x(3,:)];
0040     uv = iXY';

Generated on Sun 15-Feb-2009 18:09:29 by m2html © 2003