dh1a (directed homography about z-axis of camera)
clear
close all
filename = 'script5c.jpg';
rgb = imread(filename);
imshow(rgb);
vid = VideoWriter('test3.mp4','MPEG-4');
open(vid);
for thetad = linspace(0,90,120);
theta = thetad*pi/180;
vi = [cos(theta) sin(theta) 0];
vk = [0 0 1];
vj = cross(vk,vi);
R = [vi; vj; vk];
f = 879.2;
pt = [320 320];
KK = [ f 0 320; 0 f 320; 0 0 1];
T1 = R/KK;
newcp = h2e(T1*e2h(pt'));
M = [300 0 0; 0 300 0; 0 0 1]*[eye(2,2) -newcp ; 0 0 1];
T = M*T1;
tf = projective2d(T');
NW = 400;
imageSize = [800 800];
xWorldLimits = [-NW NW];
yWorldLimits = [-NW NW];
RA = imref2d(imageSize,xWorldLimits,yWorldLimits);
[out, RB] = imwarp(rgb,tf,'OutputView',RA);
imshow(out);
frame = getframe
writeVideo(vid,frame);
end
close(vid);