10.6 Example of camera models
This section illustrates the mapping of points into an image frame for the per-
spective and affine camera models. Code 10.1 contains the functions used to create
%***********************************************
%Draw a set of points
%-----------------------------------------------
function DrawPoints(P,colour)
%-----------------------------------------------
[r,c]=size(P);
plot3(P(1,1:c),P(2,1:c),P(3,1:c),'+','color',colour);
%***********************************************
%Draw a set of Image points
%----------------------------------------------
function DrawImagePoints(P,C,colour)
%----------------------------------------------
[r,c]=size(P);
for column=1:c
P(1:r-1,column)=P(1:r-1,column)/P(3,column);
end
plot(P(1,1:c),P(2,1:c),'+','color',colour);
axis([0 C(10) 0 C(11)]);
%***********************************************
%Draw a coordinate frame
%-----------------------------------------------
function DrawWorldFrame(x0,x1,y0,y1,z0,z1);
%-----------------------------------------------
axis equal; %same aspect ratio
axis([x0,x1,y0,y1,z0,z1]);
xlabel('X','FontSize',14);
ylabel('Y','FontSize',14);
zlabel('Z','FontSize',14);
grid on;
hold on;
%***********************************************
%Draw an image plane
%-----------------------------------------------
function DrawImagePlane(C,dx,dy);
%-----------------------------------------------
Appendix 2: Camera geometry fundamentals 371
%CW: Camera to world transformation
CW=CameraToWorld(C);
%transform coordinates to world coordinates
P(:,1)=CW*p(:,1);
P(:,2)=CW*p(:,2);
P(:,3)=CW*p(:,3);
P(:,4)=CW*p(:,4);
%Draw image plane
patch(P(1,:),P(2,:),P(3,:),[.9,.9,1]);
%*************************************************
%Draw a line be