Calculate camera coordinates from world coordinates using extrinsics
We can solve for window coordinates as follows.
The camera location is obtained from MATLAB cam = -T*R'/12 The camera z-axis is obtained from
or in MATLAB kn = R(1:3,3)'; |
The yellow line illustrates the camera z-axis. It can be
calculated from the extrinsics as
kn = R(1:3,3)'The blue line is parallel to the floor. We can obtain that by dropping the third array element. kb = [kn(1:2) 0] We cam get the look-down angle in radius by first making
down = acos(dot(kb,kn))or down = asin(cross(kb,kn)) Compare this value to the angle calculated from the picture of the camera. |
Calculate the vector between the camera location and the projected location of the principal point shown by the magenta asterisk. Calculate the vector between the camera location and the projected location of the principal point, shown by the blue line. We can also obtain the look-down angle. First calculate the horizontal distance dist = norm(pploc - cam(1:2)) The lookdown angle can then be calculated in radians from down = atan(cam(3)/dist) This should agree with previous values. |
We assume that we moved the camera and captured another image - without altering the height or orientation of the camera.
We basically need to determine the translation and rotation needed to superimpose known features, such as the checkerboard origin and vector along the Y-axis.
We transform the second image using the tform obtained for the first image. Then we calculate the required translation and rotation angle.
tpts2 = transformPointsForward(tf,imgPoints(:,:,nfile)); diff = (tpts2(1,:)-tpts1(1,:))/40/12; kt = tpts2(8,:)-tpts2(1,:); phi = atan2(kt(1),kt(2)); Rf = [cos(phi) sin(phi); -sin(phi) cos(phi)]; cam2 = (cam-diff)*Rf; kb2 = 4*kb*Rf;
Results are shown as follows
The red dot shows the second camera pose determined by homography. The green dot was detrmined by extrinsics.
Maintained by John Loomis, last updated 10 March 2019